- Edited
SOLVED
I fully just forgot to actually link the save button press with the save function itself. My first idea of code worked exactly as planned! Keeping the post up just in case someone else runs into something like this. Check your connections!!
I have a program that I've made to randomly create a NPC for ttrpg games on the fly by randomly picking from different Arrays. My question is, how can I save that NPC to a new .txt file each time?
I was thinking something like
func save_NPC():
var save = FileAccess.open("user://" + First_Name_Text + "_" + Last_Name_Text + ".txt", FileAccess.WRITE)
save.store_string(str(Final_Text))
save.close()
Final_Text is the fully generated NPC text and reads something like this
Name: Patrick Hong, "Pebble"
Looks: Akarosi, Man, Striking
Goals: Cooperation
Preferred Methods: Alchemy
Profession: Tanner
Traits: Suspicious
Interests: Gadgets, new technology
Quirk: Inherited their position. May not deserve / want it.
So that in theory it would save a "John_Doe.txt", reroll and save a "Juan_Perez.txt", reroll and save a "Jean_Dupont.txt" and then in the folder I would have 3 files named John_Doe, Juan_Perez and Jean_Dupont.
However Godot doesn't like that. I did look over the File Access documentation but it's honestly all over my head. Youtube tutorials help make this:
var save = FileAccess.open("user://NPC.txt", FileAccess.WRITE)
save.store_string(str(Final_Text))
save.close()
but that also isn't creating anything and would overwrite an old NPC with a new one I think.
The way I have the program running I could just copy and paste the NPC information but it'd be nice to a have a button that does it for me. Any help with this would be greatly appreciated!