Adding a new command
If the ARIFT standard library already contains the command (verb) that you want to use, then it is a simple matter to create a specific task to change the default behaviour for a specific object or if specific restrictions pass.
But what if we want to add a new command that is not in the standard library?
In this tutorial i will be creating a new "Rub Lamp" command that will summon a magic genie.
The General Task
But if we just do a "rub lamp" command, then the player will probably try to rub other objects and that will produce the message "Sorry, i didn't understand that command" which does not look very professional.
What we need to do is create a "rub %object%" command that will respond when the player tries to rub anything.
On the description page we change the name of the task, put in the appropriate command, and write the message to display on completion.
As the player might type "polish" instead of rub, and polishing the lamp should work the same way as rubbing it, we add this as an alternative command using advanced command constructon.
In the message box we write the default message that we want to be displayed if the player tries to rub something that they have no reason to be trying to rub.
The %CharacterName% function displays "I", "you" or the player's character's name, depending on the player perspective set in the options dialog.
Likewise  displays one of three alternatives depending on the player perspective. It adds the "s" after the word "rub" only when the game is set to third person in the options. The three different perspectives will print "I rub the lamp", "You rub the lamp", or "John rubs the lamp".
The %object%.Name function displays the full name of the object that the player is trying to rub.
Dont forget to ensure that the "Task is repeatable" checkbox is selected, or you won't be able to rub anything after the first time.
General task's also need to respond appropriately if the player tries to do something to an object that does not exist or is not currently at the same location as the player.
ADRIFT automatically adds appropriate restrictions when you select the "Restrictions" tab:
You will still need to check the text of each restriction. In this case the restriction message for the first restriction is "Sorry, I'm not sure which object you are trying to rub/polish." and you may wish to change it if you don't like this default message.
Note that we could also add a restriction that the object must be being held by the player, but i am going to allow them to rub it without having to pick it up first.
A specific object
To create the specific response for rubbing the brass lamp, we just need a specific task that is set to "Override" the "Rub object" general task:
When we select the "Rub object" task "rub object" will appear in the command-line box below it. To make this task specific to the "Brass lamp" object we click on "object" which displays a list of objects we can choose from. When "a brass lamp" is selected the command-line box will show "rub a brass lamp".
This task is now specific to the brass lamp. If the player enters "rub lamp" then they will see the message from this task. If they rub any other object then they will see the message from the general task.
This task does not need any restrictions because it only runs if all of the restrictions in the general task pass.
The only thing left to do is to switch to the "Actions" tab and add an action that moves the genie character to the players current location.
Making it even more specific
If you want rubbing the lamp to only produce a genie if the player is at a specific location, or has completed another task, or is carrying a particular object, then just add the appropriate restrictions to the specific task.
A specific group of objects
Although our default is now to say nothing happens if an object is rubbed or polished, many objects will actually become bright and shiny if you polish them.
The easiest way to do this is to create an object group for polishable objects, and add to it any objects that become shiny when rubbed.
This is a specific case of the general task that we created above, so create a specific task that overrides the rub object general task:
To make it specific to polishable objects we add a restriction to it so that it only overrides the general task when the referenced object is in the polishable group.
Now if the player rubs a polishable object they will get the message from this task, but if they rub any other object then they will get the default message from the general task.
- By leaving the restriction message blank we ensure that the message from the general task is shown if the restriction fails.
- Dont add the brass lamp to the polishable group - If you did want to do this then you would either have to change the "rub lamp" task so it overrides the "rub shiny object" specific task instead of the general task, or adjust the priority of the tasks to ensure that "rub lamp" had the highest priority.
- If you dont want the player to be able to polish the same object more than once, then add a Move-object action to this task: [Remove][Object][Referenced object][from group][Polishable]
- If you wanted to keep track of which objects have been polished (ie. to change their description with an alternate descripton, then add a "Polished" property to the objects and use a second action to set this property.
|<<< "How_do_I...?"||Main Page||Chopping through a locked door with an axe >>>|