Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Suleymanov |
Hope you are doing well. I wonder if a script can change its variable permanently. I’ll clarify my question with an example. I have a variable, let’s say:
var time = 0
Can a function change var value permanently so that the next time it’s something else but “0” even after I restart Godot?
For example, the next time I open the script I see:
var time = 378
Is there any way the script can rewrite the var value automatically and update itself?
Why do I need it you ask? I want to dump JSON.
You mean after you restart the programm? or do you mean next time when you run your function again without restarting the programm?
klaas | 2020-07-17 18:04
I mean after I restart the program. Let me put it this way, I can manually change the value of a variable, right? But can I write a function to do it automatically? So that the initial var value is always the updated value?
var = 0
if blah-blah:
var = 57
And the next time I start Godot (or a level) the variable is 57
var = 57
if blah-blah:
var = 178
And so on.
Suleymanov | 2020-07-17 18:42