Need to find out how to open exit once a number of different items have been eaten

Hi, I'm working on a game where the player needs to eat a number of different items in order to unlock a door. I've tried a few different methods, but so far have had no luck. Any help would be appreciated. Not sure how to proceed.


The easiest way to do it is probably to put a script on the exit, and only let the player through if they have eaten the items.

If you're using the default "edible" verb for the objects, it will destroy them when eaten; so you can check for their existence.
You can give the exit a script that runs when the player attempts to use it, and make it something like:

if (GetObject("apple") = null and GetObject("cheese") = null and GetObject("potion") = null) {
  game.pov.parent = this.to
}
else {
  msg ("The door seems to be locked")
}

(Generally, you don't actually use the "locked" feature of exits unless you want to lock them the standard way using keys)

In case you need explanation:

  • The expression GetObject("some name") = null is true if there is no object of that name; which will be true if it's been eaten.
  • game.pov.parent = this.to in an exit script moves the player through the exit

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

Support

Forums