Smorty [she/her]

I’m a person who tends to program stuff in Godot and also likes to look at clouds. Sometimes they look really spicy outside.

  • 22 Posts
  • 78 Comments
Joined 1 year ago
cake
Cake day: July 5th, 2023

help-circle

  • Fix: Run the FileAccess.get_file_as_bytes() method in a thread. I thought a thread wouldn’t allow for loading files using FileAccess, but it seems I was mistaken. I personally just make the Thread run my _threaded_loading(file_path:String) method and then call a signal named loaded_bytes(data:PackedByteArray). The _threaded_loading method looks like this:

    func _threaded_loading(path:String) -> void:
    	print("I am the thread and I will now load this file")
    	var file:FileAccess = FileAccess.open(path, FileAccess.READ)
    	print("i have opened the file")
    	var bytes:PackedByteArray = file.get_buffer(file.get_length())
    	print("I have the bytes of the file")
    	file.close()
    	print("I have closed the file")
    	call_deferred_thread_group("emit_signal", "loaded_bytes", bytes)
    	return
    

    It is important to emit the signal deferred, as a Thread on its own can’t emit a signal on its own. I did print a lot in the method just to check that everything is working as intended. I hope this helps someone!


















  • This seems to be the exact thing I am searching for, thanks! I have run into an interesting hickup tho. One can pass self to the expression so that it uses the node as the base, but the expression doesn’t seem to have access to autoloads. The error I’m getting there looks something like this: Invalid named index ‘ExampleAutoload’ for base type Object EDIT: Turns out I need to pass these individually as arguments essentially.