How to exempt a State Variable from being loaded upon Save.slots.load [Sugarcube 2]

0 votes
asked 5 days ago by puppetz87 (250 points)

Hello everyone,

Following up from my previous post: ,

I would like to know if there's a way to exempt a variable from being loaded when the Save.slots.load method is executed, or alternatively is it possible to execute a script that stores the state variable data externally (i.e. not through the variable store) so that I can retrieve it after executing a save.slots.load?

I want to add that the variable data im trying to store is an array of objects, each with their own individual properties. I apologize if making this second post is unnecessary, but I feel that this is a completely different question from my previous post.

2 Answers

+1 vote
answered 5 days ago by Chapel (26,410 points)

You can make variables that aren't part of the state. It's generally recommended that you use the setup object for things like this. 

<<set setup.var to "blah">>

If that for some reason won't work for you, then you can use the Config.saves.onLoad property to create a single use task object to reset or otherwise change story variables when the game is loaded. I can write you up an example of that if needed, but I think just using the setup object or similar is your best bet, depending on what you're doing. 

commented 2 days ago by puppetz87 (250 points)
Awesome.  Thanks for the help.  I'm going to try your method in addition to TME's and see which one works best.
+1 vote
answered 4 days ago by TheMadExile (14,870 points)

If you want your stashes to be persistent, see my comment on your other thread.  If that's not a requirement, then Chapel's idea will work.


commented 2 days ago by puppetz87 (250 points)
Thanks again TME.  I'm going to try both methods and see which one works best for me in the context of my game.  :D