Please specify version and format if asking for help, or apply optional tags above:
Twine Version: 2.3.9
Story Format: Harlowe 3.1.0
Question: How do I get the value of a variable stored in an array without storing it as a pointer?
I have an array which I store all the past history of my conversations with a character.
I have a problem when I generate random content, I use text variables $tempText, $tempText2, etc… to store random text and then print them and then save them into the $history array.
I found out that the (set: $history to (a: “$tempText $tempText2 $tempText”) + $history) does not store the values of $tempText but rather the pointer of that variable. So in the following passage I use the same variables again, result is that the $history is inaccurate since it references as a pointer $tempText, rather than value of that variable at the time I added to the array. I tried to convert the variables to Strings with (text: $tempText) but that doesn’t work either. How do I store a value of a variable in an array in Harlowe and not the pointer variable?
The following is the code I am playing with. You can see that
$tempText in the top history should be either: “I want to thank you! You saved my life!” or “OMG! It’s you! You saved my life, you’re amazing!”
$tempText2 should be “If you hadn’t shown up, I’d be doomed for sure!”
but they are overridden by the following passage’s use of $tempText
(set: $tempText to (either: "I want to thank you! You saved my life!", "OMG! It's you! You saved my life, you're amazing!")) (set: $tempText2 to "If you hadn't shown up, I'd be doomed for sure!
") (set: $tempText3 to (either: "You can bet the Militia would never have come back for me", "Damn Militia sent us out there to get slaughtered" )) $tempText $tempText2 $tempText3 (set: $history to (a: "(text: $tempText) (text:$tempText2) (text:$tempText3)
") + $history)
(set: $tempText2 to (either: "Did the Militia send you into that fray, and then left you there?","What do you mean? I thought the Militia was here to protect us all?","What you mean about the Militia?")) (link-reveal-goto: "$tempText $tempText2","meetOpposedMilitia")[ (set: $history to (a: "$tempText $tempText2
") + $history) ]
Your welcome. Did the Militia send you into that fray, and then left you there? Damn Militia sent us out there to get slaughtered
Your welcome. Did the Militia send you into that fray, and then left you there?
The Militia sends us all to our doom! We’ve lost countless Bunnies to their terrible command and leadership! I was forcibly conscripted to fight for them.
You found me after the last command abandoned us when the zombies got too close for comfort
Your welcome… left you there? replace prior values