Howdy, Stranger!

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

Updating Variables [Harlowe]

I am having trouble updating my variables. This is what I have so far:

Here you can rest, eat, or reassess your inventory.

{(set: $days to 0)
Rest(click: "Rest")[(set: $days to $days + 1)]}

Day $days


but this is what happens when I click "Rest":


Here you can rest, eat, or reassess your inventory.

Day 0


Is there something I'm missing?

Comments

  • You are setting you're $days to 0 at the beginning of the passage. Which would reset the days to 0 every time the passage is loaded. Maybe move this part into an init passage?
  • edited February 2016
    Oops that was not how I meant to write it. I actually do have it in an init passage. I was trying to show that $days was set to 0. But even if I did have it in this passage, wouldn't clicking "Rest" still update the variable?
  • Clicking on Rest will update the variable but it will not update the "Day $day" part of the page, if you want that to happen then you need to do it yourself using code like:
    Here you can rest, eat, or reassess your inventory.
    
    Rest(click: "Rest")[(set: $days to $days + 1)(replace: ?days)[$days]]
    
    Day |days>[$days]
    
  • Not sure. Did you try to reload the Passage? with like [[Rest|RestPassage](set: $days += 1)]
    Or maybe this helps:
    [exampleClick]<Example|

    (click: ?Example)[
    You clicked exampleClick.
    ]
    What you are missing might be a clickable Link. I could be wrong though. Still new myself.
  • Thanks, greyelf, this really helped!
Sign In or Register to comment.