Easy way to alter an object's displayverbs list


There are a few different ways to modify an object's displayverbs list.

If you haven't previously modified the list, you can't just use:

list add (object.displayverbs, "Frotz")

This is because this list is defined by an inherited type.

This means you didn't create the list. Quest added it to the object because it inherits a certain object type, and that type of comes equipped with that list of verbs by default.

Don't believe me? This is what Quest has to say:

Error running script: Cannot modify the contents of this list as it is defined by an inherited type. Clone it before attempting to modify.

You just need to copy the list first!

object.displayverbs = ListExclude(object.displayverbs, "")

Now the list has been cloned, and you are free to modify it!




just to add to KV's post, on the 'why' of it (well, the error message already explains it, lol, meh, oh well):

Inheritance is often protected (deals with constructors and etc programming/code stuff), so you have to over-ride/over-write the 'whatever (Functions, Attributes, Commands, Turnscripts, Verbs/Script_Attributes, etc)', in order to be able to alter it.

Just to add to the explanation, it is because the attribute is still on the type, and not on the object at all. You can confirm that by seeing that it is in grey on the Attributes tab. The way types work during play is that if Quest cannot find an attribute on the object itself, it will look for it on the types (and setting an attribute on your object to null will actually set it to the value on the type, where there is one).

One way to fix the issue is to add a new entry in the editor, and then remove it. This will make Quest copy the attribute to the object, and once the attribute is there, it will stay, even when you later set it to its original value..

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