Replies: 2 comments 8 replies
-
That's not what they do and not what the documentation says, so I'm unsure where the confusion comes from:
Why would you need to store just one variable with no other data, and why is it not just as easy to use: var fa := FileAccess.open(path, FileAccess.WRITE)
fa.store_var(my_data) It's just one additional line and it can do so much more There's even detailed tutorials on this Adding a method just for people who are absolute beginners and can't read the documentation feels unnecessary |
Beta Was this translation helpful? Give feedback.
-
Also if you need this you can just add your own autoload or static method to do this, something like: extends Object
class_name LoadSaveHelper
static func get_variable(path: String, allow_objects: bool = false) -> Variant:
var fa := FileAccess.open(path, FileAccess.READ)
if fa:
return fa.get_var(allow_objects)
return Variant()
static func store_variable(path: String, value: Variant, full_objects: bool = false) -> bool:
var fa := FileAccess.open(path, FileAccess.WRITE)
if fa:
fa.store_var(value, full_objects)
return true
return false Haven't tested but should work fine, you just call |
Beta Was this translation helpful? Give feedback.
-
File/save operations are a reccuring problem for new users for something that should be common and trivial.
Inevitably they all try using store_var and get_var, which feels correct but does not do what they think (which is storing and loading a variable).
PROPOSAL - Make easy to understand just works gdscript functions for saving and loading a generic non typed variable to a given file save path. So beginners can simply use store_variable(savepath, variable_name) and get_variable(savepath, variable_name) and GDscript does the magic behind the scenes (make/load the dictionaries etc.).
Pro users can still use the existing properties like they already do and this will not affect them.
END OF PROPOSAL
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions