Trying to change object verbs with a script.

I’m trying to write a script so that a chair will not let the player sit on it after they are already sitting. Same thing if they are standing.


I'm assuming your chair has a "sit on" verb?

Have a flag or attribute to indicate if the player is sitting down.

The verb would look something like:

if (GetBoolean (player, "sitting")) {
  msg ("You're already sitting down.")
}
else {
  msg ("You sit in the chair.")
  player.sitting = true
}

Thanks, that’s exactly what I was looking for. :D


You can also dynamically add and remove verbs to an object's verbs that it shows when you click on it by using

list remove (this.displayverbs, "sit on")
list add(this.displayverbs, "sit on")

I use this for a flashlight object in my game. If you click on it in the inventory pane and select "turn on", I remove "turn on" from the inventory verbs, add "turn off", and change its "isOn" variable to true.


I tried to suggest that too, but kept getting "You can't post that here" errors.

Note that if all of an object's displayverbs come from its types, you will have to do this.displayverbs = this.displayverbs before you can add or remove them. And if you have it set to auto-generate displayverbs, any actual verbs will be stored in the list this.generatedverbslist which is created the first time it becomes visible to the player.


Log in to post a reply.

Support

Forums