So I finally got around to having a look at this and sorting it out and eventually got it working. Thanks for all the help.
@tbritton -
Altering the HandleMultiVerb function doesn't help in the case I was originally describing as that function is only called once object2 has been defined. I was more interested in cases where object2 can be defined but a script (rather than string) response can be made if it isn't. Your code did help me though, I was banging my head against the wall because I couldn't get quest to recognize the script dictionary until I realized I'd not used GetAttribute.
For anyone who is interested in achieving this, here is a quick recap of the problem and (my) solution.
Situation: You have a verb that requires another object. e.g. kill orc (using object2). Quest gets you to add all the objects you can use to "kill orc." The author can specify different outcomes for each: kill orc with sword, kill orc with axe, etc.
The problem: When the player types "kill orc" without specifying a second object, a list of available objects are displayed for the player to choose from. But there is no option to set a script of your own devising to run instead of the selection menu.
The Solution:- In the object tree select Advanced > Object Types, making sure that you have set the filter to view library elements.
- Highlight defaultverb and copy it in (the yellow bar that appears at the top of the screen).
- Select the "script" attribute, scroll down to the switch script and open the case for "scriptdictionary."
- Replace what is there with the following code:
if (object2 <> null) {
HandleMultiVerb (object, this.property, object2, this.multiobjectdefault)
}
else {
verbname = this.name
dictionary = GetAttribute(object,verbname)
if (DictionaryContains(dictionary,"default")) {
invoke (ScriptDictionaryItem(dictionary,"default"))
}
else {
menu = NewStringDictionary()
objectlist = ListCombine (ScopeReachableInventory(), ScopeReachableNotHeld())
excludelist = NewObjectList()
list add (excludelist, game.pov)
list add (excludelist, object)
candidates = ListExclude(RemoveSceneryObjects(objectlist), excludelist)
if (ListCount(candidates) = 0) {
msg (this.multiobjectmenuempty)
}
else {
GenerateMenuChoices (menu, candidates)
game.pov.multiverb = this.property
game.pov.multiverbobject = object
game.pov.multiverbobjectdefault = this.multiobjectdefault
ShowMenu (this.multiobjectmenu, menu, true) {
if (result <> null) {
HandleMultiVerb (game.pov.multiverbobject, game.pov.multiverb, GetObject(result), game.pov.multiverbobjectdefault)
game.pov.multiverb = null
game.pov.multiverbobject = null
game.pov.multiverbobjectdefault = null
}
}
}
}
}
Now the menu showing available objects will still show as before by default, but if you want to replace that with a script of your own devising, simply add a case called "default" in the relevant verb tab alongside the other objects that could be used.