Denizen/0.7/Interact Scripts: Difference between revisions

From Citizens Wiki

< Denizen‎ | 0.7

No edit summary
Line 5: Line 5:
Scripts are defined in the plugins/Denizen/scripts/ folder. Any .yml file in that directory will be loaded into Denizen. For example purposes on this website, reference to script.yml is made, but again, jimbobjoe.yml or 'skeeter the cat.yml' would work just the same..
Scripts are defined in the plugins/Denizen/scripts/ folder. Any .yml file in that directory will be loaded into Denizen. For example purposes on this website, reference to script.yml is made, but again, jimbobjoe.yml or 'skeeter the cat.yml' would work just the same..
</div>
</div>


==== General layout of an Interact Script ====
==== General layout of an Interact Script ====
Line 22: Line 23:
</pre>
</pre>
</div>
</div>


==== Name Node ====
==== Name Node ====
Line 30: Line 32:
* If the name includes a single quote in it, you must use double quotes around it, or 'escape' the quote with another quote. ie: <code>"John's Script":</code> or <code>'John<nowiki>''</nowiki>s Script':</code>
* If the name includes a single quote in it, you must use double quotes around it, or 'escape' the quote with another quote. ie: <code>"John's Script":</code> or <code>'John<nowiki>''</nowiki>s Script':</code>
</div>
</div>


==== Type Node ====
==== Type Node ====
Line 51: Line 54:
This would be a difficult script to obtain, for sure. To trigger, the time must be night-time, the player would need one million units of currency, and the weather must be storming, but it shows the flexibility of requirements. First is the 'Mode'. Currently there are three different types. Second is the requirement type, with arguments if applicable.
This would be a difficult script to obtain, for sure. To trigger, the time must be night-time, the player would need one million units of currency, and the weather must be storming, but it shows the flexibility of requirements. First is the 'Mode'. Currently there are three different types. Second is the requirement type, with arguments if applicable.
</code>
</code>


===== Requirements Mode =====
===== Requirements Mode =====
Line 69: Line 73:
}}
}}
</div>
</div>


===== Requirements =====
===== Requirements =====
Line 79: Line 84:


</div>
</div>


==== Steps Node ====
==== Steps Node ====
Line 137: Line 143:
</div>
</div>


====Trigger Nodes====
<div style="margin-right:2.0em; padding:10px; font-family:museo-sans; font-size:110%;">
Steps handle the flow of commands and messages with triggers.
'''Denizen Triggers''' trigger from interaction with Denizens. They are defined in the Steps: node.


* '''Click Trigger'''s activate when the Denizen is right-clicked.
== Scripts need Triggers ==
<pre>
Click Trigger:
  Script:
  - CHAT "Teehee, that tickles!"
  - EMOTE "giggles"
</pre>


* '''Damage Trigger'''s activate when the Denizen is left-clicked. If the Denizen has Damage Triggers disabled, this will count as a Click Trigger.
Interact Scripts
<pre>
Damage Trigger:
  Script:
  - CHAT "OUCH, You'll pay for that!"
  - STRIKE <PLAYER>
</pre>


* '''Proximity Trigger'''s activate when a player walks close to the Denizen.


<pre>
Proximity Trigger:
  Script:
  - CHAT 'Eek! get away, you smell bad, <PLAYER>.'
</pre>
* '''Chat Trigger'''s activate when players chat with Denizens. Players' chat within the configurable range will be directed to the Denizen instead of global chat. Chat also follows the configuration setting. a single chat trigger entry can handle multiple words, see below:
<pre>
Chat Trigger:
  '1':
    Trigger: The word needed to /Trigger/ is inside slashes, this whole sentence will appear to be said by the player
    Script:
    - CHAT "Good to know!"
  '2':
    Trigger: A chat trigger can also catch on any word not otherwise caught using /*/.
    Script:
    - CHAT "I don't know what <*> mean, <PLAYER>!"
</pre>
* '''Location Trigger'''s activate when players walk near a [[Location Bookmark]]. Like chat triggers, multiple locations can be defined in one Location Trigger. They are similar in format to Chat Triggers in the fact that there can be multiple triggers per step.
<pre>
Location Trigger:
  '1':
    Trigger: TreasureRoom
    - TELEPORT BOOKMARK:Jail
  '2':
    Trigger: BedRoom
    - NARRATE 'You enter the bedroom of the dead man, looking for clues'
</pre>


For a full list of commands, see [[#Script Commands]]
</div>
</div>

Revision as of 18:15, 14 August 2012

Interact Scripts

Hopefully you've gotten a basic idea of a script by reading about Assignments in the previous section. If you have, you'll notice that the general structure of a script should always include the 'Name', 'Type', 'Requirements', and 'Steps' nodes.

Scripts are defined in the plugins/Denizen/scripts/ folder. Any .yml file in that directory will be loaded into Denizen. For example purposes on this website, reference to script.yml is made, but again, jimbobjoe.yml or 'skeeter the cat.yml' would work just the same..


General layout of an Interact Script

'Name of script':   # Name Node
  Type: Interact    # Type Node
  Requirements:     # Requirements Node
    ...:
    ...:
      - ...
      - ...
  Steps:            # Steps Node
    ...:
      - ...
    ...:


Name Node

This node is pretty self-explanatory, but here are some things to keep in mind.

  • Names, just like nodes are case-sensitive! 'This script name' is different than 'THIS SCRIPT NAME'.
  • Names that contain spaces should have single or double quotes around it. ie: "This script": or 'This script': is acceptable.
  • If the name includes a single quote in it, you must use double quotes around it, or 'escape' the quote with another quote. ie: "John's Script": or 'John''s Script':


Type Node

Let's Denizen know the type of script. For interact scripts, as explained in this section, use TYPE: INTERACT. For reference, there are also TASK scripts and ACTIVITY scripts, which is covered later.

Requirements Node

This node sets the rules for the player to qualify for the script. There are a couple different options that you should know when using requirements. For example:

 Requirements:
   Mode: All
   List:
   - TIME Night
   - MONEY 1000000
   - STORMY

This would be a difficult script to obtain, for sure. To trigger, the time must be night-time, the player would need one million units of currency, and the weather must be storming, but it shows the flexibility of requirements. First is the 'Mode'. Currently there are three different types. Second is the requirement type, with arguments if applicable.


Requirements Mode

[] indicates required field.

ALL

  Requires all requirements listed to be met.

ANY [#]

  Requires the specified number of requirements to be met out of the total of requirements.

NONE

  No requirements need to be met. There is also no need to have a LIST node if using NONE.


Requirements

Denizen has a large assortment of Requirements at your disposal. For a complete list, and information on those requirements, see: Denizen/Interact Scripts/Interact Requirements

Remember, requirements are also easily extensible by plugin programmers, or maybe even you!
See: Denizen/Interact Scripts/Custom Interact Requirements


Steps Node

Steps are the meat of the script. They control what to listen for and what actions to take. Each script can have multiple steps, each with multiple triggers. Let's use an example.

'Welcome to Harbortown':
  Type: Interact
  Requirements:
    Mode: NONE
  Steps:
    '1':
      Click Trigger:
        Script:
        - CHAT 'What's your name, stranger?'
      Chat Trigger:
        '1':
          Trigger: My name is /<PLAYER>/.
          Script:
          - CHAT 'Ah ha, your name sounds familiar! '
          - CHAT 'Are you from around this area?'
          - ZAP
    '2':
      Click Trigger:
        Script:
        - HINT
      Chat Trigger:
        '1':
          Trigger: /Yes/, I grew up in Harbortown!
          Script:
          - CHAT 'I thought so, welcome back! 
            Have you heard about Tom the Taylor? 
            Isn't that just horrible?'
          - ZAP 3 
        '2':
          Trigger: /No/, you must be mistaken. 
          Script:
          - CHAT 'Oh, sorry about that.' 
          - CHAT 'Hey, if you're looking for some work, 
            Bill the Baker is understaffed! 
            This is the bakery's busy season.'
          - ZAP 4
    '3':
      Click Trigger:
        Script:
        - CHAT 'I wonder if Tom the Taylor is doing any better.'
        - NARRATE 'Perhaps you should check on Tom the Taylor.'
    '4':
      Click Trigger:
        Script:
        - CHAT 'Oh, nice to see you again <PLAYER>!'
        - CHAT 'Have you stopped by the bakery?'

For a full list of Interact Script Commands, see Denizen/Interact_Scripts/Commands


Scripts need Triggers

Interact Scripts