Hello Twine-masters,
please help me. I want to make a small and simple game, where I stand in a startingRoom and can go to a different passage1, doing stuff there, then going back to the startingRoom and when I go to the passage1 again, the game should remember what I already have done there and should hide these options.
But at the moment I can do everything over and over again.
I use Twine2 2.0.10 and the Story Format Harlowe 1.2.1
So as an example excerpt, when I go to passage1 I can search a desk:
[Search the desk]<cl1|
(click: ?cl1)[
There is:
[Pistol]<getPistol|
[Ammunition]<getAmmunition|
]
(set: $pistolCheck to false)
(click: ?getPistol)[
I took the pistol!
(set: $pistolCheck to true)
]
(set: $ammunitionCheck to false)
(click: ?getAmmunition)[
I took ammunition!
(set: $ammunitionCheck to true)
]
In the next passage, I want to be told, what I took from the desk:
(if: $pistolCheck or $ammunitionCheck)[
I have:
$pistolCheck[A Pistol]
$ammunitionCheck[Ammunition]
]
[[back to the starting room->startingRoom]]
But when I now go to the startingRoom and from there to the desk-passage again I can search it and althoug I already took the pistol and/or the ammunition, it is there again and I can just take it again.
And I want it to tell me, that i already have taken one or both (depending if I took one or both) or just hide what I already did.
Can you please tell me an easy way (if possible) how the game can remember what I did throughout the passages?
Thank you very much in advance!
Matt
Comments
There is also a useful function visited(passagename), which return how much times you've visited the passage.
Instead of initializing (assigning a default value) your $pistolCheck and $ammunitionCheck variables in the passage1 passage it would be a better idea to do that before the story starts within a startup tag passage.
Try the following:
a. Create a new Passage, name it Startup and add a startup tag to this new passage. Also add the following code to the new passage: b. Remove both of the above two assignments from the passage1 passage.
Now the story will remember if you picked up the Pistol and/or the Ammunition.
notes:
1. The startup tag must be in all lower-case letters.
2. You can actually name the new Startup passage anything you want, it is the tag which causes the passage to be process before the story starts.
3. It is a good idea to initialize all your variables within the startup tagged passage.
Matt