xenidius93 wrote:Okay, but it still doesn't load the BestDude variable from text file BestDude.txt :/. Probably it's very simple fail in my code, but it's not that simple for me
Your problem is not that it isn't loading the variable, but instead that you never save any information into it. It seems like as if you we're saving the contents of Dude, but you have never set the Dude variable to hold any characters.
Another problem is that even if you first set Dude to contain the text of the ENTER_NAME actor, it still won't work with just that code, because that code gets run the instant GAME_END actor is clicked, so nothing has been written on the ENTER_NAME actor before saving. I'd recommend you to scrap that code and give it another try. Some things to note:
1) You don't have to have a new save group for each variable. Actually, it makes a lot more sense to have all the variables that are saved and loaded at the same time, to be in the same save group. So, instead of having save groups BestDude and highscore (by the way, that naming is bad practice because it can lead you get the save group names and the variable names mixed, use something like "highscoreGroup" instead).
2) Just so that you know, there are far easier ways of defining global variables than having a complete Global Code page dedicated to only one variable declaration.
You can either list all the global variables in the same Global Code page, like this:
- Code: Select all
char * Dude;
int Phighscore;
int Ppoints = 0;
And then give the page a name like "Global variables". Again, you're current naming practice is bad in this place as well. You are cheating yourself into thinking that the names of the Global Code pages are somehow related to the names of the variables you're defining within them.
Or you can just create the global variables through the Variables dialog. Whether to use this or the upper method just depends on what you prefer, but you definitely shouldn't create new Global Code pages for each global variable you want to define.
3) About saving and loading.. Whenever you want to save variables, first make sure you have set some values to each of the variables in the save group, and then call saveVars() on that save group.
And when loading variables, first call loadVars() on the correct save group, and then use the values loaded into the variables.