[Sugarcane] Refreshing Passage with state.display()?

In Sugarcane, how does one refresh a passage?

I have something like this:
Name: <<print $player.name>>
Level: <<print $player.level>>
HP: <<print $player.HP>>
MP: <<print $player.HP>>
XP: <<print $player.XP>>
Gold: <<print $player.gold>>

You buy a weapon!

<<set $player.gold = $player.gold - $price>>
The passage still shows $player.gold as it was before the change.

Can I use state.display() somehow to refresh what's on the screen? If it takes JavaScript script passage, I won't know how to write it for Twine, so help in that regard is appreciated.

The passage's name is "Purchase" so I tried <<set state.display('Purchase');>> but that didn't work.

Thanks!

Comments

  • The <<set ...>> are executed in order. So can't you just put your
    <<set $player.gold = $player.gold - $price>>
    above all the rest?
  • No. That's not the real code. This is:
    <span id="box">Name: <<print $player.name>><br>
    Level: <<print $player.level>><br>
    HP: <<print $player.HP>><br>
    MP: <<print $player.HP>><br>
    XP: <<print $player.XP>><br>
    Gold: <<print $player.gold>><br></span>

    <span id="content">

    <<if $place eq "armory">>

    <<if $player.gold gte $price>>

    <<set $player.gold = $player.gold - $price>>

    "Thank you!"<br><br>

    You received a <<print $itemName>>.<br><br>

    <<if $itemName eq "Club">>

    <<set $weaopn = {
    name: "club",
    attack: 5,
    }>>

    <<elseif $itemName eq "Axe">>

    <<set $weaopn = {
    name: "axe",
    attack: 10,
    }>>

    <<elseif $itemName eq "Sword">>

    <<set $weaopn = {
    name: "sword",
    attack: 15,
    }>>

    <<elseif $itemName eq "Leather Armor">>

    <<set $player.armor = 5>>

    <<elseif $itemName eq "Mail Armor">>

    <<set $player.armor = 10>>

    <<elseif $itemName eq "Plate Armor">>

    <<set $player.armor = 10>>

    <<endif>>

    [[OK|Place]]

    <<else>>

    "I'm sorry. You don't have enough money."<br><br>

    [[OK|Place]]

    <<endif>>

    <<endif>>


    <<if $place eq "healer">>

    "Let your wounds be healed."<br><br>

    <<set $player.gold = $player.gold - $price>>
    <<set $player.HP = $player.maxHP>>

    [[Return to Town|Town]]<br><br>

    <<endif>>


    <<if $place eq "apothecary">>

    <<if $player.gold gte $price>>

    <<set $player.gold = $player.gold - $price>>

    You received a <<print $itemName>>.

    <<else>>

    "I'm sorry. You don't have enough money."<br><br>

    [[Return to Town|Town]]

    <<endif>>

    <<endif>>


    <<if $place eq "inn">>

    <<if $player.gold gte $price>>

    <<set $player.gold = $player.gold - $price>>

    <<set $time = 0>>

    You sleep at the inn.<br><br>

    "I trust your stay was a good one? I'll see you later."<br><br>

    [[Return to Town|Town]]<br><br>

    <<else>>

    "I'm sorry. You don't have enough money."<br><br>

    [[Return to Town|Town]]

    <<endif>>

    <<endif>>

    </span>
    As you can see, it's much more complicated than that. :(

    Even if I could jury rig it somehow, the point is, I would like to know how to use state.display(). I have a game that uses it, but Henry Soule wrote the code and I can't figure out how to adapt it.
    <<set state.display('StoryRegions Module','','offscreen');>>
    "StoryRegions Module" is a script passage. Don't know what the "offscreen" does, but I've tried adding it (or not adding it, like above) and couldn't get it to work.