Denizen/0.7/Example Scripts/Beginner Scripts: Difference between revisions
No edit summary |
No edit summary |
||
(37 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
Example scripts are provided with both the assignments and the scripts in the same box. Be sure and put the text in the correct file in your plugins folder. | |||
*Assignments should always be | For more up-to-date information and full details on specific features (individual commands or tags, for example), check the [https://meta.denizenscript.com/ Meta Documentation]. | ||
*Scripts can be placed in any .yml file in the plugins\Denizen\scripts\ directory | |||
If you want a full tutorial to help get you set up, check out the [https://guide.denizenscript.com/ Beginner's Guide] text website. | |||
If you need quick help, visit our [https://discord.gg/Q6pZGSR Discord group]. | |||
<br><br><br> | |||
<span style="font-family:natalya-alternate-one; font-size:300%; margin-right:-7px; margin-left:-10px;">This wiki is outdated, please view the tutorial videos/guide, meta documentation, or Discord group (all linked above) for up-to-date information!</span> | |||
<br><br><br> | |||
<s><div style="font-family:camingodos-web;"> | |||
<div style="float:right;margin-left:2.0em; padding:10px; font-family:camingodos-web; font-size:110%; ">__TOC__</div> | |||
<div style="margin-right:2.0em; margin-top:35px; padding:10px; font-family:camingodos-web; font-size:110%;"> | |||
<span style="font-family:natalya-alternate-one; font-size:650%; margin-right:-7px; margin-left:-10px;">S</span>ometimes the best way to learn is by looking at some examples. The following beginner scripts use basic denizen commands and requirements to provide some nice basic functionality for your Denizens. | |||
<br><br> | |||
<div style="padding:20px; font-family:camingodos-web; font-size:110%; background-color:#EEDDEE; border-style:dotted; border-width:1px; width:55%; font-weight:500;">Example scripts are provided with both the assignments and the scripts in the same box. Be sure and put the text in the correct file in your plugins folder. | |||
* Assignments should always be appended to plugins\Denizen\assignments.yml | |||
* Scripts can be placed in any .yml file in the plugins\Denizen\scripts\ directory. Remember: You can have multiple scripts per file! | |||
</div> | |||
<br><br> | |||
and now... the scripts! | |||
</div> | |||
==Denizen Basics== | |||
<div style="margin-right:2.0em; padding:10px; font-family:camingodos-web; font-size:110%;"> | |||
Though Denizen can be very advanced, it can perform very simple tasks, as well. Most of the basics can be covered with a QUICK SCRIPT. Check out these examples. | |||
====The Click and Damage Triggers==== | |||
Clicking on a Denizen NPC can activates the Click Trigger or Damage Trigger, depending on which buttom was pressed. This is probably the easiest and most straight-forward way to interact with a NPC. Be sure to turn on the Damage Trigger! (Use /denizen trigger toggle damage) | |||
{{codebox|height=250px|Right click to speak, left click hurts!|<syntaxhighlight line='false' lang="yaml"> | |||
# A basic QUICK SCRIPT with a click trigger and damage trigger. | |||
# Note: Unless your npc is VULNERABLE (use /npc vulnerable -t), | |||
# the Denizen won't take any automatic damage on a Damage Trigger. | |||
# It must be handled and dealt with by using commands. | |||
# | |||
# ---- Assignments.yml | |||
Denizens: | |||
'Jeremy': | |||
Quick Scripts: | |||
Click Trigger: | |||
Script: | |||
- CHAT "Here, have a shovel." | |||
- DROP STONE_SPADE | |||
Damage Trigger: | |||
Script: | |||
- CHAT "Hey, what was that for?" | |||
</syntaxhighlight> | |||
}} | |||
====The Chat and Proximity Triggers==== | |||
The two remaining Quick Script triggers are the Chat and Proximity Triggers. Chat will catch any text said near the Denizen NPC and intercept it. The Player's text is directed towards the NPC and the NPC can respond back. Proximity is triggered when the Player comes into a specified range. (Note: Proximity is not enabled by default, so select the NPC you desire to have the Prox. Trigger and type /denizen trigger toggle proximity) | |||
{{codebox|height=250px|The worst therapist ever.|<syntaxhighlight line='false' lang="yaml"> | |||
# A basic QUICK SCRIPT with a click trigger and damage trigger. | |||
# Note: Quick Script Chat triggers will respond to ANY text. If | |||
# you wish to specify a keyword, use an interact script chat trigger. | |||
# | |||
# ---- Assignments.yml | |||
Denizens: | |||
'Richard': | |||
Quick Scripts: | |||
Proximity Trigger: | |||
Script: | |||
- CHAT "Hey, welcome to my house!" | |||
- CHAT "Tell me about your day..." | |||
Chat Trigger: | |||
Script: | |||
- CHAT "Oh my! Sounds very interesting!" | |||
</syntaxhighlight> | |||
}} | |||
</div> | |||
==Simple, random conversations== | |||
<div style="margin-right:2.0em; padding:10px; font-family:camingodos-web; font-size:110%;"> | |||
A great way to provide some nice immersion into your world is as simple as a basic interaction with a Denizen NPC outputting a random response. There are a couple different ways this can be done, as provided in the examples below. Since this concept is simple, it can be done with a Quick Script as well as an Interact Script. | |||
====A conversation with RANDOM==== | |||
{{codebox|height=250px|Quick Script conversation with the RANDOM command.|<syntaxhighlight line='false' lang="yaml"> | |||
# A quick script conversation with RANDOM | |||
# | |||
# ---- Assignments.yml | |||
Denizens: | |||
'Notch': | |||
Quick Scripts: | |||
Click Trigger: | |||
Script: | |||
- CHAT "The next message will be random." | |||
- ^RANDOM 4 | |||
- CHAT "Random message 1." | |||
- CHAT "Random message 2." | |||
- CHAT "Random message 3." | |||
- CHAT "Random message 4." | |||
</syntaxhighlight> | |||
}} | |||
====A conversation with ZAP RANDOM==== | |||
{{codebox|height=250px|Interact Script conversation with the ZAP command.|<syntaxhighlight line='false' lang="yaml"> | |||
# An interact script for conversation with ZAP | |||
# | |||
# ---- Assignments.yml | |||
Denizens: | |||
Notch: | |||
Interact Scripts: | |||
- 10 Random conversations | |||
# ---- Random conversations.yml | |||
'Random conversations': | |||
Type: Interact | |||
Requirements: | |||
Mode: None | |||
Steps: | |||
1: | |||
Click Trigger: | |||
Script: | |||
- CHAT "This is step 1." | |||
- ZAP RANDOM:2-3 | |||
2: | |||
Click Trigger: | |||
Script: | |||
- CHAT "This is step 2. Now, back to step 1!" | |||
- ZAP 1 | |||
3: | |||
Click Trigger: | |||
Script: | |||
- CHAT "This is step 3. Now, back to step 1!" | |||
- ZAP 1 | |||
</syntaxhighlight> | |||
}} | |||
====Notch's Cookies==== | |||
{{codebox|height=250px|Notch loves cookies, and RANDOM chat.|<syntaxhighlight line='false' lang="yaml"> | |||
# A small script for conversing with Notch, with an easter egg | |||
# if you can figure out the magic word. | |||
# | |||
# ---- Assignments.yml | |||
Denizens: | |||
Notch: | |||
Interact Scripts: | |||
- 10 Notch Cookies | |||
# ---- Random conversations.yml | |||
'Notch Cookies': | |||
Type: Interact | |||
Requirements: | |||
Mode: None | |||
Steps: | |||
1: | |||
Click Trigger: | |||
Script: | |||
- RANDOM 3 | |||
- CHAT 'I Like Cookies!' | |||
- CHAT 'MMmm.. cookies are my favorite!' | |||
- CHAT 'Cocoa and Wheat make me freak!' | |||
Chat Trigger: | |||
1: | |||
Trigger: 'I love /cookie/s!' | |||
Script: | |||
- CHAT 'Me too!' | |||
- EMOTE 'gives <PLAYER> some cookies.' | |||
- EMOTE 'gives <PLAYER> some cookies.' | |||
- GIVE COOKIE QTY:6 | |||
- ZAP 2 | |||
2: | |||
Click Trigger: | |||
Script: | |||
- CHAT 'How were the cookies?' | |||
</syntaxhighlight> | |||
}} | |||
</div> | |||
==Multiple Scripts & Requirements== | |||
<div style="margin-right:2.0em; padding:10px; font-family:camingodos-web; font-size:110%;"> | |||
Random chat is nice, but controlling the flow of conversation and events is just as important. One of the best features of Denizen's Interact Scripts is the requirements system, which can be used to control multiple scripts. Imagine NPCs greeting players based on weather, or having conversations only when on a quest. For further understanding, you should check out [Denizen/Script Assignments#Multiple Scripts], but take these examples below to get a basic understanding. | |||
====A Simple Multiple Requirement Script==== | |||
{{codebox|height=250px|Two scripts are better than one.|<syntaxhighlight line='false' lang="yaml"> | |||
# A script that shows the behavior of multiple assignments. | |||
# | |||
# ---- Assignments.yml | |||
Denizens: | |||
Jimmy: | |||
Interact Scripts: | |||
- 10 Script 1 | |||
- 20 Script 2 | |||
# ---- Multiple Scripts.yml | |||
'Script 1': | |||
Type: Interact | |||
Requirements: | |||
Mode: None | |||
Steps: | |||
1: | |||
Click Trigger: | |||
Script: | |||
- NARRATE "You have clicked on script 1." | |||
'Script 2': | |||
Type: Interact | |||
Requirements: | |||
Mode: All | |||
List: | |||
- TIME Night | |||
Steps: | |||
1: | |||
Click Trigger: | |||
Script: | |||
- NARRATE "You have clicked on script 2, | |||
which only activates when it is night." | |||
</syntaxhighlight> | |||
}} | |||
====Script sequencing with the SCRIPT requirement==== | |||
Another good way to control the flow of multiple scripts is by using the SCRIPT requirement, which can check if the player has completed or failed scripts. Since 'Quest, part 2' requires the completion of 'Quest, part 1', the player will be forced to complete the scripts in an order set forth by the arguments in the requirement. | |||
{{codebox|height=250px|You must do them in order!|<syntaxhighlight line='false' lang="yaml"> | |||
# A script that shows the behavior of multiple assignments. | |||
# | |||
# ---- Assignments.yml | |||
Denizens: | |||
Jimmy: | |||
Interact Scripts: | |||
- 10 Quest, part 1 | |||
- 20 Quest, part 2 | |||
# ---- Multiple Scripts.yml | |||
'Quest, part 1': | |||
Type: Interact | |||
Requirements: | |||
Mode: None | |||
Steps: | |||
1: | |||
Click Trigger: | |||
Script: | |||
- ^FINISH | |||
- NARRATE 'And with no warning... | |||
- NARRATE '...you embark on a quest, filled with danger.' | |||
'Quest, part 2': | |||
Type: Interact | |||
Requirements: | |||
Mode: All | |||
List: | |||
- SCRIPT FINISHED 'SCRIPT:Quest, part 1' | |||
Steps: | |||
1: | |||
Click Trigger: | |||
Script: | |||
- CHAT AS_PLAYER "Uhh.. can I at least have a sword?" | |||
- LOOK AT | |||
- CHAT "Yes, I suppose that would be wise... check the attic.' | |||
</syntaxhighlight> | |||
}} | |||
====Script sequencing with FLAGS==== | |||
This script is more of an intermediate script, but shows how flags can be used to control sequence of a script. In this example, multiple NPCs are part of this karma example. Note: Scottie's Script/Jason's Script/etc. are not shown, and aren't necessarily important to this example, but it is assumed that the player collects karma from these characters, somehow, '''one at a time'''. | |||
{{codebox|height=250px|A sample 'Karma' reward system.|<syntaxhighlight line='false' lang="yaml"> | |||
# A very small example for a 'karma reward system'. | |||
# | |||
# ---- Assignments.yml | |||
Denizens: | |||
Scottie: | |||
Interact Scripts: | |||
- 10 Scottie's Script | |||
- 100 ^Karma Check | |||
Jason: | |||
Interact Scripts: | |||
- 10 Jason's Script | |||
- 100 ^Karma Check | |||
Jeb: | |||
Interact Scripts: | |||
- 10 Jeb's Script | |||
- 100 ^Karma Check | |||
# ---- Multiple Scripts.yml | |||
'Karma Check': | |||
Type: Interact | |||
Requirements: | |||
Mode: Any | |||
List: | |||
- FLAGGED EXACTLY KARMA:10 | |||
- FLAGGED EXACTLY KARMA:50 | |||
- FLAGGED EXACTLY KARMA:100 | |||
Steps: | |||
1: | |||
Click Trigger: | |||
Script: | |||
- CHAT "Wow, <PLAYER>, sorry to interrupt, but you've certainly racked up some karma!" | |||
- RUNTASK 'SCRIPT:Karma reward <FLAG.PLAYER:KARMA>' | |||
# These 'TASK' scripts are only used when called upon. | |||
'Karma reward 10': | |||
Type: Task | |||
Script: | |||
- NARRATE "Alright! You have 10 karma! Here's a reward.." | |||
- GIVE BREAD QTY:10 | |||
'Karma reward 50': | |||
Type: Task | |||
Script: | |||
- NARRATE "Whoa! You have 50 karma! Here's a reward.." | |||
- GIVE GOLD_INGOT QTY:25 | |||
'Karma reward 100': | |||
Type: Task | |||
Script: | |||
- NARRATE "Holy bejezzus! 100 KARMA?! Here's a reward.." | |||
- GIVE GOLDEN_APPLE QTY:5 | |||
</syntaxhighlight> | |||
}} | |||
Line 7: | Line 365: | ||
{| class="wikitable collapsible collapsed" | {| class="wikitable collapsible collapsed" | ||
! Joe the Builder Script and Assignment | ! Joe the Builder Script and Assignment | ||
Line 19: | Line 375: | ||
Interact Scripts: #These are the assigned interact scripts. The number before the script is the priority. | Interact Scripts: #These are the assigned interact scripts. The number before the script is the priority. | ||
- 0 Regular Joe | - 0 Regular Joe | ||
- 10 Joe the Builder | - 10 ^Joe the Builder | ||
Line 32: | Line 388: | ||
Script: #This sends a basic message to the interacting player. | Script: #This sends a basic message to the interacting player. | ||
- CHAT "Hello <PLAYER>! I supply builders only!" | - CHAT "Hello <PLAYER>! I supply builders only!" | ||
Proximity Trigger: | |||
Script: #This sends a basic message to the player when he walks near. | |||
- CHAT "Hello <PLAYER>! Welcome to <WORLD>!" | |||
'Joe the Builder': | 'Joe the Builder': | ||
Type: Interact | Type: Interact | ||
Requirements: | Requirements: | ||
Mode: All | Mode: All | ||
List:#Here we check if the player has this permission. If he does, this script is selected because it is higher priority. | List: #Here we check if the player has this permission. If he does, this script is selected because it is higher priority. | ||
- PERMISSION modifyworld.* | - PERMISSION modifyworld.* | ||
Steps: | Steps: | ||
Line 47: | Line 406: | ||
- CHAT "Hello <PLAYER> the Builder! Take this shovel!" | - CHAT "Hello <PLAYER> the Builder! Take this shovel!" | ||
- GIVE WOOD_SPADE | - GIVE WOOD_SPADE | ||
- WAIT 1 | |||
- CHAT "If you have any questions, just say 'help'" | |||
- FINISH | - FINISH | ||
#This increments the number of times this script (Joe The Builder) has been completed by this player. | #This increments the number of times this script (Joe The Builder) has been completed by this player. | ||
- DISENGAGE | - DISENGAGE | ||
#This sets the NPC Interactable again. | #This sets the NPC Interactable again. | ||
Chat Trigger: #There can be multiple entries under a Chat Trigger or Location Trigger node. Hence the 1: on the next line. | |||
1: | |||
Trigger: I need some /help/ | |||
Script: | |||
- CHAT "Press 'e' to open your inventory, and drag the shovel to your item bar" | |||
- CHAT "Press the number 1-9 to select the shovel, then start digging!" | |||
</pre> | </pre> | ||
|} | |} | ||
==Basic Repeatable Fetch Quest== | |||
Here is the fastest way to do a repeatable 'fetch' quest. Useful for custom crafting-type NPCs. Once the player agrees to help, he can turn in the items as often as he wants to receive the reward. | |||
{| class="wikitable collapsible collapsed" | |||
! Basic Repeatable Fetch Quest | |||
|- | |||
| <pre> | |||
#--- assignments.yml ---- | |||
Denizens: | |||
John Q QuestGiver: | |||
Interact Scripts: | |||
- 0 StartFetch | |||
- 1 EndFetch | |||
#--- RepeatableFetchQuest.yml ---- | |||
StartQuest: | |||
Type: Interact | |||
Requirements: | |||
Mode: None | |||
Steps: | |||
1: | |||
Click Trigger: | |||
Script: | |||
- CHAT "Hey, you there!" | |||
- CHAT "I have a special request of you!" | |||
- CHAT "Will you help me?" | |||
Chat Trigger: | |||
1: | |||
Trigger: /Yes/. I will. | |||
Script: | |||
#Tell the player what to do. | |||
- CHAT "I need you to bring me some thing. For testing!" | |||
- WAIT 1 | |||
- CHAT "I need: 1 Iron Block, 1 Feather, and 3 Eggs." | |||
- WAIT 1 | |||
- CHAT "Come back when you have them and I will reward you!" | |||
#Set this script as finished, so we know they're on the quest | |||
- FINISH | |||
#set this script to step 2. So the player gets the hint message. | |||
- ZAP | |||
2: | |||
Trigger: /No/. I will not. | |||
Script: | |||
- CHAT "Are you sure? OK. maybe later?" | |||
2: | |||
Click Trigger: | |||
Script: | |||
- CHAT "Come back you have 1 Iron Block, 1 Feather, and 3 Eggs!" | |||
EndFetch: | |||
Type: Trigger | |||
Requirements: | |||
Mode: All | |||
List: #Here we check if they are on the quest and have the items. | |||
- FINISHED StartQuest | |||
- ITEM 42 1 | |||
- ITEM 288 1 | |||
- ITEM 344 3 | |||
Steps: | |||
'1': | |||
Click Trigger: | |||
Script: | |||
#Engage is used to keep the player from clicking twice. | |||
- ENGAGE | |||
- TAKE 42 QTY:1 | |||
- TAKE 288 QTY:1 | |||
- TAKE 344 QTY:3 | |||
- CHAT "Thank you so much! Here, take this as a reward!" | |||
- GIVE 133 QTY:1 | |||
- WAIT 1 | |||
- CHAT "Bring me those items again, and I'll give you another!" | |||
#Always disengagae after an Engage | |||
- DISENGAGE | |||
</pre> | |||
|} | |||
==Basic Unrepeatable Fetch Quest== | |||
By adding 3 lines to the script above, it becomes un-repeatable. | |||
{| class="wikitable collapsible collapsed" | |||
! Basic Repeatable Fetch Quest | |||
|- | |||
| <pre> | |||
#--- assignments.yml ---- | |||
Denizens: | |||
John Q QuestGiver: | |||
Interact Scripts: | |||
- 0 StartFetch | |||
- 1 EndFetch | |||
#--- UnRepeatableFetchQuest.yml ---- | |||
StartQuest: | |||
Type: Interact | |||
Requirements: | |||
Mode: None | |||
Steps: | |||
1: | |||
Click Trigger: | |||
Script: | |||
- CHAT "Hey, you there!" | |||
- CHAT "I have a special request of you!" | |||
- CHAT "Will you help me?" | |||
Chat Trigger: | |||
1: | |||
Trigger: /Yes/. I will. | |||
Script: | |||
- CHAT "I need you to bring me some thing. For testing!" | |||
- WAIT 1 | |||
- CHAT "I need: 1 Iron Block, 1 Feather, and 3 Eggs." | |||
- WAIT 1 | |||
- CHAT "Come back when you have them and I will reward you!" | |||
- FINISH | |||
- ZAP | |||
2: | |||
Trigger: /No/. I will not. | |||
Script: | |||
- CHAT "Are you sure? OK. maybe later?" | |||
2: | |||
Click Trigger: | |||
Script: | |||
- CHAT "Come back you have 1 Iron Block, 1 Feather, and 3 Eggs!" | |||
3: | |||
Click Trigger: | |||
Script: | |||
- CHAT "Thanks for the help before!" | |||
EndFetch: | |||
Type: Interact | |||
Requirements: | |||
Mode: All | |||
List: #Here we check if they are on the quest and have the items, and haven't completed this yet. | |||
- FINISHED StartQuest | |||
- -FINISHED EndFetch | |||
- ITEM 42 1 | |||
- ITEM 288 1 | |||
- ITEM 344 3 | |||
Steps: | |||
'1': | |||
Click Trigger: | |||
Script: | |||
- ENGAGE | |||
- TAKE 42 QTY:1 | |||
- TAKE 288 QTY:1 | |||
- TAKE 344 QTY:3 | |||
- CHAT "Thank you so much! Here, take this as a reward!" | |||
- GIVE 133 QTY:1 | |||
- WAIT 1 | |||
- CHAT "Tbanks so much! see you around!" | |||
#This handy command will move the first script to Step 3. | |||
- ZAP 3 SCRIPT:StartFetch | |||
#Mark this script as completed. | |||
- FINISH | |||
- DISENGAGE | |||
</pre> | |||
|} | |||
==The Race== | |||
Coach wants you to RUN, BOY! This script uses a TASK script and a Location trigger to make a timed race for the player. Good example of ZAP and RUNTASK/CANCELTASK command usage. Be sure and define a Location Bookmark called 'theTree' using the <code> /denizen bookmark location </code> command. Be sure to turn on the Location Trigger for this NPC! (Use /denizen trigger toggle location) | |||
{| class="wikitable collapsible collapsed" | |||
! Joe the Builder Script and Assignment | |||
|- | |||
| | |||
<pre> | |||
---- assignments.yml---- | |||
Denizens: | |||
Coach: | |||
Interact Scripts: | |||
- 0 Coaches Race | |||
---- Scripts.yml ----- | |||
'RaceEnd': | |||
Type: Task | |||
Script: | |||
- NARRATE "%%cTimes Up!" | |||
- ZAP 'SCRIPT:Coaches Race' 3 | |||
"Coaches Race": | |||
Type: Interact | |||
Requirements: | |||
Mode: All | |||
List: | |||
- -FINISHED Coaches Race | |||
Steps: | |||
1: | |||
Click Trigger: | |||
Script: | |||
- CHAT "Think you're fast, sonny-jim?" | |||
- CHAT "Lets see how fast you are. Run up that hill, around the tree, and back in 15 seconds, if you can!" | |||
- WAIT 1 | |||
- CHAT "On your mark, get set, go!" | |||
- RUNTASK SCRIPT:RaceEnd DELAY:15 | |||
- ZAP 2 | |||
2: | |||
Location Trigger: | |||
1: | |||
Trigger: theTree | |||
Script: | |||
- ZAP 4 | |||
Click Trigger: | |||
Script: | |||
- CANCELTASK RaceEnd | |||
- CHAT "Trying to cheat eh?, you have to go around the tree!, try again later, slowpoke!" | |||
- ZAP 1 | |||
3: | |||
Click Trigger: | |||
Script: | |||
- CHAT "Aww too slow!, go run some laps and try again!" | |||
- ZAP 1 | |||
4: | |||
Click Trigger: | |||
Script: | |||
- CANCELTASK RaceEnd | |||
- CHAT "Woo, you are quick! Good job!" | |||
- GIVE MONEY QTY:1000 | |||
- FINISH | |||
</pre> | |||
|} | |||
[[Category:Denizen 0.7]]</s> |
Latest revision as of 18:57, 3 September 2021
For more up-to-date information and full details on specific features (individual commands or tags, for example), check the Meta Documentation.
If you want a full tutorial to help get you set up, check out the Beginner's Guide text website.
If you need quick help, visit our Discord group.
This wiki is outdated, please view the tutorial videos/guide, meta documentation, or Discord group (all linked above) for up-to-date information!
Sometimes the best way to learn is by looking at some examples. The following beginner scripts use basic denizen commands and requirements to provide some nice basic functionality for your Denizens.
- Assignments should always be appended to plugins\Denizen\assignments.yml
- Scripts can be placed in any .yml file in the plugins\Denizen\scripts\ directory. Remember: You can have multiple scripts per file!
and now... the scripts!
Denizen Basics
Though Denizen can be very advanced, it can perform very simple tasks, as well. Most of the basics can be covered with a QUICK SCRIPT. Check out these examples.
The Click and Damage Triggers
Clicking on a Denizen NPC can activates the Click Trigger or Damage Trigger, depending on which buttom was pressed. This is probably the easiest and most straight-forward way to interact with a NPC. Be sure to turn on the Damage Trigger! (Use /denizen trigger toggle damage)
Code: Right click to speak, left click hurts! |
{{{2}}} |
The Chat and Proximity Triggers
The two remaining Quick Script triggers are the Chat and Proximity Triggers. Chat will catch any text said near the Denizen NPC and intercept it. The Player's text is directed towards the NPC and the NPC can respond back. Proximity is triggered when the Player comes into a specified range. (Note: Proximity is not enabled by default, so select the NPC you desire to have the Prox. Trigger and type /denizen trigger toggle proximity)
Code: The worst therapist ever. |
{{{2}}} |
Simple, random conversations
A great way to provide some nice immersion into your world is as simple as a basic interaction with a Denizen NPC outputting a random response. There are a couple different ways this can be done, as provided in the examples below. Since this concept is simple, it can be done with a Quick Script as well as an Interact Script.
A conversation with RANDOM
Code: Quick Script conversation with the RANDOM command. |
{{{2}}} |
A conversation with ZAP RANDOM
Code: Interact Script conversation with the ZAP command. |
{{{2}}} |
Notch's Cookies
Code: Notch loves cookies, and RANDOM chat. |
{{{2}}} |
Multiple Scripts & Requirements
Random chat is nice, but controlling the flow of conversation and events is just as important. One of the best features of Denizen's Interact Scripts is the requirements system, which can be used to control multiple scripts. Imagine NPCs greeting players based on weather, or having conversations only when on a quest. For further understanding, you should check out [Denizen/Script Assignments#Multiple Scripts], but take these examples below to get a basic understanding.
A Simple Multiple Requirement Script
Code: Two scripts are better than one. |
{{{2}}} |
Script sequencing with the SCRIPT requirement
Another good way to control the flow of multiple scripts is by using the SCRIPT requirement, which can check if the player has completed or failed scripts. Since 'Quest, part 2' requires the completion of 'Quest, part 1', the player will be forced to complete the scripts in an order set forth by the arguments in the requirement.
Code: You must do them in order! |
{{{2}}} |
Script sequencing with FLAGS
This script is more of an intermediate script, but shows how flags can be used to control sequence of a script. In this example, multiple NPCs are part of this karma example. Note: Scottie's Script/Jason's Script/etc. are not shown, and aren't necessarily important to this example, but it is assumed that the player collects karma from these characters, somehow, one at a time.
Code: A sample 'Karma' reward system. |
{{{2}}} |
Joe the Builder Script and Assignment |
---|
---- assignments.yml ---- Denizens: 'Steve': #This is the name of the Denizen Interact Scripts: #These are the assigned interact scripts. The number before the script is the priority. - 0 Regular Joe - 10 ^Joe the Builder ---- script.yml ---- 'Regular Joe': Type: Interact Requirements: #There is no list of requirements, so this script can always be picked. That's why we assign it with low priority. Mode: None Steps: 1: Click Trigger: Script: #This sends a basic message to the interacting player. - CHAT "Hello <PLAYER>! I supply builders only!" Proximity Trigger: Script: #This sends a basic message to the player when he walks near. - CHAT "Hello <PLAYER>! Welcome to <WORLD>!" 'Joe the Builder': Type: Interact Requirements: Mode: All List: #Here we check if the player has this permission. If he does, this script is selected because it is higher priority. - PERMISSION modifyworld.* Steps: 1: Click Trigger: Script: - ENGAGE #Engage prevents all interaction with this NPC until DISENGAGE is called. - CHAT "Hello <PLAYER> the Builder! Take this shovel!" - GIVE WOOD_SPADE - WAIT 1 - CHAT "If you have any questions, just say 'help'" - FINISH #This increments the number of times this script (Joe The Builder) has been completed by this player. - DISENGAGE #This sets the NPC Interactable again. Chat Trigger: #There can be multiple entries under a Chat Trigger or Location Trigger node. Hence the 1: on the next line. 1: Trigger: I need some /help/ Script: - CHAT "Press 'e' to open your inventory, and drag the shovel to your item bar" - CHAT "Press the number 1-9 to select the shovel, then start digging!" |
Basic Repeatable Fetch Quest
Here is the fastest way to do a repeatable 'fetch' quest. Useful for custom crafting-type NPCs. Once the player agrees to help, he can turn in the items as often as he wants to receive the reward.
Basic Repeatable Fetch Quest |
---|
#--- assignments.yml ---- Denizens: John Q QuestGiver: Interact Scripts: - 0 StartFetch - 1 EndFetch #--- RepeatableFetchQuest.yml ---- StartQuest: Type: Interact Requirements: Mode: None Steps: 1: Click Trigger: Script: - CHAT "Hey, you there!" - CHAT "I have a special request of you!" - CHAT "Will you help me?" Chat Trigger: 1: Trigger: /Yes/. I will. Script: #Tell the player what to do. - CHAT "I need you to bring me some thing. For testing!" - WAIT 1 - CHAT "I need: 1 Iron Block, 1 Feather, and 3 Eggs." - WAIT 1 - CHAT "Come back when you have them and I will reward you!" #Set this script as finished, so we know they're on the quest - FINISH #set this script to step 2. So the player gets the hint message. - ZAP 2: Trigger: /No/. I will not. Script: - CHAT "Are you sure? OK. maybe later?" 2: Click Trigger: Script: - CHAT "Come back you have 1 Iron Block, 1 Feather, and 3 Eggs!" EndFetch: Type: Trigger Requirements: Mode: All List: #Here we check if they are on the quest and have the items. - FINISHED StartQuest - ITEM 42 1 - ITEM 288 1 - ITEM 344 3 Steps: '1': Click Trigger: Script: #Engage is used to keep the player from clicking twice. - ENGAGE - TAKE 42 QTY:1 - TAKE 288 QTY:1 - TAKE 344 QTY:3 - CHAT "Thank you so much! Here, take this as a reward!" - GIVE 133 QTY:1 - WAIT 1 - CHAT "Bring me those items again, and I'll give you another!" #Always disengagae after an Engage - DISENGAGE |
Basic Unrepeatable Fetch Quest
By adding 3 lines to the script above, it becomes un-repeatable.
Basic Repeatable Fetch Quest |
---|
#--- assignments.yml ---- Denizens: John Q QuestGiver: Interact Scripts: - 0 StartFetch - 1 EndFetch #--- UnRepeatableFetchQuest.yml ---- StartQuest: Type: Interact Requirements: Mode: None Steps: 1: Click Trigger: Script: - CHAT "Hey, you there!" - CHAT "I have a special request of you!" - CHAT "Will you help me?" Chat Trigger: 1: Trigger: /Yes/. I will. Script: - CHAT "I need you to bring me some thing. For testing!" - WAIT 1 - CHAT "I need: 1 Iron Block, 1 Feather, and 3 Eggs." - WAIT 1 - CHAT "Come back when you have them and I will reward you!" - FINISH - ZAP 2: Trigger: /No/. I will not. Script: - CHAT "Are you sure? OK. maybe later?" 2: Click Trigger: Script: - CHAT "Come back you have 1 Iron Block, 1 Feather, and 3 Eggs!" 3: Click Trigger: Script: - CHAT "Thanks for the help before!" EndFetch: Type: Interact Requirements: Mode: All List: #Here we check if they are on the quest and have the items, and haven't completed this yet. - FINISHED StartQuest - -FINISHED EndFetch - ITEM 42 1 - ITEM 288 1 - ITEM 344 3 Steps: '1': Click Trigger: Script: - ENGAGE - TAKE 42 QTY:1 - TAKE 288 QTY:1 - TAKE 344 QTY:3 - CHAT "Thank you so much! Here, take this as a reward!" - GIVE 133 QTY:1 - WAIT 1 - CHAT "Tbanks so much! see you around!" #This handy command will move the first script to Step 3. - ZAP 3 SCRIPT:StartFetch #Mark this script as completed. - FINISH - DISENGAGE |
The Race
Coach wants you to RUN, BOY! This script uses a TASK script and a Location trigger to make a timed race for the player. Good example of ZAP and RUNTASK/CANCELTASK command usage. Be sure and define a Location Bookmark called 'theTree' using the /denizen bookmark location
command. Be sure to turn on the Location Trigger for this NPC! (Use /denizen trigger toggle location)
Joe the Builder Script and Assignment |
---|
---- assignments.yml---- Denizens: Coach: Interact Scripts: - 0 Coaches Race ---- Scripts.yml ----- 'RaceEnd': Type: Task Script: - NARRATE "%%cTimes Up!" - ZAP 'SCRIPT:Coaches Race' 3 "Coaches Race": Type: Interact Requirements: Mode: All List: - -FINISHED Coaches Race Steps: 1: Click Trigger: Script: - CHAT "Think you're fast, sonny-jim?" - CHAT "Lets see how fast you are. Run up that hill, around the tree, and back in 15 seconds, if you can!" - WAIT 1 - CHAT "On your mark, get set, go!" - RUNTASK SCRIPT:RaceEnd DELAY:15 - ZAP 2 2: Location Trigger: 1: Trigger: theTree Script: - ZAP 4 Click Trigger: Script: - CANCELTASK RaceEnd - CHAT "Trying to cheat eh?, you have to go around the tree!, try again later, slowpoke!" - ZAP 1 3: Click Trigger: Script: - CHAT "Aww too slow!, go run some laps and try again!" - ZAP 1 4: Click Trigger: Script: - CANCELTASK RaceEnd - CHAT "Woo, you are quick! Good job!" - GIVE MONEY QTY:1000 - FINISH |