SCRIPT-LABEL-EXAMPLE
The "gojs" and "label" Script options provide a mechanism for providing flow control in a Script. The "gojs" option is similar to the regular "js" option except that the return value of the script is used as a label name for the script to go to.
There are also four built-in labels:
start Restart the Script at the beginning. end End the Script. current Run the current step again. next Continue on to the next step in the Script.
For example:
> mb cleric script say 'heal' .
gojs return actor.hit < actor.maxHit ? "next" : "perfect";
speed 1d4+2
com say Ahhh ... healing you want?
label healing
js .
inRoom.amsg( '^n heals ^2n a little...', self, actor );
actor.hit = Math.min( actor.hit + Mud.dice( 8 ), actor.maxHit );
!
gojs .
if ( actor.hit < actor.maxHit ) {
talk( actor, "Ahh ... you be needin' some more healing!" );
return "healing";
} else
return "next";
!
c say Always a pleasure to heal up the wounded!
c smile ^2p
gojs return "end";
label perfect
c say But you're already in perfect health, ^2n!