Difference between revisions of "Adding a new command"

From ADRIFT 5 Manual Wiki
Jump to: navigation, search
m (typo)
m (consistancy)
Line 45: Line 45:
 
[[File:TaskSpecificObject.jpg]]
 
[[File:TaskSpecificObject.jpg]]
  
When we select the "Rub object" task "rub <font color="blue"><u>object</u></font>" 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 <font color="blue"><u>a brass lamp</u></font>".
+
When we select the "Rub object" task "rub <font color="blue"><u>object</u></font>" will appear in the command-line box below it. To make this task specific to the "Brass lamp" object we click on "<font color="blue"><u>object</u></font>" which displays a list of objects we can choose from. When "a brass lamp" is selected the command-line box will show "rub <font color="blue"><u>a brass lamp</u></font>".
  
 
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 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.

Revision as of 09:13, 26 August 2012

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

There is no "Rub" command in the standard library, so the first thing we need to do is create a new general task to define it.

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.

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.

This can involve writing several restrictions, however if the standard library contains a command that operates in a similar way to the one you want to create then you can right-click on it's task and select copy, then go to your own folder and right-click to paste in a copy of the task which you can then edit.

Here are the restrictions copied from the "Pull object" task:

TaskRestrictionsPull.jpg

You will still need to check the text of each restriction, in this case we need to change the word "pull" to "rub" in the first two restrictions.

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.

On the description page we change the name of the task, put in the appropriate command, and write the message to display on completion.

TaskGeneralRub.jpg

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. It is a good idea to have a thesaurus on hand so you can check for any similar verbs that you may want to add to your new task.

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 players characters name depending on the player perspective set in the options dialog.

Likewise [1] displays one of three alternatives depending on the player perspective.

The %TheObject[%object%]% 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.

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:

TaskSpecificObject.jpg

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.

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 task:

TaskSpecificGroup.jpg

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.

RestrictionInGroup.jpg

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.

  • 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.