Quest - Why can't I unlock the door?

0 votes
57 views
asked Jul 28 in Authoring by Marleen (3 points)

I have created a locked exit and the following script:

if (not Got(sleutel)) {
firsttime {
msg ("Dit is de slaapkamer van Maartje, je huisgenote. Ze vermoordt je levend als je hier naar binnen gaat. ")
LockExit (Maartjes kamer)
}
otherwise {
msg ("Deze deur zit op slot. ")
}
}
else {
msg ("Behoedzaam open je de deur en loop je de kamer van je huisgenote in.")
UnlockExit (Maartjes kamer)
MoveObject (player, tweede slaapkamer)
}

I also have created an object sleutel. But when the player first tries to enter this room (tweede slaapkamer) but does not have the key (sleutel) yet, and then when they try later when they have the key, the exit remains closed and the only message you get is 'Deze deur zit op slot'. However, when they already have the key they will succeed in unlocking the door. I really don't get what I'm doing wrong here.

I have used a locked door before, I looked up how I did it there but then I created a verb: 'open door with'. I assume this was a workaround.

I hope the situation is clear enough, if not, please tell me. Thanks in advance!

commented Aug 2 by jaynabonne (141 points)
"I have created a locked exit and the following script:"

*Where* have you created the script? When does it occur?
commented Aug 4 by Marleen (3 points)
I created it in the tabblad exit and then at the 'Run a script (instead of moving the player automatically)'.

I'll check if I don't have several keys with the same alias, and I will look at the script you have made, unfortunately I don't have the time to do it now but thanks in advance!
commented Aug 4 by jaynabonne (141 points)
Ok, knowing where you're using it helps. The problem is that the first time in, you lock the exit. From then on, every time you try to go out that exit, Quest just prints "The exit is locked" instead of running your script. (I hope you can forgive my lack of translation! :)You may have just happened to print out the same message Quest does. Try changing your "locked" message, and you should see that it's not your code running.

Since you're blocking the player yourself from going to the next room, you don't need to lock the exit at all. The player won't be able to go that way until your script lets them. So if you remove the LockExit and UnlockExit from your script, it should work fine.

1 Answer

0 votes
answered Aug 2 by jaynabonne (141 points)

I created the following parallel script and assigned it to command called "test":

   if (not Got(apple)) {
    firsttime {
      msg ("The apple looks good enough to eat.")
    }
    otherwise {
      msg ("You really want to take the apple.")
    }
  }
  else {
    msg ("The apple splits open, and a worm comes out.")
  }

and I get this output when run:

> test
The apple looks good enough to eat.

> test
You really want to take the apple.

> take apple
You pick it up.

> test
The apple splits open, and a worm comes out.

I'm not really sure where your script is being called, so I don't know if you have any odd side effects. Since you're moving the player to a room directly, I'm also not sure what the exit locking and unlocking is doing, but I'm sure you have a reason for it!

Random thing to check: be sure you don't have more than one "sleutel" (e.g. "sleutel" and "sleutel1", both with alias "sleutel" or something like that).

commented Aug 2 by TM123 (1 point)
I used your script called by a command "in" (matching the exit) and it worked as you want (I think).
I used your script called by "before entering the room" and it did not work correctly.
commented Aug 3 by jaynabonne (141 points)
I created another room to the east called "next" and added my script to the "before enter" for that room, and here's what I got:

You are in a room.
You can see an apple.
You can go east.

> go east
The apple looks good enough to eat.

You are in a next.
You can go west.

> go west

You are in a room.
You can see an apple.
You can go east.

> go east
You really want to take the apple.

You are in a next.
You can go west.

> go west

You are in a room.
You can see an apple.
You can go east.

> take apple
You pick it up.

> go east
The apple splits open, and a worm comes out.

You are in a next.
You can go west.

So it seems ok. If you had other results, could you explain a bit what "did not work correctly" means?

(I assume you're referring to my script, since you responded to me. If you meant to respond to the initial poster, then yeah, that script probably won't work in an "enter room" script since it will try to move the player while the player is being moved._That's not quite what the OP was complaining about though...)
This site is now closed.
As of 1st November 2015, this site is a read-only archive. For more information see the intfiction forum post

Welcome to IF Answers, a site for questions and answers about Interactive Fiction.

Technical questions about interactive fiction development tools such as Inform, Twine, Quest, QuestKit, Squiffy, Adrift, TADS etc. are all on-topic here.

Non-technical questions about interactive fiction are also on-topic. These questions could be about general IF design, specific games, entering the IF Comp etc.
...