How to hide in a cupboard. (tutorial)

Hey.
You probably want to make it so a player can enter a cupboard.

Weirdly specific, but you're in luck.
Today I will be teaching you how to enter a cupboard in a detailed manner.

Step 1:
Go into the Object tab in the cupboard object, and enable "Is a room".
Step 2:
Make a verb for the cupboard called "get into"
Step 3:
In the script editor, place:
MoveObject (player, cupboard)
Step 4:
Test.
Your player character should be able to use the cupboard verb "Get Into" to enter a cupboard.
Step 5:
make a command called "get out"
Step 6:
put this in it:

if (game.pov.parent = cupboard) {
MoveObject (player, cupboard.parent)
}
else {
msg ("What are you getting out of?")
}
Step 7:
Test the game. If you're not in the cupboard and use the get out command, it will say
"What are you getting out of?"
Then get in the cupboard.
Now when you do the command, you leave the cupboard.

Congratulations.
You can now enter a cupboard.


I think this is in the wrong forum; you seem to be using Quest, not Quest 6.

Seems a decent way to do it. Although when I did a game with a "get out" or "leave" command, I used alternate command scopes to put the object you're inside into scope (so that "look cupboard" is an alias for "look" when you're inside it; and "leave cupboard" behaves intuitively as an alias for the simple "leave").

I would suggest that if you're doing it that way, the leave command could be changed to:

if (HasScript (game.pov.parent, "leave")) {
  do (game.pov.parent, "leave")
}
else if (HasScript (game.pov.parent, "getinto")) {
  MoveObject (game.pov, game.pov.parent.parent)
}
else {
  msg ("What are you getting out of?")
}

That way, it will work for any object that has a "get into" verb, without needing to change the get out command if you want to add another one. And in this case, you can give an object a "leave" script attribute if you want to stop them climbing out of it so easily.


This topic is now closed. Topics are closed after 14 days of inactivity.

Support

Forums