Difference between revisions of "Executing sub-tasks"

From ADRIFT 5 Manual Wiki
Jump to: navigation, search
Line 44: Line 44:
  
 
No matter what you want to do, it is possible to do it in ADRIFT by using execute-task actions to run sub-tasks that contain extra restrictions, and can operate on the result of an item function instead of the original item references.
 
No matter what you want to do, it is possible to do it in ADRIFT by using execute-task actions to run sub-tasks that contain extra restrictions, and can operate on the result of an item function instead of the original item references.
 +
 +
[[File:ExecuteClimbObject.jpg]]
 +
 +
This action can execute any task, general, specific or system. If you are creating a new task to use as a sub-task then you should create a system task if you don't need to pass parameters to it, or a general task if you do.
 +
 +
== Executing a system task to print text ==
 +
There are several reasons to create a system task that only displays text, and execute it with an action.
 +
#. It allows you to keep one copy of a large block of text that you want to display in several tasks.
 +
#. You may need to display some text before executing actions, and some after.
 +
#. You may have a complex arrangement of alternate restrictions that you don't want to duplicate every time you need it.
 +
 +
[[File:TaskSystem.jpg]]
 +
 +
This system task
 +
 +
== Executing a system task to add conditional actions ==
 +
 +
 +
== Executing a general task for advanced processing ==
 +
 +
[[File:TaskGeneralSub.jpg]]
 +
 +
Note the use of the # symbol at the start of the command line. This tells ADRIFT that this task does not contain a command and should be ignored by the command parser.
 +
 +
After the #, you can add any combination of [[General tasks#References|references]] (%object1% to %object5%, %objects%, %character1% to %character5%, %characters%, %direction%, %number%, %text% and %location%)
 +
 +
These references can then be used in the usual manner in the [[restrictions]] and [[actions]] of the task.
 +
 +
When you now execute this task from an action in another task, you will be presented with a series of parameter entry dialogs, one for each reference that you defined:
 +
 +
[[File:ActionTaskParameter.jpg]]
 +
 +
In the simplest case you might pass on the references of the main task to the sub-task so it can use them, but you are also able to use the full power of the [[general functions|general]] and [[item functions]] to generate whatever reference you need.
 +
 +
== Using a group to execute a sub-task multiple times ==
 +
If you pass the key of a character, object or location group as a parameter, or use an item function to access the group of objects on or in another object, or worn/held by a character, then the sub-task will be executed for each item in the group.
 +
  
  
 
<TABLE ALIGN=CENTER BORDER=1 WIDTH="50%"><TD WIDTH="33%" ALIGN=CENTER>[[General tasks|<<< General tasks]]</TD><TD WIDTH="34%" ALIGN=CENTER>[[Main_Page#The_Main_Items|Main_Page]]</TD><TD ALIGN=CENTER>[[How tasks work|How tasks work >>>]]</TD></TABLE>
 
<TABLE ALIGN=CENTER BORDER=1 WIDTH="50%"><TD WIDTH="33%" ALIGN=CENTER>[[General tasks|<<< General tasks]]</TD><TD WIDTH="34%" ALIGN=CENTER>[[Main_Page#The_Main_Items|Main_Page]]</TD><TD ALIGN=CENTER>[[How tasks work|How tasks work >>>]]</TD></TABLE>

Revision as of 07:06, 31 January 2014

THE MAIN ITEMS
Locations
Objects
Tasks
---- Specific
---- General
---- System
---- Executing sub-tasks
---- How tasks work
Characters
Events
Variables
Groups
Properties
Text Overrides
Hints
Synonyms
User functions

A single ADRIFT task checks its restrictions and if they pass it performs its actions and displays its text.

Basically it is a single IF <restrictions> THEN <perform actions and display text> ELSE <display first failing restriction message> statement.

In most cases this is all you need, but what if you want to output text both before and after the actions, or if you want to perform an action that is more complex than the one's provided by ADRIFT.

No matter what you want to do, it is possible to do it in ADRIFT by using execute-task actions to run sub-tasks that contain extra restrictions, and can operate on the result of an item function instead of the original item references.

ExecuteClimbObject.jpg

This action can execute any task, general, specific or system. If you are creating a new task to use as a sub-task then you should create a system task if you don't need to pass parameters to it, or a general task if you do.

Executing a system task to print text

There are several reasons to create a system task that only displays text, and execute it with an action.

  1. . It allows you to keep one copy of a large block of text that you want to display in several tasks.
  2. . You may need to display some text before executing actions, and some after.
  3. . You may have a complex arrangement of alternate restrictions that you don't want to duplicate every time you need it.

TaskSystem.jpg

This system task

Executing a system task to add conditional actions

Executing a general task for advanced processing

TaskGeneralSub.jpg

Note the use of the # symbol at the start of the command line. This tells ADRIFT that this task does not contain a command and should be ignored by the command parser.

After the #, you can add any combination of references (%object1% to %object5%, %objects%, %character1% to %character5%, %characters%, %direction%, %number%, %text% and %location%)

These references can then be used in the usual manner in the restrictions and actions of the task.

When you now execute this task from an action in another task, you will be presented with a series of parameter entry dialogs, one for each reference that you defined:

ActionTaskParameter.jpg

In the simplest case you might pass on the references of the main task to the sub-task so it can use them, but you are also able to use the full power of the general and item functions to generate whatever reference you need.

Using a group to execute a sub-task multiple times

If you pass the key of a character, object or location group as a parameter, or use an item function to access the group of objects on or in another object, or worn/held by a character, then the sub-task will be executed for each item in the group.


<<< General tasksMain_PageHow tasks work >>>