Harlowe 3.1 Saving/Loading Variables

I’m making a Pokemon-inspired game, and wanted to have a load/save function. But I found out that the load/save on the Harlowe guide doesn’t save my variables. Is there anyway I could do this? Thanks!

1 Like

and wanted to have a load/save function.

I’m assuming you know about using the (save-game:) macro to save the current state of History and using the (load-game:) macro to replace the current state of History with the one store in a save.

I found out that the load/save on the Harlowe guide doesn’t save my variables.

Could you explain in greater detail what lead you to believe the above, possibly with example source code from your project demonstrating any issues you are having and the type of variable/values you’re having them with.

Hi @Greyelf ! Thanks for responding! Yeah, so I was trying the load/save macro, and it saved my passage, but not the variables. Example, if a user got a map (set: $map to true), when the user would save and load the game, all the variables were set to 0, so $map would be 0/false, not true. Thanks in advance!

info:
The (save:) macro saves the current state of (History) all known story variables as they were just before the contents of the current Passage was processed and shown. So if your $map variable was assigned a value before the current Passage was navigated to then that should be the value that variable is reset yo when that save is loaded.

eg. If $map was equal to true before the current passage was navigated to then that should be the value saved within a save generated for the current passage.

After the loading of a save has finished updating the History the load code navigates to the Passage associated with that save, this results in that Passage becoming the ‘current’ one and the contents of that passage being re-processed/executed.

So when you were testing the save/load functionality did:

  1. The $map variable have a value of true before you navigated to the Passage you created the save for.
  2. Did the Passage you created the save for contain code that changed the value of $map
1 Like

Hi! I followed what you said, and now it is working! Thanks!