Results 1 to 6 of 6

Thread: Variables saving between game loads

  1. #1

    Variables saving between game loads

    Hello, I looking to create a script for role playing games such as pathfinder and DND, but I am faced with one large problem and that is how to pass variables from game to game. For instance recently in a game that I was DMing a game and 2 out of three people had to go suddenly so we are currently between two encounters How would I save their number of first level spells between games. The way I currently have my scripts identifying it is using a dice but this feels like it has two many opportunities for people to mess accidentally with it. Is there currently a good way of dealing with this issue?

  2. #2
    Join Date
    May 2016
    Posts
    1,072
    You could save them to chest then load them in? If you used scripted counters to track spells those could be tossed into a bag and saved as well. It just depends on how you WANT to make it happen I think.

  3. #3
    How would I save the integers on the item. Would I just declare the integer in the items code and then throw the item in the bag and change it with it still in the bag?
    wouldn't the code still reset upon loading it as a save? Thanks for your speedy response.

  4. #4
    Join Date
    May 2016
    Posts
    1,072
    It depends. You could have an onSave function on items and have it save a variable value. But you couldn't change it while its in the bag (without editing the json).

    You could manage it in Global or on an item. Have that keep a table of the a value, use unique names to access them.

    tableYouSave = { someValue = 5, someOtherValue = 2, etc }

    Then, on the items, use getTable to pull that table into the item (temporarally) and locate its value on it. Then any time you pull that token out of the bag, it will get the most up-to-date value.

    You really do have a lot of flexibility. But to be honest, I'm not 100% sure what you goal is. I'm trying to answer your questions, but I may be leading you astray. If you have further questions, could you try to clear it up for me from a purely functional standpoint, what are you trying to achieve? By that, I mean just the "I want and object (X) to do (Y) so I need to give it some value (Z) to make that happen" kind of stuff.

  5. #5
    I am dumb... I just realized as I was rephrasing this to you that I wanted exactly what a counter does and there is already a way to reference the counter in scripting so I can do that easily and the save will keep track of it. I was looking for someway to store a number across scripts and counters easily solve that issue. Thanks for helping me so much.

  6. #6
    See "onSave" function for script related variables.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •