Tutorial > Advanced Techniques > Overriding system commands
 
Chapter 3.5 - Overriding system commands

The vast majority of all the system commands (ie, commands that ADRIFT understands without having to define tasks for, such as getting and dropping objects) can all be overridden with your own tasks.  This is very useful to allow you to customise the adventure, and do more advanced things.

One example where this is useful is if you have a fragile object, such as a vase.  If you type "drop vase", then the default system command moves the object to the current room the player is in.  You may want to make the object break if the player tries to drop it, so you would define a task such as "drop *vase", then give the reply "You drop the fragile vase, but it smashes on impact with the ground.", then move the object to hidden.

The difficulty with overriding the system commands is to cover all possible ways that it can be phrased.  In the example above, if that was the only definition in the task, then if the player typed "put vase down" would still move the vase to the current room instead of running the task.

Here are some tips for overriding the get/take and drop commands;

For taking an object, define the following tasks;

*get *<object>*    *take *<object>*    *pick *<object>*

For putting the object down, define;

*drop *<object>*    *put *<object>*    *leave *<object>*

It's important to define the "get" task rather than just "take", so that if the player types "get/take all", the task will still execute, as ADRIFT internally creates the command "get <object>" for each object when getting all.

It is also important to note that only a successful task will override the system command.  If all the conditions on the task are not met, then the default system response will be displayed.  If you require to display a different message when the task is executed and all the conditions haven't been met, you will have to add another task without the restrictions.

Strictly speaking, in the above examples, you for each verb, you should have two separate commands, ie;

get *<object>*    and    * get *<object>*

The reason for this, is to only allow sentences beginning with "get", or sentences with the complete word "get".  The examples above would for example, accept "forget <object>", which you wouldn't really want.
 


Back to top