A SpecialVerb allows us to define grammar for verbs applying to only a handful of objects in our game, where we want the rarely used command to be translated into a common one, e.g. RIMG BELL -> PUSH BELL, which we could implement as:
SpecialVerb 'ring' 'push' @doorbell
class
SpecialVerb : object
Superclass Tree (in declaration order)
SpecialVerb
object
Subclass Tree
(none)
Global Objects
(none)
Summary of Properties
during
matchObjs
priority
score
specVerb
stdVerb
verbPhrase
when
where
Summary of Methods
checkSV
customChecks
failCheck
initSpec
matches
objAfterChecks
objChecks
scopeCheck
showFailureMsg
Properties
A Scene or list of Scenes that must be happening for this SpecialVerb to apply.
The object ot objects we want this SpecialVerb to apply to. This can be a single object or class or list of objecta and/or classes, but it should result only in a small number of matches.
The priority we want to assign this SpecialVerb if the library needs to break a tie between two or more SpecialVerbs that might otherwise be matched after all other conditions have been applied. The default is 100. Other things being equal, the SpecialVerb with the higher/highest priority will be matched.
Our adjusted priority after attempting a match.
The word or words this SpecialVerb should match, e.g. 'ring'. Different forms can be listed separated by a vertical bar, e.g. 'cross|go across|walk across'
The verb words needed to trigger the action we want this SpecialVerb to perform, e.g. 'push' or 'go through'
The verb phrase that's been matched to invoke this SpecialVerb.
A condition that must be true for this SpecialVerb to apply. This cannot refer to the objects involved in the command (e.g. dobj or iobj) since these won't be known the first time the when condition is tested. For conditions involving the dobj, iobj, or aobj of a the current command, use objCheck() instead.
A Room, Region or list of Rooms and/or Regions where this SpecialVerb is applicable. Note we'd very rarely need to specficy this since SpecialVerb already makes scope checks.
Methods
This method is called once the command has been resolved and we kmow the objects involved in it. lst is a list containing the action followed by the objects involved in the action, e.g. [action, dobj]. svPhrase is the special verb phrase that's been translated into another action, e.g. 'ring' or 'walk across'
This method is called twice, first when the specialVerbMgr is seeking the best SpecialVerb option to match, and the second once the objects of the revised command have been identified and the command is about to be executed. The first time round the lst parameter won't be supplied (so will be effectively nil); the second time it will be a list containing the action and its objects. The customChecks() method uses this simply to determine at which stage its being invoked. The first time its being asked to adjust the match score; the second time its being asked to check whether or not the proposeed action should be allowed to proceed.
Display a messsage saying the command can't proceed and then stop it in its tracks. svPhrase is the command we matched, e.g. 'ring' or 'walk over'.
Initialise (in fact preinitialize) this SpecialVerb
Check whether this SpecialVerb matches its conditions.
Checks involving the objects of the commmand, once we know them
A check that can be applied once the objects involved in the command are known, (e.g. to check whether dobj.isOpen). The method can return nil to reject the command at this stage, or else display a message to explain why it can't go ahead and then use abort to stop it. It's unlikely that this will be needed often.
Check whether any of the items this SpecialVerb is meant to match is in scope.
Display our failure message. By default this is "You can't <<svPhrase>> that.
Adv3Lite Library Reference Manual
Generated on 02/05/2024 from adv3Lite version 2.0