Customize Verbs:Modifying Verbs
Modifying Verbs body text.
- patchVerb() lets an author replace only selected properties and methods of any predefined Verb.
- replaceVerb() lets an author completely replace any of the predefined Verbs.
- combineVerbs()
lets an author consolidate predefined Verbs. Some of
the predefined Verbs exist to catch subtle distinctions
that may not be necessary for your game. For instance,
twist
andturn
are predefined as distinct Verbs. If you don't need that level of distinction, you can use combineVerbs to consolidate them. - disableVerbs() lets an author delete specified Verbs from their game's Dictionary. Useful when you don't want to support certain Verbs.
- enableVerbs() lets an author re-enable Verbs that have been disabled.
- disableAllVerbsBut() lets an author disable all but specified Verbs. Useful for creating a game with limited language.
- createVerb() lets an author create a new Verb from scratch.
- doVerb() lets an author call a Verb from custom code during runtime.
- verb subscription on_success
- override_verb_success_msg - a simple method that overrides
- override_verb_failure_msg - simple but inflexible REPLACE WITH on_failure
Examples:
// patchVerb()
MyGame.patchVerb({
name: "go_out_from_under",
prettyname: "crawl out from under", // change prettyname
verb_prep_prep_noun: [ "out from under" ],
verb_prep_prep_prep_noun: [
"crawl out from under", // add new pattern
],
});
//replaceVerb()
MyGame.replaceVerb( "xyzzy", {
name: "xyzzy",
prettyname: "xyzzy",
synonyms: [],
verb_prep_noun: [],
verb_noun_prep_noun: [],
verb_noun_prep_noun_prep_noun: [],
do: function( params )
{
console.log( "verbs.do" );
var msg = "Clever xyzzy response!";
if(msg) this.game.print( msg, MyGame.input.output_class );
return params
},
});
// combineVerbs()
MyGame.combineVerbs( [ "twist" ], "turn" );
// disableVerbs()
MyGame.disableVerbs( [ "lick", "eat" ] );
// enableVerbs()
MyGame.enableVerbs( [ "lick", "eat" ] );
// disableAllVerbsBut()
MyGame.disableAllVerbsBut( [ "look", "examine" ] );
// createVerb()
MyGame.createVerb({
name: "blab_about",
prettyname: "blab about",
verb_prep_noun: [ "blab about" ], // blab about thing
verb_noun_prep_noun: [ "blab about" ], // blab person about thing
doTry: function( input )
{
[insert logic here]
return true;
},
doSuccess: function( input )
{
[insert logic here]
return true;
},
});
// doVerb() (call during runtime)
this.game.dictionary.doVerb("xyzzy");
Created by Ivan Cockrum on Sunday, May 29, 2022.
For more information, please send mail to webmaster@adventurejs.com.