Twine Version: 2.10.0
Sugarcube: 2.37.3
I have a variable stored as part of a string. I’d like to set the variable, print the string in one place on the passage, then change the value, refresh the passage, and print it in another place. The problem is, doing this changes the value in the first place too.
Is there a way to “freeze” the first string with the variable’s initial value while printing the second string with the new value?
/*StoryInit*/
<<set $players to ["bob","jill"]>>
<<set $direction to "">>
<<set $bob = {
name: "Bob",
moveDescription: "",
}>>
<<set $jill = {
name: "Jill",
moveDescription: "",
}>>
<<set $walk = {
name: "Walk",
description: "You walk $direction.",
}>>
/*home*/
<<for _i to 0; _i lt $players.length; _i++>>
<<capture _i>>
<<set $name to State.variables[$players[_i]].name>>
<<= $name>>
<<button "Go West">>
<<set $direction to "west">>
<<set State.variables[$players[_i]].moveDescription to $walk.description>>
<<goto "home">>
<</button>>
<<button "Go East">>
<<set $direction to "east">>
<<set State.variables[$players[_i]].moveDescription to $walk.description>>
<<goto "home">>
<</button>>
<</capture>>
<<= State.variables[$players[_i]].name>> Move: <<= State.variables[$players[_i]].moveDescription>>
<</for>>
In this example, I want to be able to click “Go West” on Bob’s button and update his description to “You walk west.” Then I want to click “Go East” on Jill’s button and update her description to “You go east.” while leaving Bob’s as “You go west.”