Denizen/0.7/Interact Scripts: Difference between revisions
Davidcernat (talk | contribs) m (→Requirements Mode: Fixed Wikitext typo.) |
|||
Line 124: | Line 124: | ||
<code>[] indicates required field.</code> | <code>[] indicates required field.</code> | ||
{{Denizen | {{Denizen Requirement Type Color |white| | ||
ALL | ALL | ||
| Requires all requirements listed to be met. | | Requires all requirements listed to be met. | ||
}} | }} | ||
{{Denizen | {{Denizen Requirement Type Color |white| | ||
ANY [#] | ANY [#] | ||
| Requires the specified number of requirements to be met out of the total of requirements. | | Requires the specified number of requirements to be met out of the total of requirements. | ||
}} | }} | ||
{{Denizen | {{Denizen Requirement Type Color |white| | ||
NONE | NONE | ||
| No requirements need to be met. There is also no need to have a <tt>LIST</tt> node if using <tt>NONE</tt>. | | No requirements need to be met. There is also no need to have a <tt>LIST</tt> node if using <tt>NONE</tt>. | ||
}} | }} | ||
</div> | </div> | ||
=====Requirements===== | =====Requirements===== |
Revision as of 19:19, 30 September 2012
Interact Scripts
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
This small 'outline' below shows the general layout of an Interact Script. Remember: SPACING is INCREDIBLY important with YML. If you are receiving a SnakeYML
error in your console when working with any YML file, 99% of the time it is because of bad spacing or a missing ':' colon. YAML tutorials can be intimidating, but this small tutorial on the Essentials wiki is pretty useful for basic YAML, which is the extent of which Denizens uses.
'Name of script': # Name Node Type: Interact # Type Node Requirements: # Requirements Node Mode: ... List: - ... - ... Steps: # Steps Node 1: # Step Node Some Trigger: # Trigger Node Trigger: ... Script: # Script Node - ... - ... Another Trigger: Script: - ... - ...
For information on what goes in Requirements and Steps, keep reading. What is show above is just a an outline of the correct spacing, not a valid script! Let's take a look at a few small scripts, below.
A few small scripts
...just to get a small look of some basic ways to use scripts. The rest of this document will go into detail about the specifics of each part. Some of the functionality described may require additional reading.
This scripts below is a neat little way to leave a hint. Upon a Player coming into proximity, this script will trigger the NPC looking at a target while holding a small conversation with the player.
"A Hint in the Sky": Type: Interact Requirements: Mode: None Steps: 1: Proximity Trigger: Script: - ^COOLDOWN 15 - LOOK CLOSE - ^CHAT "Look up there! What could that possibly be used for?" - LOOK BOOKMARK:upthere DURATION:10 - WAIT 1 - CHAT "If only I could figure out how to make it, I can't find any stairs!"
Below is a script for a nice fellow who will help an adventurer out in the night-time. Keep in mind that Interact Scripts only define one set of rules for a Denizen NPC... player-interaction. Imagine this next script combined with some activities that make the Denizen NPC scope out and wander an area in some woods.
"Night-time Helper": Type: Interact Requirements: Mode: All List: - TIME NIGHT Steps: 1: Click Trigger: Script: - ^ZAP DURATION:60 - ENGAGE DURATION: 5 - LOOK CLOSE DURATION:5 - CHAT "It's dark out here, man!" - CHAT "You really gotta watch out for those Zombies... they're all over the place!" 2: Click Trigger: Script: - ^COOLDOWN 3600 - LOOK CLOSE DURATION:5 - CHAT "You again, eh? Hey man.. you need some torches?" - WAIT 1 - GIVE TORCH QTY:12
Scripts can also start a story-line of adventures, all activated by scripts working together, thanks to the FLAG, FAIL, and FINISH commands. This small script below could be the start of a Quest, with two different outcomes, if utilized properly.
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 and you to easily 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 are covered in their appropriate sections.
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
Each script can have multiple steps, each with multiple triggers. A player can only ever be on 1 step for a script. When a script is selected to run, a query is made to the Denizen saves to see if the Player has completed any steps. If no entry is found, the player starts on Step 1.
Here's an example of s script making good use of steps. Note the ZAP command is what moves a player from one step to the next, it is NOT automatic!
'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?'
Assigning
See Denizen/Assignments#Interact_Assignment