Howdy, Stranger!

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

Sugarcube: Saving variable changes in same passage

I feel bad to clutter up this forum with all my questions, but I think it might be better than having conversations about multiple different topics in one thread.

I've updated my demo (also source) so that you can finish the conversation and go back to the apartment passage. (For convenience, I've set it so that the intro sequence is skipped.) If you get any of the items in the apartment, and then refresh the page, you won't have them anymore. Even worse, the same thing happens if you save the game then restore. However, if you get stuff, go do the conversation, then return to the apartment, refreshes and saves alike will keep the items you get.

How can I make sure variables get saved without having to go to another passage? <<rembmer $inv>> at the end of the inventory macros doesn't seem to do anything. If I had to take a guess, it will probably involve advancing state.history at the end of the interact widget, but precursory browsing of the object structure in the browser console did not leave me very comfortable with guessing how to do that.

Comments

  • Short answer: You don't.  Long answer: What you're trying to do is completely counter to how any of the current Twine headers work.  You are supposed to traverse passages to generate story history states.  Generating them is more complicated than simply pushing stuff into state.history (which you should never be doing manually, for multiple reasons).

    Summary: Having player interaction outside of the normal passage traversal mechanism is, generally, okay.  Mutating state while doing so, especially if the non-passage traversal interactions are extensive, not so much.
  • Oh. That almost completely destroys everything I was trying to do. I wish I'd taken care of this first. :(

    The only thing I can think to do to work around this is to change interactions so that instead of being <<click>>s that show passages in a div, they are links that set a variable tracking the current interaction passage and go to the current passage. The only reason this is viable is because I don't currently have passage transitions at all. If I decide I want them, this will become ugly unless I can figure out ways to conditionally enable transitions (e.g. don't transition if it's the same passage).

    Do you have any better ideas, or see anything wrong with this idea?

    EDIT: Yup, I ran into the giant stopper after changing up the implementation. Clicking a link that leads to the passage you're currently on does absolutely jack squat. Which means I have to make my save points separate passages, and advise readers against refreshing unless they want to redo everything they did in a passage. (Which I guess in retrospect might be good for puzzles?) I backed up the old version of libdynamicstory, but the current one that tries to fix this is here.
Sign In or Register to comment.