world_setup:game_features:tasks
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
world_setup:game_features:tasks [2023/07/12 15:04] – [PlayerTaskStartSetTime( Seconds )] mit | world_setup:game_features:tasks [2023/07/12 16:08] (current) – [Example task process] mit | ||
---|---|---|---|
Line 9: | Line 9: | ||
===== Example task process ===== | ===== Example task process ===== | ||
To implement the tree ' | To implement the tree ' | ||
- | * Unordered List ItemUsing | + | * Using the building editor, create the building as a ' |
* Implement the building access script as shown: | * Implement the building access script as shown: | ||
< | < | ||
Line 36: | Line 36: | ||
</ | </ | ||
(Then if you wanted to get real //fancy//, you could also use the *changebuilding command to change the tree building to one set up with a tree stump graphic - then perhaps use a ProductionRun event to turn the stump back into a tree building after its had time to regrow. That kinda thing, ya know..) | (Then if you wanted to get real //fancy//, you could also use the *changebuilding command to change the tree building to one set up with a tree stump graphic - then perhaps use a ProductionRun event to turn the stump back into a tree building after its had time to regrow. That kinda thing, ya know..) | ||
+ | |||
+ | ===== Task Codes or Callbacks ===== | ||
+ | |||
+ | In the various task commands listed below, there are two ways of using the functions, either by using a TaskCode - which is an integer value, or a Callback - which is a text string. | ||
+ | |||
+ | The resulting script events triggered are slightly different depending on whether you're providing a TaskCode number or a Callback string. | ||
===== Task commands ===== | ===== Task commands ===== | ||
==== *dotask ==== | ==== *dotask ==== | ||
- | ^ Format | *dotask [PLAYER_NAME] [TASK_CODE] [TEXT] | | + | ^ Format | *dotask [PLAYER_NAME] [TASK_CODE/CALLBACK] [TEXT] | |
^ Description | Activates the task display for the specified player. | ^ Description | Activates the task display for the specified player. | ||
+ | ^ Example | '' | ||
Using '' | Using '' | ||
- | '' | + | '' |
then | then | ||
- | '' | + | '' |
\\ | \\ | ||
- | (The two events are used because in some circumstances you'd want to react to a specific task_code, and sometimes you just want to do something whenever any *dotask event starts). | + | (The two events are used because in some circumstances you'd want to react to a specific task_code, and sometimes you just want to do something whenever any *dotask event starts. Note that when using a ' |
In either of those events you can use the script command | In either of those events you can use the script command | ||
Line 54: | Line 61: | ||
When the task completes (and assuming the player does not cancel or interrupt it) two further events are triggered: | When the task completes (and assuming the player does not cancel or interrupt it) two further events are triggered: | ||
- | '' | + | '' |
then | then | ||
- | '' | + | '' |
\\ | \\ | ||
[[Scripting: | [[Scripting: | ||
==== *dotaskparam ==== | ==== *dotaskparam ==== | ||
+ | ^ Format | *dotaskparam [PLAYER_NAME] [TASK_CODE/ | ||
+ | ^ Description | Activates the task display for the specified player, with parameters that can be access via script. | ||
+ | ^ Example | '' | ||
+ | |||
+ | '' | ||
+ | |||
+ | e.g. : | ||
+ | < | ||
+ | *dotaskparam %PLAYER% MyTask 100 150 Performing task | ||
+ | |||
+ | Event( " | ||
+ | { | ||
+ | $var1 = $gParam[1] | ||
+ | $var2 = $gParam[2] | ||
+ | |||
+ | *say Parameters were $var1 and $var2 | ||
+ | } | ||
+ | </ | ||
+ | would print '' | ||
+ | |||
==== *dobuildingtask ==== | ==== *dobuildingtask ==== | ||
- | '' | + | ^ Format | *dobuildingtask [PLAYER_NAME] [BUILDING_ID] [TASKCODE/CALLBACK] [DISPLAY_TEXT] | |
+ | ^ Description | Activates the task display for the specified player in relation to the specified building. | ||
+ | ^ Example | '' | ||
==== *dobuildingtaskparam ==== | ==== *dobuildingtaskparam ==== | ||
+ | ^ Format | *dobuildingtask [PLAYER_NAME] [BUILDING_ID] [TASKCODE/ | ||
+ | ^ Description | Activates the task display for the specified player in relation to the specified building. | ||
+ | ^ Example | '' | ||
- | ==== *docombitask ==== | + | As with the *dotask equivalents, |
==== *showtask ==== | ==== *showtask ==== | ||
+ | ^ Format | *showtask [PLAYER_NAME] | | ||
+ | ^ Description | This is a sysop/debug command that tells you the current state of the task for the specified player | ||
===== Task scripting ===== | ===== Task scripting ===== | ||
Line 75: | Line 109: | ||
==== PlayerTaskStartSetTime( Seconds ) ==== | ==== PlayerTaskStartSetTime( Seconds ) ==== | ||
- | $gTaskItem1, | + | Call this function from one of the TaskStart events to set the number of seconds that the task will last for. \\ |
+ | These script System Values provide the item numbers that were used in the '' | ||
- | Event( " | + | ***dobuildingtask** and ***dobuildingtaskparam** trigger: |
- | Event( "BuildingTaskComplete", | + | '' |
- | Event( | + | '' |
- | Event( "CustomTaskComplete", | + | |
- | Event( | + | |
- | Event( " | + | |
+ | ***dotask** and ***dotaskparam** trigger: \\ | ||
+ | '' | ||
+ | '' | ||
TaskStart and TaskComplete events are triggered on all types of task (i.e. from all of the *do.. commands). | TaskStart and TaskComplete events are triggered on all types of task (i.e. from all of the *do.. commands). | ||
Line 91: | Line 126: | ||
'' | '' | ||
- | Where TASK_TYPE is | + | When a numeric TaskCode is used in the task command, the event is triggered with a TASK_TYPE, where TASK_TYPE is:\\ |
- | 0 : Combination Tasks (Tasks triggered with *docombitask and no text callback field) | + | **0** : Combination Tasks (Tasks triggered with *docombitask and no text callback field)\\ |
- | 1 : Standard/ | + | **1** : Standard/ |
- | 2 : Building Tasks (Tasks triggered with *dobuildingtask and no text callback field) | + | **2** : Building Tasks (Tasks triggered with *dobuildingtask and no text callback field)\\ |
+ | \\ | ||
If you specify a callback name in the task command, this is used in the event instead. | If you specify a callback name in the task command, this is used in the event instead. | ||
e.g. | e.g. | ||
- | '' | + | '' |
would trigger\\ | would trigger\\ | ||
- | '' | + | '' |
+ | and **not** \\ | ||
+ | '' | ||
+ | |||
+ | |||
+ | ==== Combination tasks ==== | ||
+ | |||
+ | You probably don't need to use combination tasks unless you're doing something very funky. (They were used on some early worlds to build a complex, but probably rather daft, crafting system which used the combination of items to generate a single code that could be looked up to find the resulting item - e.g. combining items 12, 39 and 41 would generate a code 12039041 and there' | ||
+ | |||
+ | Anyway.. for reference: | ||
+ | |||
+ | ==== *docombitask ==== | ||
+ | ^ Format | *docombitask [PLAYER_NAME] [ITEM1] [ITEM2] [ITEM3] | | ||
+ | ^ Description | Activates the task display for the specified player with relation to the specified item numbers | | ||
+ | ^ Example | '' | ||
+ | |||
+ | |||
+ | Combi tasks also make use of the system values : \\ | ||
+ | **$gTaskItem1**, | ||
+ | which correspond to the three values used in the combitask command | ||
+ | ***docombitask** and ***docombitaskparam** trigger: \\ | ||
+ | '' | ||
+ | '' | ||
world_setup/game_features/tasks.1689192255.txt.gz · Last modified: 2023/07/12 15:04 by mit