Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Remembering what already happened in passages.

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

  • yunyun
    edited February 2016
    I don't know the syntax of your story format, but in Sugarcane it will look like this:
    <<if $pistolCheck>>I have a pistol already<<else>>[[Take pistol|getPistol][$pistolCheck=true]]<<endif>>
    
    (Instead of going to a special passage "getPistol", you can return to the same one, and you will see the new text.)
    There is also a useful function visited(passagename), which return how much times you've visited the passage.
  • edited February 2016
    zoelibat wrote: »
    Can you please tell me an easy way (if possible) how the game can remember what I did throughout the passages?
    The reason the story seems to be forgetting if you picked up the Pistol and/or the Ammunition is because you are setting both $pistolCheck and $ammunitionCheck to false each time the Reader visits the passage1 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:
    (set: $pistolCheck to false)
    (set: $ammunitionCheck to false)
    
    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.
  • It's working. Thank you very much again!! :)

    Matt
Sign In or Register to comment.