Denizen/0.7/Interact Scripts: Difference between revisions

From Citizens Wiki

< Denizen‎ | 0.7

(Created page with "== Interact Scripts == <div style="margin-right:2.0em; padding:10px; font-family:museo-sans; font-size:110%;"> Hopefully you've gotten a basic idea of a script by reading abou...")
 
Line 53: Line 53:
</div>
</div>


===== Requirements Mode =====
See: [[Interact Requirements]]
<div style="margin-right:2.0em; padding:10px; font-family:museo-sans; font-size:110%;">
<code>[] indicates required field.</code>
 
{{Denizen Requiremnt Type Color |white|
ALL
| &nbsp;&nbsp;Requires all requirements listed to be met.
}}
{{Denizen Requiremnt Type Color |white|
ANY [#]
| &nbsp;&nbsp;Requires the specified number of requirements to be met out of the total of requirements.
}}
{{Denizen Requiremnt Type Color |white|
NONE
| &nbsp;&nbsp;No requirements need to be met. There is also no need to have a <tt>LIST</tt> node if using <tt>NONE</tt>.
}}
</div>
 
===== Requirements =====
<div style="margin-right:2.0em; padding:10px; font-family:museo-sans; font-size:110%;">
Note: Requirements are due for a re-code to make them extensible like Commands. This will improve tolerence and allow for better debugging, as well as make it easy for other plugin programmers to extend Denizen. What this means to you is that it will probably change up some syntax formatting in future updates.
 
<code>[] indicates required field, () indicates an optional field, | indicates alternative usage.</code>
 
Click on any requirement to get more information and example usages.
</div>
 
''' Player Requirements '''
<div style="margin-right:2.0em; padding:10px; font-family:museo-sans; font-size:110%;">
{{Denizen Requiremnt Type Color|ivory|
[[Interact_Script_Requirements#Name|NAME]]
| &nbsp;&nbsp;<nowiki>[Player Name]&nbsp;&nbsp;(Player Name)&nbsp;&nbsp;(Player Name) ...</nowiki>
}}
{{Denizen Requiremnt Type Color|ivory|
[[Interact_Script_Requirements#Item|ITEM]]
| &nbsp;&nbsp;<nowiki>[[ITEM_NAME]|[#]:[#]]&nbsp;&nbsp;(Quantity)</nowiki>
}}
{{Denizen Requiremnt Type Color|ivory|
[[Interact_Script_Requirements#Holding|HOLDING]]
| &nbsp;&nbsp;<nowiki>[[ITEM_NAME]|[#]:[#]]&nbsp;&nbsp;(Quantity)</nowiki>
}}
{{Denizen Requiremnt Type Color|ivory|
[[Interact_Script_Requirements#Wearing|WEARING]]
| &nbsp;&nbsp;<nowiki>[[ITEM_NAME]|[#]:[#]]</nowiki>
}}
{{Denizen Requiremnt Type Color|ivory|
[[Interact_Script_Requirements#Hunger|HUNGER]]
| &nbsp;&nbsp;<nowiki>[Full|Hungry|Starving]</nowiki>
}}
{{Denizen Requiremnt Type Color|ivory|
[[Interact_Script_Requirements#Wearing|LEVEL]]
| &nbsp;&nbsp;<nowiki>[# or higher]&nbsp;&nbsp;OR&nbsp;&nbsp;LEVEL&nbsp;&nbsp;[At least this Level #]&nbsp;&nbsp;[No more than this Level #]</nowiki>
}}
{{Denizen Requiremnt Type Color|ivory|
[[Interact_Script_Requirements#Wearing|POTIONEFFECT]]
| &nbsp;&nbsp;<nowiki>[POTION_TYPE]</nowiki>
}}
{{Denizen Requiremnt Type Color|ivory|
[[Interact_Script_Requirements#Wearing|DURABILITY]]
| &nbsp;&nbsp;<nowiki>[>,<,=] [#|#%]</nowiki>
}}
</div>
 
''' WORLD REQUIREMENTS '''
<div style="margin-right:2.0em; padding:10px; font-family:museo-sans; font-size:110%;">
{{Denizen Requiremnt Type Color|aliceblue|
[[Interact_Script_Requirements#Name|WORLD]]
| &nbsp;&nbsp;<nowiki>[World Name]&nbsp;&nbsp;(World Name)&nbsp;&nbsp;(World Name) ...</nowiki>
}}
{{Denizen Requiremnt Type Color|aliceblue|
[[Interact_Script_Requirements#Time|TIME]]
| &nbsp;&nbsp;<nowiki>[Day|Night|Dusk|Dawn]  OR  TIME [0-23999] [1-24000]</nowiki>
}}
{{Denizen Requiremnt Type Color|aliceblue|
[[Interact_Script_Requirements#Time|POWERED]]
| &nbsp;&nbsp;<nowiki>[Block Bookmark]</nowiki>
}}
{{Denizen Requiremnt Type Color|aliceblue|
[[Interact_Script_Requirements#Sunny|SUNNY]]
| &nbsp;&nbsp;
}}
{{Denizen Requiremnt Type Color|aliceblue|
[[Interact_Script_Requirements#Sunny|PRECIPITATING]]
| &nbsp;&nbsp;
}}
{{Denizen Requiremnt Type Color|aliceblue|
[[Interact_Script_Requirements#Storming|STORMY]]
| &nbsp;&nbsp;
}}
</div>
 
''' SCRIPT REQUIREMENTS
<div style="margin-right:2.0em; padding:10px; font-family:museo-sans; font-size:110%;">
{{Denizen Requiremnt Type Color|mintcream|
[[Interact_Script_Requirements#Finished|FINISHED]]
| &nbsp;&nbsp;<nowiki>(# of times)&nbsp;&nbsp;[Script Name]</nowiki>
}}
{{Denizen Requiremnt Type Color|mintcream|
[[Interact_Script_Requirements#Failed|FAILED]]
| &nbsp;&nbsp;<nowiki>(# of times)&nbsp;&nbsp;[Script Name]</nowiki>
}}
{{Denizen Requiremnt Type Color|mintcream|
[[Interact_Script_Requirements#Sunny|ACTIVITY]]
| &nbsp;&nbsp;[Name of Activity]
}}
{{Denizen Requiremnt Type Color|mintcream|
[[Interact_Script_Requirements#Sunny|FLAGGED]]
| &nbsp;&nbsp;(FlagName:Value OR FlagName #)
}}
</div>
 
'''VAULT REQUIREMENTS'''
<div style="margin-right:2.0em; padding:10px; font-family:museo-sans; font-size:110%;">
These requirements only work if you have Vault installed and a compatible permissions/economy plugin.
 
{{Denizen Requiremnt Type Color|whitesmoke|
[[Interact_Script_Requirements#Permission|PERMISSION]]
| &nbsp;&nbsp;[permission.node]
}}
{{Denizen Requiremnt Type Color|whitesmoke|
[[Interact_Script_Requirements#Sunny|GROUP]]
| &nbsp;&nbsp;<nowiki>[Group Name]&nbsp;&nbsp;(Group Name)&nbsp;&nbsp;(Group Name) ...</nowiki>
}}
{{Denizen Requiremnt Type Color|whitesmoke|
[[Interact_Script_Requirements#Money|MONEY]]
| &nbsp;&nbsp;[Quantity]
}}
</div>
 
'''Negative Requirements
<div style="margin-right:2.0em; padding:10px; font-family:museo-sans; font-size:110%;">
Requirements can also be 'negative' requirements. In the Requirements List, just place a '-' in front of the requirement to inverse its logic. For example, 'HOLDING IRON_SWORD' would require the player to be holding an Iron Sword. '-HOLDING IRON_SWORD' would require the player to NOT be holding an Iron Sword. All requirements have a negative alternative, even ones whose function may overlap, such as '-WEATHER Precipitating' and 'WEATHER Sunny', which technically do the same thing. If anything, it can add to script readability. The negative requirement '-' should not be confused with the 'list item -' with a trailing space in front of each Requirement in the List, as that is standard YAML list format. See below:
 
<code>
  Requirements:
    Mode: All
    List:
    - -TIME Night
    - -MONEY 1000000
    - -STORMY
</code>
 
Negative requirements can completely change the original example around. In this 'revised' example, for this script to trigger, time needs to be day, the weather in the current world must NOT be storming, and the player have less than 1000000 units of currency on them.
</div>


==== Steps Node ====
==== Steps Node ====

Revision as of 17:33, 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.

See: 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?'

The sub-sections below reference this example.

Trigger Nodes

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 Triggers activate when the Denizen is right-clicked.
Click Trigger:
  Script:
  - CHAT "Teehee, that tickles!"
  - EMOTE "giggles"
  • Damage Triggers activate when the Denizen is left-clicked. If the Denizen has Damage Triggers disabled, this will count as a Click Trigger.
Damage Trigger:
  Script:
  - CHAT "OUCH, You'll pay for that!"
  - STRIKE <PLAYER>
  • Proximity Triggers activate when a player walks close to the Denizen.
Proximity Trigger:
  Script:
  - CHAT 'Eek! get away, you smell bad, <PLAYER>.'


  • Chat Triggers 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:
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>!"
  • Location Triggers 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.
Location Trigger:
  '1':
    Trigger: TreasureRoom
    - TELEPORT BOOKMARK:Jail
  '2':
    Trigger: BedRoom
    - NARRATE 'You enter the bedroom of the dead man, looking for clues'

For a full list of commands, see #Script Commands