Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Question about (save-game:) and variables (Harlowe)

edited April 2016 in Help! with 2.0
So, I fashioned a save and load menu by putting a bunch of stuff in a passage with the header tag. In itself, the saving and loading works perfectly fine, but at some point I decided to add a functionality that displays an "(empty)" behind the slot name if you haven't saved to it yet and the date and time of the save, plus what chapter the player was at if they have saved to it, so now it looks like this:

{(link:"Save game")[(text-style: "underline")[Save to:]
|A>[(link:"Slot A ($SLOTA)")[(set: $SLOTA to "(current-date:)" + "|" + "(current-time:)" + "|" + "$Chapter")(replace: ?B)[](replace: ?C)[](if:(save-game:"Slot A"))[Game saved!](else:)[Saving failed!]]]
|B>[(link:"Slot B ($SLOTB)")[(set: $SLOTB to "(current-date:)" + "|" + "(current-time:)" + "|" + "$Chapter")(replace: ?A)[](replace: ?C)[](if:(save-game:"Slot B"))[Game saved!](else:)[Saving failed!]]]
|C>[(link:"Slot C ($SLOTC)")[(set: $SLOTC to "(current-date:)" + "|" + "(current-time:)" + "|" + "$Chapter")(replace: ?B)[](replace: ?A)[](if:(save-game:"Slot C"))[Game saved!](else:)[Saving failed!]]]]}
{(link: "Load game")[(text-style: "underline")[Load from:]
(link: "Slot A ($SLOTA)")[(load-game:"Slot A")]
(link: "Slot B ($SLOTB)")[(load-game:"Slot B")]
(link: "Slot C ($SLOTC)")[(load-game:"Slot C")]]}

$SLOTA, $SLOTB and $SLOTC are set to "empty" at the beginning of the game and $Chapter is set accordingly at the beginning of each new chapter. So, theoretically this should work, but what happens is this: When I click on "save game" or "load game" after saving to one of the slots, the message containing the date, time and chapter is displayed as intended. But when I load that save and then click on save or load again, it says "empty" again. At first I thought it was because the variables for the messages were actually set after the game is saved (the set macro was originally after the save-game macro), but even when I moved that part before the actual saving part (as displayed above), the problem persisted. So, why are the values for those variables not carried over after loading? It seriously doesn't make sense to me, from everything I know about how harlowe works, this should do what I want it to... It's not exactly a gamebreaking issue so I can keep working without problems, but at some point I'd like to fix this and I have no idea where the problem even lies...

Comments

  • A save contains the state of all the story $variables as they were just before the current passage was processed, so any change to a variable done in the current passage is not stored within the save.

    It is done that way so that the current passage's changes don't happen twice, once before the save and once after the load.
  • edited April 2016
    Ah, thanks a lot, that explains it! I think I already have a vague idea of a workaround... tinkering time! :D I take that back... At least I can make it say if the file is empty or not, that'll have to be enough, though maybe I'll figure something out one day... As long as I know what the problem I have to solve is, there is hope...
Sign In or Register to comment.