mirror of
https://github.com/godotengine/godot.git
synced 2024-11-10 14:12:51 +00:00
FileAccess.xml had conflicting function names in its example code
In the example code the declared load() function conflicts with global scope load(). so if you copy pasted it in godot 4.2.2 you would get a "Too few arguments for "load()" call. Expected at least 1 but received 0." error since it doesn't override global scope load().
This commit is contained in:
parent
11d3768132
commit
40651eb642
@ -8,23 +8,23 @@
|
||||
Here's a sample on how to write and read from a file:
|
||||
[codeblocks]
|
||||
[gdscript]
|
||||
func save(content):
|
||||
func save_to_file(content):
|
||||
var file = FileAccess.open("user://save_game.dat", FileAccess.WRITE)
|
||||
file.store_string(content)
|
||||
|
||||
func load():
|
||||
func load_from_file():
|
||||
var file = FileAccess.open("user://save_game.dat", FileAccess.READ)
|
||||
var content = file.get_as_text()
|
||||
return content
|
||||
[/gdscript]
|
||||
[csharp]
|
||||
public void Save(string content)
|
||||
public void SaveToFile(string content)
|
||||
{
|
||||
using var file = FileAccess.Open("user://save_game.dat", FileAccess.ModeFlags.Write);
|
||||
file.StoreString(content);
|
||||
}
|
||||
|
||||
public string Load()
|
||||
public string LoadFromFile()
|
||||
{
|
||||
using var file = FileAccess.Open("user://save_game.dat", FileAccess.ModeFlags.Read);
|
||||
string content = file.GetAsText();
|
||||
|
Loading…
Reference in New Issue
Block a user