So I'm trying to create a game where the game randomly generates the text when you click on the room, AND that text is assigned a value. So, for example, the player is given the choice of weapons, and they choose to use the sword. That opens up a new passage called "Sword."
I want the screen to display a random choice:
<<print either("the sword slices through the air", "you miss with the sword but receive a blow from your opponent", "you stab the sword cleanly through your opponent's arm")>>
BUT
Let's say I also am tracking the player's strength with $strength. I want the second option (you miss with the sword but receive a blow from your opponent) to subtract a point from $strength with $strength = $strength - 1. And I want the third option (you stab the sword cleanly through your opponent's arm) to add a point to $strength with $strength = $strength +1.
I then want to display the weapons again (using <<display "weapons">>) to take the player back to the original choice room and allow them to choose again.
How would I add the variable so depending on the text displayed, the variable's value changes? Is that possible? Is there another work-around?
Comments