Variable question
Terrorble
Member Posts: 179
If I set a bunch of variables on an object like a WP or area via scripting and save the game, do those remain when I reload the game?
0
Comments
This isn't the same as online play, where restarting modules "clean" is routine and so variables usually have to be saved on something which isn't a part of the module.
The most secure method with the least trouble which I've found is to give your PCs a permanent, undroppable item (it can even be useful for something else, so long as it can't be dropped or destroyed) upon which you save all variables relating to that PC.
The other way is to save the variables in a database and then re-load them on module load and re-create them on the appropriate objects.
But if you're playing a single-player module, or creating one, you can count on any variables which are created on objects being saved along with the rest of the game.
If it didn't save them, I'd be in a lot of trouble with my current idea unless I figure out how to handle storing the info in a database - which I'm not sure I want to do. Better to be certain they saved now.
I use the heck out of the PC database item for what I can, but I can't see a way to store all these WP vars on that, especially since multiple people could play at once.
It has the advantage that, if you ever want to offer the PCs the option of resetting back to level 1 and starting over with the same character, you only need to remove the undroppable item (a script can still destroy it) and give them a new one, and they lose all variables so they can start quests over again.
(Another method for giving the PC the permanent item on entry is to check if they have zero experience points and if so, give them the permanent item and one experience point, so that the script will skip them next time)
I'd advise making the permanent item something "tiny" so that it takes up the minimum of inventory space, unless you have a good reason for using something larger.