Ambrosia Garden Archive
    • Global Variables and Saving


      Quick question:

      I tried using a global variable in a plug-in for POG. I had an event that set the content of a global variable to true. Imagine my surprise when I loaded a previous game (where the variable should not have been set) and the global variable was set to true!

      Shouldn't the global variable had been returned to its previous state when I loaded an earlier game? Anyone else see this? Am I doing something wacky?

      --v

    • Quote

      Originally posted by VictorC:
      **Quick question:

      I tried using a global variable in a plug-in for POG. I had an event that set the content of a global variable to true. Imagine my surprise when I loaded a previous game (where the variable should not have been set) and the global variable was set to true!

      Shouldn't the global variable had been returned to its previous state when I loaded an earlier game? Anyone else see this? Am I doing something wacky?

      --v**

      Hello-
      At the risk of exposing my ignorance, I'm thinking global event means global -- it's going to be what that event says it will be in all cases.

      I'll try and get a definitive answer for you.

      We'll do our best to help with plug in and game design, and answer all of the general questions we can, but we won't be able to troubleshoot individual games or projects.

      The longer Coldstone is out, the larger the community of developers and users will be with a body of knowledge to give hints and troubleshooting tips.

      ------------------
      David Dunham / tech support / Ambrosia Software, Inc.

    • Thanks for the reply.

      Although, at the risk of exposing my own igorance 🙂 -- if this is how it's supposed to work, how can you rely on a global variable to tell you if a player has completed a quest or not?

      I thought that's what global variables were for -- switches you can flip to say: the player has completed this quest. But if a player restores a previous game where he hasn't completed the quest, but the global variable says he has, then things are going to get all screwy.

      I would think that the engine would save the state of all global variables when the player saves, then restore the variables whenever he or she loads a game. Otherwise I have to rely on giving the character an object and testing for the presence of that object. Fine for a big quest, but if I just want to recognize that the player talked to someone it seems kind of cumbersome.

      Maybe I'm thinking of it all wrong. If anyone has any suggestions on how I can "remember" events between saves and loads, please speak up!

      Thanks!
      --v

      ------------------

    • From my own project, if you save a game, the state of the global variables are saved with it. This is the behaviour that would be desired, since we need to be able to keep track of things like the completion of quests (as mentioned before). (Of course I'm sure your imagination will come up with many more reasons to use globals). If you want some globals to always be set to a certain state after loading the game I think you could use an event to initialize them after the saved game has been loaded. (I haven't tried this, but it seems possible.) The other way to do it would be to set them to the desired state just before the save dialog appears (so that they save as their initialized state). Anyway, the point is that there are ways to initialize globals but unless they are saved, you can't have any kind of persistence to your game.

      -Jeff

      ------------------
      Experiences = Integrate( Life, {t, birth, death} )