Denizen/0.7/Task Scripts: Difference between revisions

From Citizens Wiki

< Denizen‎ | 0.7

No edit summary
Line 1: Line 1:
== Task Scripts in detail ==
<div style="margin-right:2.0em; padding:10px; font-family:museo-sans; font-size:110%;">
<div style="margin-right:2.0em; padding:10px; font-family:museo-sans; font-size:110%;">
Task scripts are just a simple list of [[Denizen/Interact_Scripts/Commands|Script Commands]]. They can be called by the RUNTASK command, the IF command, or the TASK activity. They are useful for creating a set of commands that is used in multiple places.
Task scripts are just a simple list of [[Denizen/Interact_Scripts/Commands|Script Commands]]. They can be called by the RUNTASK command, the IF command, or the TASK activity. They are useful for creating a set of commands that is used in multiple places.

Revision as of 20:57, 10 October 2012

Task scripts are just a simple list of Script Commands. They can be called by the RUNTASK command, the IF command, or the TASK activity. They are useful for creating a set of commands that is used in multiple places.

General layout

'Name of script':  
  Type: Task    
  Script:        
  - COMMAND1
  - COMMAND2
  - etc...

Using the RUNTASK command

Imagine a scenario where you'd like to check a single outcome from multiple sources. Say, for instance, you have multiple 'quests' that all have the same outcome. You could check the completion for each quest, or, you could have all the quests call a Task Script and check against that.

This is a very basic example for something that can in theory be very complex. Imagination, hoooo!

'Apple Reward': 
  Type: Task    
  Script:       
  - NARRATE "You've received some APPLES. Nice!"
  - GIVE APPLE QTY:10
  - FINISH

'Apple Quest 1':
  Type: Interact
  Requirements:
    Mode: All
    List:
    - -FINISHED Apple Reward
  Steps:
    '1':
      Click Trigger:
        Script:
        - CHAT "Welcome to my house, have some apples!"
        - RUNTASK Apple Reward
  
'Apple Quest 2':
  Type: Interact
  Requirements:
    Mode: All
    List:
    - -FINISHED Apple Reward
  Steps:
    '1':
      Click Trigger:
        Script:
        - CHAT "Welcome to my orchard, have some apples!"
        - RUNTASK Apple Reward

Using the TASK Activity

This is a special case, as Activities occur without a player. Therefor any commands that require a Player will not function in a Task Script called from the activity. Many script commands have a DENIZEN modifier to run the command on the NPC instead of the Player, and these should always be used when calling a Task Script from the TASK Activity.

'WalkHome': 
  Type: Task    
  Script:       
  - CHAT NOPLAYER "Welp.. time to head home!"
  - WALKTO BOOKMARK:Home

'GoHomeActivity':
  Type: Activity
  Requirements:
    Mode: None
  Activities:
    List:
    - 1 TASK SCRIPT:WalkHome REPEATS:0