Hi! After googling and finding some other discussion on here, I discovered that the easiest way to create dynamic links that 'remember' the state information at their moment of construction is to use the print command to build them. In this case, I want to list all of the locations that the player can visit, and so I loop through all locations and check which ones can be visited, etc. When the player selects an option, they consume some stamina - and the amount they consume is different for each location.
So, in order to deduct the correct amount of stamina, the stamina reduction must be hardcoded into the link while the list of links is being generated, using the print command. That is:
<<print '[[' + $cur_location.name + '|' + $cur_location.passage + '][$pc.stamina = $pc.stamina - ' + $cur_location.stamina + ']]'>> (Stamina: <<print $cur_location.stamina>>)
($cur_location is updated with each step through the loop)
This was working for me, exactly as intended. However, when I went to try to adjust the 'setter' portion of the setter link by adding in a second set variable so that I could keep track of the player's location, i.e.
<<print '[[' + $cur_location.name + '|' + $cur_location.passage + '][$pc.stamina = $pc.stamina - ' + $cur_location.stamina + '; $location = ' + $cur_location + ']]'>> (Stamina: <<print $cur_location.stamina>>)
I got the "Error: Script Error.."
I tested this using a non-dynamically generated link (i.e. removing the print command and keeping all the rest the same) and that produced no errors (though of course, it deducted the wrong amount of stamina and set $location to the wrong thing because it used the values at the end of the loop when the user clicked).
So I was wondering, have I just made some sort of silly error in the second bunch of code there, or do I need to use a different syntax (maybe the ; character is upsetting Twine somehow when it's inside the print command?), or do I just need to work around this completely?
Thank you very much for any insight.