How do I hide an object verb

I have an object with an action verb such as "Wait", this been is one that I only want to be available/visible when certain conditions are met but I don't know how this might be done as it doesn't have an attribute. Is there a way to remove/add verbs to an object via a script when I enter the room the object is within?


What verbs are displayed in an object's menu is determined by a couple of attributes. They are all lists:

  • inventoryverbs - if the object is held
  • displayverbs - if the object is not held
  • generatedverbslist - a list of verbs (from the object's "Verbs" tab), created automatically the first time the player sees it

On the object's "Object" tab, you can tick the box "Disable automatically generated display verb list for this object" to hide the generatedverbslist verbs; or "Only display verbs from this object's Verbs tab" to disable displayverbs/inventoryverbs.

So you can disable the automatically generated verbs list, and then manually add/remove verbs from the displayverbs attribute when you want to show or hide them. Or you could hide a verb by removing it from the automatic list, as long as you wait until the list has been generated first.

This only affects what is displayed in the menu/buttons. You probably want your verb to check if it's valid in case the player types it anyway.

If you want to actually remove a verb from an object, each verb has a script attribute which normally has the same name as the verb. Removing this removes the verb; but won't change the verbs menu if generatedverbslist has already been generated.


So if I've ticked the "Disable automatically generated display verb list for this object" flag what script do I have to run to manually add a verb to the object's verb list?


If you have edited the displayverbs list in the editor, you can do something like:

list add (object.displayverbs, "verb")

(where object is the name of the object, and verb is the verb you want to add)

You can similarly remove items by using list remove.

If you haven't edited displayverbs in the editor, it will be a special list which composes a list based on all the types that object has. You can't add items to a magic list, so you first need to convert it to a normal list by doing:

object.displayverbs = object.displayverbs

before the first time you modify it.


Excellent, that's this problem solved as well, thank you as always.


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

Support

Forums