User vars are totally easy to learn and to use.
So, if you want to create variable, go to script editor and press "Variables" then press add.
First, give it a name. (It's always good to use short variable names like: jump, dir, ...)
Then, you can choose is it global or actor variable. If you make it global, you can use it like to hold some global things, like score. If you make it actor variable, it becomes same kind of variable as x and y coordinates; every actor will have it's own value for it.
Next thing you choose is integer, real or string. Integer can hold number like: 1, real can hold number with decimals, like: 1.43, and string is for characters, and strings of them.
You can choose is it array or no, and the array size. If you choose to make it array, then you have to give it some size. One array can hold many things like positions. You can use it like this:
- Code: Select all
pos[0] = view.x;
pos[1] = view.y;
pos[2] = Player.x;
pos[3] = Player.y;
This is just simple example of how you can use arrays. It's easier to create array called pos and give it size of 4, and then use it like what the code was, than create single vars for all of those, like viewX, viewY, etc.
And save group is for making variables able to save. For positions, you can create own save group called positions and other groups for other things.
For saving and loading variables, you can use saveVars and loadVars.
They work like this:
Saving:
- Code: Select all
saveVars("file name here with ending, like .dat", "save group name here");
Loading:
- Code: Select all
loadVars("file name here with ending, like .dat", "save group name here");
You can find saveVars and loadVars also from script editor by clicking variables / functions and then searching them from there. Then it opens a new window where you can choose file and save group.
I think these were the most important things about variables.
If you still need help with them, ask.