Denizen/0.7: Difference between revisions

From Citizens Wiki
No edit summary
No edit summary
 
(281 intermediate revisions by 5 users not shown)
Line 8: Line 8:
HEADING = ''' ''' |
HEADING = ''' ''' |
CONTENT = [[image:denizen.png|center]]
CONTENT = [[image:denizen.png|center]]
<div class="padded" style="padding: 19px">
<div class="padded" style="padding: 19px; font-family:camingodos-web; font-size:110%;">


'''Denizen''' is an extension for Citizens that allows scripting of NPCs to handle tasks, quests, player interaction and more!  
'''Denizen''' is an extension for Citizens that allows scripting of NPCs to handle tasks, quests, player interaction and more!  


'''Current Version:''' 0.7 BETA
'''Current Version:''' 0.7.6 Pre-release BETA


'''Developers:''' aufdemrand
'''Developers:''' aufdemrand
Line 18: Line 18:
'''Source:''' [https://github.com/aufdemrand/Denizen Github]
'''Source:''' [https://github.com/aufdemrand/Denizen Github]


'''Development Builds:''' [http://jenkins.citizensnpcs.net/job/Denizen/ Jenkins]
'''Development Builds:''' [http://jenkins.citizensnpcs.com/job/Denizen/ Jenkins]


'''Latest Developmental Build:''' [http://ci.citizensnpcs.net/job/Denizen/lastSuccessfulBuild/ {{Version2}}]
'''Latest Developmental Build:''' [http://ci.citizensnpcs.com/job/Denizen/lastSuccessfulBuild/ {{Version2}}]


'''Support tickets:''' [http://github.com/aufdemrand/Denizen/issues/ Tickets on Github], but please read the entirety of this document first.
'''Support tickets:''' [http://github.com/aufdemrand/Denizen/issues/ Tickets on Github], but please read the entirety of this document first.


'''Donate:''' A lot of man hours has been put into Denizen. Your donations add a lot to the project and are always welcome! Your donations will probably help remodel my house and feed my kids. :)  
'''Donate:''' A lot of man hours has been put into Denizen. Your donations add a lot to the project and are always welcome! Your donations will probably help remodel my house and feed my kids. :)  
[https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=jeremy%2eschroeder%40gmail%2ecom&lc=US&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donate_LG%2egif%3aNonHosted Donate to aufdemrand]
[https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=jeremy%2eschroeder%40gmail%2ecom&lc=US&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donate_LG%2egif%3aNonHosted Donate to aufdemrand] Don't forget to donate to the Citizens2 project as well, as none of this would be possible without that!


'''Thank You:''' A lot of people have stepped forward to help out with Denizen, and that's awesome! Special thanks to everyone who has beta tested, and a huge to these people: fullwall, AgentKid, aPunch, NeonMaster, Instinx, tenowg, groggluebutt, Wreyth, jrbudda, spidi, the list could go on!
'''CitizensUI:''' For a GUI interface, check out [[CitizensUI]] by jrbudda which provides an interface for Citizens NPCs as well as managing scripts and other NPC types.
<br>
<br>


Line 33: Line 36:
</div>
</div>


<div style="float:right; clear:both; width:295px; margin-left:2.5em; margin-top:2.0em; margin-bottom:2.0em">__TOC__</div>
<div style="padding:10px; font-family:camingodos-web; font-size:110%;">
 
[[image:Denizen-Logo-Large.png|center]]
<div style="margin-right:2.0em; padding:10px">
Denizens are a great way to add [http://en.wikipedia.org/wiki/MUD MUD-style] RPG Citizens (and some other features) to your server. Denizen NPCs use mini scripts with steps and events to interact with the player and world. Imagine interactive gate-keepers, magical wizards, experience trainers, bankers, talking townspeople and more! They can be used in thousands of different ways, from tutorials, to questing, to administrating.. your imagination is just about the limit!
</div>
 
== Script Repository ==
<imagemap>Image:Script Repository.png|
rect 2 26 280 104 [http://form.jotform.us/form/21498151597160|]
rect 286 26 555 104 [https://www.dropbox.com/sh/hw6x3f980maa8d9/DNtzAw8cn3]
#<!-- Created by Online Image Map Editor (http://www.maschek.hu/imagemap/index) -->
</imagemap>
 
== Change Log ==
<div style="margin-right:2.0em; padding:10px">
First, thanks for being patient, I know there has been a lot of anxious people waiting for the new release. This took a lot longer to do than I thought, but it's worth it! Updating code and adding content is easier than ever, so keep those feature requests coming in! I also want to put out there that I took OUT the PLAYERTASK command, so please be patient with me as I know a lot of you were looking for more 'quest types'. I am instead placing this in another plugin that will extend Denizen called the Adventurer. This will have similar functionality to the 1.2 Quester, but use Denizen as the core so it can be more flexible and powerful than ever!
 
Second, a huge sorry to current faithful users. I have made a promise to myself and you to try to maintain compatibility throughout the evolution of Denizen. I take that seriously, and that being said, I had to change some syntax around in regards to new commands to make way for cleaner code and the ability to have greater flexibility. The upside to this is there are more options and modifiers for commands than ever before! The downside is there's probably a few commands that you will have to check and fix syntax for if trying to run a 0.6 Denizen Script with the new builds. I am EXTREMELY sorry, but expect some syntax to change on some Requirements soon, too!
 
Here's what's changed!
 
0.7 BETA:
 
* Less bugs!(Hopefully) We're still in beta, but there has been some major code cleanup!
 
* Triggers, Commands, and Activities are now extensible by plugin programmers. See: [http://wiki.citizensnpcs.net/Custom_Denizen_Commands Custom Denizen Commands on the Citizens2 Wiki]. Documentation for extending Triggers and Activities coming soon. Note: Requirements will be extensible very soon.
 
* New! Debug mode will let you see the logic of interaction and script execution to help you find problems in scripts faster than ever.
 
* New! Info-click mode lets you see Denizen stats and specifics, such as script assignments and associated bookmarks with just a crouch and a click.
 
* New! Proximity Trigger can trigger a script when a Player comes near.


* New! Location Trigger can trigger a script when a Player walks over a Location Bookmark.
{{#ev:youtube|oKTe8-joBUI|305|right|A small glimpse of Denizen.}}


* New! Damage Trigger separates the left and right clicks for more control over interaction.


* New! Overlay mode is a whole new way to assign a script. Less copying/pasting when working with multiple scripts!
For more up-to-date information and full details on specific features (individual commands or tags, for example), check the [https://one.denizenscript.com/denizen/cmds/ Meta Documentation].


* New! FLAG command lets you set 'flags', on players to store progress, important information, or other variables that can be used with the FLAG requirement.
If you want a full tutorial to help get you set up, check out the [https://one.denizenscript.com/denizen/cmds/denizen/vids Tutorial Videos] on youtube or the [https://guide.denizenscript.com/ Beginner's Guide] text website.


* New! FLAG requirement can require special flags and values to be set in order to be eligible for a script.
If you need quick help, visit our [https://discord.gg/Q6pZGSR Discord group].


* New! POWERED requirement can check if a block bookmark has redstone power.
<br><br><br>


* New! RANDOM command will leave command execution to chance.
<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>


* New! The activity engine has been implemented which will allow your Denizens to do things on their own. There's a whole lot more to this concept, but you can try out the new WANDER activity with bukkit commands or script commands.


* Updated! Extended/unified command syntax for almost every existing command.


<span style="font-size:110%">{{color|red|yellow|This is the old Wiki for Denizen 0.7.6! Information found here does not apply to later versions of Denizen.}}</span>
<s>
<br><br><br>
<span style="font-family:natalya-alternate-one; font-size:750%; margin-right:-7px; margin-left:-10px;">D</span>enizen is a great way to add [http://en.wikipedia.org/wiki/MUD MUD-style] RPG Citizens to your server. Denizen NPCs use mini scripts with steps and events to interact with the player and world. Imagine interactive gate-keepers, magical wizards, experience trainers, bankers, talking townspeople and more! They can be used in thousands of different ways, from tutorials, to questing, to administrating.. your imagination is just about the limit! Though Denizen uses Scripting, it is not to be confused with [[Scripting|Citizens2 Core Scripting]] which utilizes JavaScript and other major scripting languages to implement Goals. Instead, Denizen uses its own YML 'scripting language' which is designed to be easily read and edited by hand.


<br>
<br><br>
You can see more at the full [[Denizen changelog]].
<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;">If you are coming from Denizen 0.6, we've attempted to compile a [[Denizen/0.7/Migration|list for helping with migration]] for users upgrading who need a brief on what needs to be changed to become compatible.
</div>
</div>
== Known caveats ==
<div style="margin-right:2.0em; padding:10px">
There are some 'issues' with Denizen that we are aware of, and thought that you should be too. Keep in mind that we're working hard to fix these, as soon as possible.
* I've been having problems getting the NPCs to WALKTO a bookmarked location that is far away.
* When close to a Denizen that is RESPAWNing, it sometimes won't actually spawn until you back away from it.
* Multi-line CHATting loses color codes second line on.
</div>
</div>


== Before using Denizens ==
<div style="margin-right:2.0em; padding:10px">
Denizens are in BETA! Expect a few bugs here and there! There is little error handling for scripts that contain bad syntax, so if you are getting errors while processing a script, the first thing you should do it check the script syntax. I'm working hard to catch errors, but every once in awhile you'll find one that requires a /reload or server restart. If you do come across any errors beyond bad syntax, please  report them to the [http://www.github.com/aufdemrand/Denizen/issues Github Issues page for Denizens]. You can also get assistance with Denizens on the [irc://irc.esper.net #citizens IRC channel on EsperNET] from me (aufdemrand) when available. I'm usually there working hard to add awesome features and squashing bugs.


Denizen is not a drag-and-go type of plugin. In fact, Denizen won't do anything unless you assign and define scripts to NPCs. It's highly customizable and you should expect that to be able to write scripts, it is suggested you read the entirety of this wiki document. I'm always around IRC to help out, but please don't ask about the basics unless you have consulted here first.
<div style="padding:10px; font-family:camingodos-web; font-size:110%;">
===How it works===
Denizen is an extension of Citizens2 that adds an incredible amount of interactivity and automation to NPCs and Players with some of these major features:


Denizens '''REQUIRES''' you to have [http://dev.bukkit.org/server-mods/vault/ Vault] installed. You also should have a Permissions System and and Economy System for best results.
* '''The Script Engine''' carries out and sends all the commands to be executed in an orderly and predictable fashion; this is the backbone of Denizen. Currently has 3 queues, one for the Player, one for Denizen, and one for Tasks. There's not much to see on the outside, this is the interworkings of Denizen, but rest assured that this is high performance machine behind the scenes!
</div>
* '''Interact Scripts''' are the meat of Denizen, allowing Players and NPCs to interact with each other and the world. These are highly customizable with 20+ requirement types, 40+ script commands, and thousands of different ways to use them together. This with the Denizen Script Engine also allows commands to help control the rest of Denizen with script flow commands and such.
* '''Activity Scripts''' are exciting. Imagine Johnny Appleseed planting trees, on his own, or simple villagers wandering around and socializing. Activities, of course, work with the rest of Denizen's other functions and features, allowing hundreds of ways to use Activities to add automation and liveliness to your world.
* '''Activity Scheduler''' takes Activity Scripts one step further, allowing Denizen NPCs to have daily schedules, based on the Minecraft day, to allow certain functionality to different times of the day. This also enables certain Script Commands to be executed and carried out, as well.
* '''Task Scripts''' are simple scripts that can be carried out in a variety of different ways. These can be used along side both Activity and Interact Scripts, but perhaps the most powerful way to use them is by allowing your plugin to utilize them, if you're a developer, or using other plugins that harness the ability to run a Denizen Task Script as well.
* '''Listeners''' are currently in an 'experimental phase', but are already allowing control over minecraft and bukkit events like nothing other. This already allows scripts to keep track of and assign 'quest-like' objectives, such as a 'kill quest', if you're familiar with the C1 Quester. But whereas many quest plugins are limited to this feature alone, Denizen, of course, allows you to use this in addition and along side the rest of the plugin, making room for extremely dynamic and intricate 'quest scripts'.
* '''Flag System''' is the key to Denizen being dynamic. An intricate, yet easy to learn 'Flag/Variable' system has been implemented into Denizen to help keep track of events, items, numbers, players, and more. The new Flag System is still getting more powerful each and every day.. it's the key to a spectacular script is sure to have a flag or two.
* '''Extensible Commands/Requirements/Activities and more''' make it easy to add-on to Denizen with very little Java knowledge. This also makes it extremely easy to let users utilize your plugin with script commands. Denizen also has API Events to use.
* '''Denizen Debugger'''' is an extremely friendly and informative way to test out scripts and interactions. Commands, events, and interactions are all logged in an easy to read format to show the exact progression of a script and its surroundings. No more guessing! Less headaches!


== Getting started with Denizen ==
<div style="margin-right:2.0em; padding:10px">
The easiest way to use Denizen for the first time is to download the [http://dl.dropbox.com/u/44002922/Start-up%20Kit.zip Start-up Kit] with sample .yml configuration files and scripts. This includes the default config file, sample scripts, and sample assignments to get you started. Denizen relies on a few files to run properly, so let's first go over the file structure.
</div>


=== File Structure ===
Seem overwhelming? Stop! Start small! Denizen is easy, Denizen is simple. But. Denizen is hard, Denizen is complex. Simply put: Denizen is what you make it! Our advice? Start small, and build upon what you have. Read the wiki articles, watch the youtube videos, test our your scripts, and test out some of the sample scripts! Before you know it, you'll be a Denizen poweruser, drunken with power, just like us!
[[File:Figure 1 - Denizen file structure.png|250px|thumb|right|Denizen File Structure]]
<div style="margin-right:2.0em; padding:10px">
Denizen requires the use of a few different YML files to operate properly. This includes a config.yml, assignments.yml, scripts, and saves.yml.
</div>
</div>


==== config.yml ====
<div style="margin-right:2.0em; padding:10px">
The Denizen config.yml contains nodes to alter the stock behavior and look of Denizen. You'll notice that Denizen does not create its own config.yml. Why is this? Denizen stores its entire config inside memory, so it's not necessary to have a copy inside the Denizen folder unless you need to change the defaults. You can use the config.yml to override those defaults. Not having Denizen write to the config.yml itself (as well as scripts files, and assignments.yml) ensures that upon a <code>/denizen reload</code>, the config.yml, between a save and reload, is never changed when you don't want it to. This also keeps code comments inside the YML files stay intact, exactly the way you left them from last edit allowing you to leave yourself and others detailed notes and ideas.


This file can be reloaded into from disk to Denizen memory at any time by using <code>/denizen reload</code>.
<div style="margin-right:2.0em; padding:10px; font-family:camingodos-web; border-style:none; font-size:110%; font-weight:500;width:100%;border-width:0px;">


See: [[Denizen config.yml]] for a stock copy and explanation of all available options.
=Denizen=
If you are new to Denizen, see [[Denizen/0.7/Before Using Denizen|Before Using Denizen: Getting Started]].
<br>If you are having problems getting a script working please see [[Denizen/0.7/Troubleshooting|Troubleshooting]].<br>
If you're hooked, we recommend you read all the sections in order and try out some sample scripts!
</div>
</div>
{|class="wikitable" style="text-align: left; border-color:white; border-style:none; vertical-align: text-top; background-color:white;"
|- style="vertical-align:top;"
| style="width: 60%;" |
<div style="vertical-align: text-top; padding:16px; border-style:none; border-color:white;font-family:camingodos-web; font-size:110%; font-weight:500;width:85%;border-width:0px;">
===Table of Contents===


==== assignments.yml ====
# [[Denizen/0.7/Before Using Denizen|Before Using Denizen & Getting Started]]
<div style="margin-right:2.0em; padding:10px">
#* [[Denizen/0.7/Start-up kit|The Start-up Kit]]
This YML is where you can define all the options and information for your Denizen NPCs. This will be explained further along in this document, but the most common information in this file is [Interact Script Assignments], [Activity Script Schedule], and [Custom Interact Texts].
# [[Denizen/0.7/Troubleshooting|Denizen Troubleshooting]]
 
# [[Denizen/0.7/File_Structure|The File Structure]]
This file can be reloaded from disk into Denizen memory at any time by using <code>/denizen reload</code>.
#* [[Denizen/0.7/config.yml|Default config.yml]]
 
# [[Denizen/0.7/In Game Commands|In Game and Console Commands]]
See: [[#A basic assignment]] for information on how to get started with assignments.
# Writing Scripts
#* [[Denizen/0.7/Interact Scripts|Introduction to Interact Scripts]]
#** [[Denizen/0.7/Interact Scripts/Triggers|Interact Triggers]]
#** [[Denizen/0.7/Interact Scripts/Interact Requirements|Interact Script Requirements]]
#** [[Denizen/0.7/Interact Scripts/Commands|Script Commands]]
#* [[Denizen/0.7/Task Scripts|Task Scripts and the Task Queue]]
#* [[Denizen/0.7/Activity Scripts|Activity Scripts and the Scheduler]]
#** [[Denizen/0.7/Activity Scripts/Activities|Activities and Goals]]
# [[Denizen/0.7/Assignments|Assigning Scripts]]
# [[Denizen/0.7/Flags|Denizen Flag System]]
# [[Denizen/0.7/Replaceables|Replaceable Data Tags]]
# [[Denizen/0.7/Listeners|Denizen Listeners and Events]]
# Examples
#* [[Denizen/0.7/Example Scripts/Beginner Scripts|Beginner Scripts]]
#* [[Denizen/0.7/Example Scripts/Advanced Scripts|Advanced Scripts]]
#* [[Sentry/Sentry and Denizen|Denizen and Sentry]]
#* [[Sentry/Builder and Denizen|Denizen and Builder]]
# Extending Denizen
#* [[Denizen/0.7/Interact Scritps/Custom_Commands|Extending Custom Commands]]
#* [[Denizen/0.7/Interact Scripts/Custom_Requirements|Extending Custom Requirements]]
#* [[Denizen/0.7/Interact Scripts/Custom_Triggers|Extending Custom Triggers]]
#* [[Denizen/0.7/Activity Scripts/Custom_Activities|Extending Custom Activities]]
#* [[Denizen/0.7/Activity Scripts/Event_API|Utilizing Denizen Event API]]
# Bonus Content
#* [[Denizen/0.7/Bonus Content/Pictures|Denizen Bonus Pictures]]
</div>
</div>
| style="width: 40%;" |


==== saves.yml ====
<div style="padding:16px; vertical-align: text-top;border-color:white; border-style:none; font-family:camingodos-web; font-size:110%; font-weight:500;width:95%;border-width:0px;">
<div style="margin-right:2.0em; padding:10px">
This file is not meant to be edited by hand, Denizen will create and populate this file automatically as needed. It stores important information such as player progression, Denizen location and block bookmarks, active activity script progression and more. If you absolutely need to make changes by hand, it's best to stop the server, edit, and then restart your server, as this file is constantly being written to by Denizen which will overwrite any changes you make.


This file saves periodically, and automatically, upon progression and a server stop.
===Sample Scripts===
</div>


==== read-only-scripts.yml ====
[[Denizen/0.7/Example_Scripts/Beginner_Scripts#Denizen_Basics|Denizen Basics]]
<div style="margin-right:2.0em; padding:10px">
* [[Denizen/0.7/Example_Scripts/Beginner_Scripts#Denizen_Basics|The Click and Damage Triggers]]
This is another files that Denizen creates and should not be edited by hand. This is a combination of the files contained in the scripts folder that Denizen reads from.  
* [[Denizen/0.7/Example_Scripts/Beginner_Scripts#Denizen_Basics|The Chat and Proximity Triggers]]
[[Denizen/0.7/Example_Scripts/Beginner_Scripts#Simple,_random_conversations|Simple, random conversations]]
* [[Denizen/0.7/Example_Scripts/Beginner_Scripts#A_conversation_with_RANDOM|A conversation with RANDOM]]
* [[Denizen/0.7/Example_Scripts/Beginner_Scripts#A_conversation_with_ZAP_RANDOM|A conversation with ZAP RANDOM]]
* [[Denizen/0.7/Example_Scripts/Beginner_Scripts#The_server_rules|The Server Rules]]
* [[Denizen/0.7/Example_Scripts/Beginner_Scripts#Simple_Bank_teller|Simple Bank Teller]]
* [[Denizen/0.7/Example_Scripts/Beginner_Scripts#Advanced_Bank_teller|Advanced Bank Teller]]


This file is populated on a server restart, or by using the <code>/denizen reload</code> command.
</div>
</div>
| style="width: 20%;" |


==== /scripts/ folder ====
<div style="padding:16px; vertical-align: text-top;border-color:white; border-style:none; font-family:camingodos-web; font-size:110%; font-weight:500;width:95%;">
<div style="margin-right:2.0em; padding:10px">
This folder is where Denizen will read all the script information from. Upon a server load or <code>/denizen reload</code>, the files are combined and put into the read-only-scripts.yml for the Denizen to read from. This allows better organization of scripts to be maintained, since the amount of scripts can easily get into the triple digits.


The files in the plugins/Denizen/scripts/ folder can be named whatever you please, as long as they end in <code>.yml</code>. Be sure not to duplicate script names from file to file as this will cause problems.
===Index===


See: [[#A basic trigger script]] for information on how to get started with scripts.
If you are having problems getting a script working please see [[Denizen/0.7/Troubleshooting|Denizen/Troubleshooting]].
</div>
</div>
|}


== Writing Scripts and Assignments ==
=== Change Log ===
<div style="margin-right:2.0em; padding:10px">
<div style="margin-right:2.0em; padding:10px; font-family:camingodos-web; font-size:110%;">
Still reading? Great! You're on your way to writing some sweet scripts. Let's start out with the basics: Trigger Scripts and Assignments. Denizen needs two things to be functional. A script, and an assignment. Scripts, obviously, hold instructions that are carried out when triggered. Assignments hold information on which scripts should trigger, and when. Bear with me, and keep reading!
Here's what's changed!
</div>
 
==== A basic trigger script ====
<div style="margin-right:2.0em; padding:10px">
First, we need a script. The great thing about a Denizen script is that it can be simple or advanced, short or long, thanks to a wide array of commands and functions at your disposal. Scripts can work with, extend, and rely on one another to create rich, interactive gameplay. Each script has at least 2 parts, Requirements and Steps. For now, let's take this very simple script as an example. We'll get more detailed later on.
 
Remember: Scripts are defined in <code>plugins/Denizen/scripts/</code> folder. They can be put into any YML file contained in that directory. You may need to create the directory yourself if no scripts yet exist.
 
<pre>
'Daytime in the City': 
  Type: Trigger
  Requirements:
    Mode: All
    List:
    - TIME Day
  Steps:
    1:
      Click Trigger:
        Script:
        - CHAT Welcome to the city! Isn't it beautiful in the daytime?
</pre>
 
So what just happened there? A quick literal translation: This script is named <code>'Daytime in the City'</code>. This name is used when assigning Denizen NPCs their scripts to use. When the script is called by a trigger, in this case a <code>'Click Trigger'</code>, for it to activate the Requirements set must be met, more specifically <code>ALL</code> of the requirements set. In this example, the only requirement is <code>TIME DAY</code> which requires the current time in the world to be daytime. If the Requirements are met, the script defined in the <code>'Click Trigger'</code> is sent to be run. It will have the Denizen NPC chat to the player 'Welcome to the city! Isn't it beautiful in the daytime?'.
 
But before the script can be triggered, it needs to be assigned.
</div>


==== A basic assignment ====
<div style="margin-right:2.0em; padding:10px">
In order for a Denizen to be associated with a script, he needs to be assigned to it. The following shows a simple assignment format.


Assignments are defined in the Denizens node found in plugins/Denizen/assignments.yml and must be done by hand. Once you edit the config.yml, immediately save and use /denizen reload in-game.
'''0.7.5 BETA build #455'''


<pre>
* {{color|red|white|'''New!'''}} OWNER requirement will require ownership of the NPC interacting. Could be used for 'command interfaces' that only the owner can access.
Denizens:                       
  'Steve':                       
    Interact Scripts:                     
    - 10 Daytime in the City 
    Texts:
      No Requirements Met: 'Come back during the day!'
</pre>


Let's break this down again. This assignement will work for Denizens named <code>'Steve'</code>. Triggers that involve this NPC, such as a <code>'Click Trigger'</code> will call the script named <code>'Daytime in the City'</code>. The <code>10</code> before the name is the script priority, useful when assigning multiple scripts, but we'll get into that next. If no scripts meet requirements (in this case -- if it's NOT daytime when clicking on Steve), the text defined in the <code>Texts:</code> node called 'No Requirements Met' will trigger instead. So to reiterate, if the player clicks on Steve during the daytime, the player will get a chat containing 'Welcome to the city! Isn't it beautiful in the daytime?' If the player clicks during the nighttime, since the script requirements are not met, the player will see a chat containing 'Come back during the day!'. Note that the default <code>No Requirements Met</code> text can be changed in the <code>config.yml</code>.
* {{color|red|white|'''New!'''}} SNEAKING requirement requires the player be crouched when clicking. Careful on conflict with info-click for ops! Info-click can be disabled in the config.
</div>


==== Multiple Script Assignments ====
* {{color|red|white|'''New!'''}} Queue-time flag replacement can let you dynamically use flag data in a script entry. For example: - GIVE <FLAG:ExampleItemFlag> QTY:<FLAG:ExampleQtyFlag>
<div style="margin-right:2.0em; padding:10px">
The key to Denizens being dynamic is their ability to handle multiple scripts in different situations. This is done by assigning a priority to script assignments. Let's take this example configs below to see how script priority is handled. The below code references <code>assignments.yml</code> and a <code>script.yml</code>.


<pre>
* {{color|red|white|'''Experimental!'''}} Denizen NPCs now have their own Command Queue, and a TASK activity. This allows NPC's to use the activity scheduler to do tasks at certain times of the day.
---- assignments.yml ----


Denizens:                       
* {{color|red|white|'''Experimental!'''}} LISTEN command implemented, KILL type implemented. Return of the 'Quester'. More types coming soon. Example usage: - LISTEN KILL ID:UniqueId TYPE:ENTITY NAME:ZOMBIE QTY:5 SCRIPT:FinishIt would require the player to kill 5 zombies. When completed, it will run the task script 'FinishIt'.
  'Steve':                      
    Interact Scripts:                    
    - 0 Regular Joe
    - 10 Joe the Builder 


---- script.yml ----
* {{color|red|white|'''New!'''}} Use <*> to use Chat Trigger text in EXECUTE or talk commands.


'Regular Joe':
* {{color|red|white|'''New!'''}} Use <*> in FLAG command to remember player input. Example usage: - FLAG PLAYER_RESPONSE:<*>
  Type: Trigger 
  Requirements:
    Mode: None
  Steps:
    1:
      Click Trigger:
        Script:
        - CHAT Hello <PLAYER>! I supply builders only!


'Joe the Builder':
  Type: Trigger 
  Requirements:
    Mode: All
    List:
    - PERMISSION modifyworld.*
  Steps:
    1:
      Click Trigger:
        Script:
        - ENGAGE
        - CHAT Hello <PLAYER> the Builder! Take this shovel!
        - GIVE WOOD_SPADE 1
        - FINISH
        - DISENGAGE
</pre>


Denizen <code>Steve</code> has been assigned two scripts. Upon player interaction, each script is checked for met requirements. If only one script has their requirements met, it's clear what script will be returned. But what if both meet requirements? That's where the number before each script assigned comes in. Higher priority always wins. To break down this specific situation, if a player with the 'modifyworld.*' permission clicks on Steve, both scripts meet the requirements, but since the script 'Joe the Builder' has a priority of 10, and 'Regular Joe' only has a priority of 0, 'Joe the Builder' sends its script. 'Regular Joe' is simply ignored. Denizens can be issued as many scripts as you want.  If two scripts have the same priority, the first in the list will be the one to trigger, if both scripts meet their requirements.
'''0.7.5 BETA build #440:'''
</div>


==== Things to Note, Thus Far ====
* {{color|red|white|'''New!'''}} API Events make extending Denizen more powerful than ever!
<div style="margin-right:2.0em; padding:10px">
Denizens with the same name use the same script assignments. The plus to this is the ability to quickly make 'generic NPCs' such as a 'Townsman' or 'Miner'.


All the scripts and configuration nodes are in YAML. Remember! Spacing is CRITICAL when dealing with YAML files. Each parent node and sibling node should follow the spacing and formatting guidelines set forth by the YAML 1.0 standard.
* {{color|red|white|'''New!'''}} RUNTASK/CANCELTASK allows delayed tasks to be set, and cancelled.


In all the examples used in this guide, 2 spaces are used for indenting.  Generally, whatever you choose should be maintained through your YAML document. No tabs are allowed in YAML files.
* {{color|red|white|'''New!'''}} HOLD command can change what a Denizen NPC is wielding.


In the YAML files, nodes are case sensitive! 'Scripts:' will work. 'scripts:' will not! All nodes are first letter capital, rest of the word lowercase. Scripts names follow this rule too!  
* {{color|red|white|'''New!'''}} Replaceable data for dynamically putting flags into texts!


YAML tutorials can be intimidating, but [http://wiki.ess3.net/wiki/YAML_Tutorial this small tutorial on the Essentials wiki] is pretty useful for basic YAML, which is the extent of which Denizens uses.
* {{color|red|white|'''New!'''}} ISLIQUID requirement can sense if a block bookmark is solid, or liquid.
</div>
 
== Assignments in Detail ==
<div style="margin-right:2.0em; padding:10px">
In addition to handling the script assignments, there are also a few other things that will be declared in the Denizens node of assignments.yml. This section will update as functionality requires.
</div>


== Trigger Scripts in detail ==
* {{color|red|white|'''New!'''}} IF command can evaluate a FLAG and run a TASK script.
<div style="margin-right:2.0em; padding:10px">
The general structure of a script should always include the 'Name', 'Type', 'Requirements', and 'Steps' nodes. These are required.


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.
</div>


==== General layout of a Trigger Script ====
'''0.7 BETA builds #125 - #280:'''
<div style="margin-right:2.0em; padding:10px">
<pre>
'Name of script':  # Name Node
  Type: Trigger    # Type Node
  Requirements:    # Requirements Node
    ...:
    ...:
      - ...
      - ...
  Steps:            # Steps Node
    ...:
      - ...
    ...:
  Options:          # Options Node
    ...:
</pre>
</div>


==== Name Node ====
* {{color|red|white|'''Updated!'''}} Less bugs! We're still in beta, but there has been some major code cleanup!
<div style="margin-right:2.0em; padding:10px">
This node is pretty self-explanatory, but here are some things to keep in mind.
* Names, just like nodes are case-sensitive! <code>'This script name'</code> is different than <code>'THIS SCRIPT NAME'</code>.
* Names that contain spaces must have single or double quotes around it. ie: <code>"This script":</code> or <code>'This script':</code> 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: <code>"John's Script":</code> or <code>'John<nowiki>''</nowiki>s Script':</code>
</div>


==== Type Node ====
* {{color|red|white|'''New!'''}} Triggers, Commands, Requirements and Activities are now extensible by plugin programmers. See: [http://wiki.citizensnpcs.net/Custom_Denizen_Commands Custom Denizen Commands on the Citizens2 Wiki]. Documentation coming soon!
<div style="margin-right:2.0em; padding:10px">
Let's Denizen know the type of script. For trigger scripts, as explained in this section, use <code>TYPE: TRIGGER</code>.
</div>


==== Requirements Node ====
* {{color|red|white|'''New!'''}} [[#Debug_Mode|Debug Mode]] will let you see the logic of interaction and script execution to help you find problems in scripts faster than ever. I'm striving to make this as informational and clean as possible to help you test your scripts and get good feedback on behavior.
<div style="margin-right:2.0em; padding:10px">
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:


<pre>
* {{color|red|white|'''New!'''}} [[#Info-click|Info-Click]] lets you see Denizen stats and specifics, such as script assignments, trigger status, activity schedule and associated bookmarks with just a crouch and a click. Requires OP.. use this!
  Requirements:
    Mode: All
    List:
    - TIME Night
    - MONEY 1000000
    - STORMY
</pre>


This would be a difficult script to obtain, for sure. To trigger, the time would have to be after 16000, but before 0, the player would need one million dollars on hand (or whatever economy you use), 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.
* {{color|red|white|'''New!'''}} [[#Proximity_Trigger|Proximity Triggers]] can trigger a script when a Player comes near. The most requested trigger type I got during the previous betas.
</code>
</div>


===== Mode Types =====
* {{color|red|white|'''New!'''}} [[#Location_Trigger|Location Triggers]] can trigger a script when a Player walks over a Location Bookmark. This is kind of like a PLAYERTASK LOCATION, but better! :)
<div style="margin-right:2.0em; padding:10px">
<code>[] indicates required field


* ALL
* {{color|red|white|'''New!'''}} [[#Damage_Trigger|Damage Triggers]] separate the left and right clicks for more control over interaction. Look forward to a whole new set of commands to go along with this!
*: </code>Requires all requirements listed to be met.<code>
* ANY [#]
*: </code>Requires the specified number of requirements to be met, out of the total of requirements listed.<code>
* NONE
*: </code>Requires NO requirements to be met.<code>
</code>
</div>


===== Requirements Types =====
* {{color|red|white|'''New!'''}} [[Denizen/Assignments#Overlay_Assignment_Mode|Script 'Overlay' Assignment]] mode is a whole new way to assign a script. Less copying/pasting when working with multiple scripts, not to mention more control! If you're an advanced script-user, this is for you!
<div style="margin-right:2.0em; padding:10px">
<code>[] indicates required field, () indicates an optional field, OR indicates alternative usage.


* NAME [Player Name] (or this Player Name) ...
* {{color|red|white|'''New!'''}} [[#Interact Script Commands|ANNOUNCE command]] can make global server announcements.
*: </code>Requires a specific player.<code>


* ITEM <nowiki>[</nowiki>[[ITEM_NAME|#:#]]<nowiki>]</nowiki> (# of that item, or more)
* {{color|red|white|'''New!'''}} [[#Interact Script Commands|RANDOM command]] will leave command execution to chance. Duck-duck-goose.
*: </code>Requires the player to have an item in their inventory. You can also specify an amount.<code>


* WEARING <nowiki>[</nowiki>[[ITEM_NAME|#]]<nowiki>]</nowiki>
* {{color|red|white|'''New!'''}} [[#Interact Script Commands|HINT command]] will hint to the Player acceptable Chat Triggers for the current step and script. Language support coming soon!
*: </code>Requires the player to be wearing a specific piece of armor.<code>


* HOLDING <nowiki>[</nowiki>[[ITEM_NAME|#:#]]<nowiki>]</nowiki> (# of that item, or more)
* {{color|red|white|'''New!'''}} [[#Interact Script Commands|FLAG command]] lets you set 'flags', on players to store progress, important information, or other variables that can be used with the FLAG requirement. This is HUGE!
*: </code>Requires the player to have an item in their hand. You can also specify an amount.<code>


* TIME [Day|Night|Dusk|Dawn]  OR  TIME [0-23999] [1-24000]
* {{color|red|white|'''New!'''}} [[#Requirement Types|FLAG requirement]] can require special flags and values to be set in order to be eligible for a script. Again, this is HUGE!
*: </code>Requires day or night. Alternatively you can specify a time window.<code>


* HUNGER [Full|Hungry|Starving]
* {{color|red|white|'''New!'''}} [[#Requirement Types|POWERED requirement]] can check if a block bookmark has redstone power. Great idea, instinx!
*: </code>Requires a specific hunger state.<code>


* PRECIPITATION
* {{color|red|white|'''New!'''}} The activity engine has been implemented which will allow your Denizen to do things on their own. There's a whole lot more to this concept, but you can try out the new WANDER activity in all its glory. This thing is cool, and customizable!
*: </code>Requires a rain or snow.<code>


* SUNNY
* {{color|red|white|'''New!'''}} [[#In-game_Commands|In-game commands]] now let you easily manage triggers, bookmarks, and debug info.
*: </code>Requires clear skies. Note: This can still trigger at night as it does not check time.<code>


* WORLD [World Name] (or this World Name) (or this World Name) ...
* {{color|red|white|'''Updated!'''}} Extended/unified command syntax for almost every existing command. Once you get over the pain of upgrading, you will drop a jaw at the new capabilities!
*: </code>Requires the player to be in a specific world, or worlds.  You can check as many as you'd like with one line.<code>


* PERMISSION [this.permission.node] (or this permission.node) ...
<br>
*: </code>Requires one of the listed permission nodes. Only one is required. If you require multiple permission nodes, use multiple entries.<code>
You can see more at the full [https://github.com/aufdemrand/Denizen/commits/master Denizen Changelog].
 
* LEVEL [This Level # or higher]  OR  LEVEL [At least this Level #] [But no more than this Level #]
*: </code>Requires a specific Minecraft XP level, or a range of levels.<code>
 
* FINISHED (# of times) [Script Name]
*: </code>Requires a specific script to be <code>FINISH</code>ed. Remember: Script names are case-sensitive! You can specify a certain number of times, as well. Using this as a negative requirement is a good way to put a limit on how many times a player can do a script.<code>
 
* FAILED [Script Name]
*: </code>Requires a specific script to be <code>FAIL</code>ed. Remember: Script names are case-sensitive!<code>
 
* GROUP [Name of Group] (or this Group) ...
*: </code>Requires the player be a member of a group. Requires a Permissions system that allows groups, such as PermissionsEX.<code>
 
* MONEY [Amount of Money, or more]
*: </code>Requires the player to have at least a certain amount of money on hand. Requires an economy system, such as iConomy.<code>
 
* POTIONEFFECT [POTION_EFFECT]
*: </code>Requires the player to be under the influence of a specific potion. You can use 'ANY' to specify the player just be under the influence of a potion, without being specific as to which type.
</div>
 
===== Negative Requirements Types =====
<div style="margin-right:2.0em; padding:10px">
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 overlaps, such as '-WEATHER Precipitating' and 'WEATHER Sunny' technically being the same thing. If anything, it can add to script readability.
 
<pre>
  Requirements:
    Mode: All
    List:
    - -TIME Night
    - -MONEY 1000000
    - -STORMY
</pre>
 
Negative requirements completely change our original example around. For this script to trigger, time needs to be Day, the weather in the current world must NOT be storming, and the player must not have more than 1000000 units of currency on them.
</div>
 
==== Steps Node ====
<div style="margin-right:2.0em; padding:10px">
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.
 
<pre>
'Welcome to Harbortown':
  Type: Trigger
  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?
</pre>
 
The sub-sections below reference this example.
</div>
 
===== Trigger Types =====
<div style="margin-right:2.0em; padding:10px">
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 clicked on.
 
<pre>
Click Trigger:
  Script:
  - CHAT Scripts are nested as a list.
  - CHAT You can use any command that
    you'd wish.
</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 <code>
 
<pre>
Chat Trigger:
  '1':
    Trigger: The word needed to /Trigger/ is inside slashes.
    Script:
    - CHAT Scripts are nested as a list.
    - CHAT You can use any command that
      you'd wish.
</pre>
</code>
For a list of commands, see [[#Script Commands]]
</div>
 
== Task Scripts in detail ==
<div style="margin-right:2.0em; padding:10px">
Task scripts are script that are called by either the RUNTASK command or PLAYERTASK command. These are more basic than trigger scripts since they have no requirements or step nodes. The types of commands are also more limited since there is no NPC Denizen associated with the script, but useful for certain situations.
</div>
 
==== General layout of a Trigger Script ====
<div style="margin-right:2.0em; padding:10px">
<pre>
'Name of script':  # Name Node
  Type: Task        # Type Node
  Script:          # Script Node
  - ...
  - ...
</pre>
</div>
 
==== Using a Task Script with RUNTASK ====
<div style="margin-right:2.0em; padding:10px">
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!
 
<pre>
'Apple Reward':
  Type: Task   
  Script:     
  - NARRATE You've received some APPLES. Nice!
  - GIVE APPLE 10
  - FINISH
 
'Apple Quest 1':
  Type: Trigger
  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: Trigger
  Requirements:
    Mode: All
    List:
    - -FINISHED Apple Reward
  Steps:
    '1':
      Click Trigger:
        Script:
        - CHAT Welcome to my orchard, have some apples!
        - RUNTASK Apple Reward
</pre>
</div>
 
==== Using a Task Script with PLAYERTASK ====
<div style="margin-right:2.0em; padding:10px">
Tasks scripts are very straight forward when using with a PLAYERTASK command. The script that is called when the 'player task' is complete is a Task script.
 
<pre>
'Graveyard Investigation':
  Type: Trigger
  Requirements:
    Mode: NONE
  Steps:
    '1':
      Click Trigger:
        Script:
        - CHAT Go investigate the graveyard for me!
        - PLAYERTASK LOCATION graveyard 20 120 Graveyard Search
 
'Graveyard Search':
  Type: Task   
  Script:     
  - NARRATE You are thoroughly spooked out. Maybe you should return to Dave.
  - FINISH
 
'Graveyard Investigated Complete':
  Type: Trigger
  Requirements:
    Mode: All
    List:
    - FINISHED Graveyard Search
  Steps:
    '1':
      Click Trigger:
        Script:
        - CHAT Ahhh, dang. You couldn't find anything? Ah well, thanks for your help!
</pre>
 
== Script Commands ==
<div style="margin-right:2.0em; padding:10px">
Note: There are plenty more to come, be patient, more are coming! Have ideas for a good command? Let me know!
 
<code>[] indicates required field, () indicates an optional field, OR indicates alternative usage.
 
* ZAP (Step #)
*: </code>Progresses the player through the steps. ZAP used alone will progress to the next step. ZAP with a number following will progress the player to a specific step.<code>
 
* FINISH
*: </code>Marks the script as completed to check against with the requirement type 'FINISHED'.<code>
 
* ENGAGE
*: </code>Blocks player interaction from triggering the NPC.<code>
 
* DISENGAGE
*: </code>Opens the NPC back up to player interaction.<code>
 
* PLAYERTASK LOCATION [Location Bookmark] [Duration in seconds] [Block leeway] [Task Script to trigger]
*: </code>Starts a player task to the Denizen's location bookmark in which the player must stay within a certain amount of blocks (Block Leeway) for a specific duration. Once accomplished, a Task Script is called.<code>
 
* FAIL
*: </code>Marks the script as failed to check against with the requirement type 'FAILED'. Note: A script can be both completed and failed!<code>
 
* RESET [FINISHED|FAILED] [Name of Script]
*: </code>Sets either FINISHED or FAILED of the specified script to False. Remember: Script names are case sensitive!<code>
 
* WAIT [# of seconds]
*: </code>Will hold a player's Command Que for a specific amount of seconds. You can use this to put delays in your script. All lines of a script after the hold will execute after the time has passed.<CODE>
 
* LOOK [CLOSE|AWAY] or LOOK [Location Bookmark]
*: </code>Toggle 'lookclose' on the Denizen. Alternate use specifies a pitch/yaw from a Location bookmark.<code>
 
* GIVE [ITEM_NAME] (Quantity)
*: </code>Denizen will drop specified items.<CODE>
 
* TAKE [ITEM_NAME|MONEY] (Quantity)
*: </code>Takes specific item or money from the player.<CODE>
 
* CHAT [The text to chat.]
*: </code>Makes the Denizen talk to the player. Long messages will be formatted for multiple lines automatically.<code>
 
* NARRATE [The text to narrate.]
*: </code>Sends text to the player without branding the Denizen. Long messages will be formatted for multiple lines automatically.<code>
 
* FOLLOW [PLAYER|NOBODY]
*: </code>Makes the Denizen follow the player, or stop following the player.<code>
 
* WALKTO [Location Bookmark]
*: </code>Makes the Denizen walk to a specified location.<code>
Note: I've been having problems getting the NPCs to WALKTO a bookmarked location that is far away, perhaps in a different chunk? Working on it with the C2 team. I may have another workaround as well.
 
* WALK [Z] [X] [Y]  Note: Z(-NORTH(2)/+SOUTH(0)) X(-WEST(1)/+EAST(3)) Y (+UP/-DOWN)
*: </code>Makes the Denizen walk. This is not for making the Denizen to specific coordinates. The values for X Y and Z will get added or subtracted from the Denizen's current location.<code>
 
* RETURN
*: </code>Can be used after initiating a WALK command.  This will make the denizen return to its previous location.<code>
 
* EXECUTE [ASPLAYER|ASNPC|ASSERVER] [command to execute]    Ex: EXECUTE ASSERVER toggledownfall
*: </code>Executes a command, issues from either the Player, NPC, or Server. No need for a /.<code>
 
* STRIKE
*: </code>Strikes the player with lightning.<CODE>
 
* WEATHER [Sunny|Stormy|Precipitating]
*: </code>Sets the weather for the world.<CODE>
 
* RESPAWN [Location Bookmark]
*: </code>Despawns the Denizen and respawns it to a bookmarked location.<CODE>
Note: There is something funny going on with NPCs spawning to a location you are very near to. You sometimes have to back away before they show up. This seems to be an issue with Craftbukkit and/or Minecraft Server.
 
* TELEPORT [Location Bookmark]
*: </code>Teleports the player interacting to the Denizen's specified Location Bookmark/ <code>
 
* SPAWN [ENTITY_TYPE] [AMOUNT] (Location Bookmark)
*: </code>Spawns a specified amount of entities. If the location bookmark is missing, they will spawn near the Denizen.<CODE>
 
* PERMISS [permission.node.to.add]
*: </code>Gives to the player interacting the specified permission node for the current world.<CODE>
 
* REFUSE [permission.node.to.take]
*: </code>Takes from the player interacting the specified permission node for the current world.<CODE>
 
* CAST [POTION_TYPE] [Duration in seconds] [Amplifier]
*: </code>Gives the player interacting a potion effect. Note: [[Alchemist#Valid_Effects | Valid potion types are the same as the Alchemist's.]] Amplifier specifies 'level, strength, or duration', depending on the type of potion effect. Try 1-5 for most types.<CODE>
 
* SWITCH [Block Bookmark]
*: </code>If a lever is found at the block location, it will be switched ON or OFF.<CODE>
 
* PRESS [Block Bookmark]
*: </code>If a button is found at the block location, it will be pressed. Note: You may need a - WAIT 1 and a 2nd - PRESS [Block Bookmark] or the Denizen will hold the button.<CODE>
</code>
</div>
</div>


== Denizen in-game bukkit commands ==
__NOTOC__
<div style="margin-right:2.0em; padding:10px">
<code>/denizen reload|save</code>
* Reloads|saves the config.yml and scripts.yml. Useful for testing scripts without rebooting your server.


<code>/denizen bookmark location [name]</code>
[[Category:Denizen 0.7]]</s>
* Stores a location to the selected Denizen for use with script commands such as RESPAWN and WALKTO. Note: Names can only be one word, and are unique to the Denizen.
 
<code>/denizen bookmark block [name]</code>
* Stores the Player crosshair's block location to the selected Denizen for use with script commands such as SWITCH. Note: Names can only be one word, and are unique to the Denizen.
 
<code>/denizen adddata|decdata|getdata</code>
* Nothing to do with Denizens, really, but handy for checking/switching block data. Try it on a tree.
 
<code>/denizen version</code>
* Gives you an approximation of what build you are using. I'll probably ask you this if you come to #citizens for any tech support.
</div>

Latest revision as of 16:07, 24 March 2020

Denizen.png

Denizen is an extension for Citizens that allows scripting of NPCs to handle tasks, quests, player interaction and more!

Current Version: 0.7.6 Pre-release BETA

Developers: aufdemrand

Source: Github

Development Builds: Jenkins

Latest Developmental Build: 2.0.2

Support tickets: Tickets on Github, but please read the entirety of this document first.

Donate: A lot of man hours has been put into Denizen. Your donations add a lot to the project and are always welcome! Your donations will probably help remodel my house and feed my kids. :) Donate to aufdemrand Don't forget to donate to the Citizens2 project as well, as none of this would be possible without that!

Thank You: A lot of people have stepped forward to help out with Denizen, and that's awesome! Special thanks to everyone who has beta tested, and a huge to these people: fullwall, AgentKid, aPunch, NeonMaster, Instinx, tenowg, groggluebutt, Wreyth, jrbudda, spidi, the list could go on!

CitizensUI: For a GUI interface, check out CitizensUI by jrbudda which provides an interface for Citizens NPCs as well as managing scripts and other NPC types.

Denizen-Logo-Large.png
A small glimpse of Denizen.


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 Tutorial Videos on youtube or 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!


This is the old Wiki for Denizen 0.7.6! Information found here does not apply to later versions of Denizen.


Denizen is a great way to add MUD-style RPG Citizens to your server. Denizen NPCs use mini scripts with steps and events to interact with the player and world. Imagine interactive gate-keepers, magical wizards, experience trainers, bankers, talking townspeople and more! They can be used in thousands of different ways, from tutorials, to questing, to administrating.. your imagination is just about the limit! Though Denizen uses Scripting, it is not to be confused with Citizens2 Core Scripting which utilizes JavaScript and other major scripting languages to implement Goals. Instead, Denizen uses its own YML 'scripting language' which is designed to be easily read and edited by hand.



If you are coming from Denizen 0.6, we've attempted to compile a list for helping with migration for users upgrading who need a brief on what needs to be changed to become compatible.


How it works

Denizen is an extension of Citizens2 that adds an incredible amount of interactivity and automation to NPCs and Players with some of these major features:

  • The Script Engine carries out and sends all the commands to be executed in an orderly and predictable fashion; this is the backbone of Denizen. Currently has 3 queues, one for the Player, one for Denizen, and one for Tasks. There's not much to see on the outside, this is the interworkings of Denizen, but rest assured that this is high performance machine behind the scenes!
  • Interact Scripts are the meat of Denizen, allowing Players and NPCs to interact with each other and the world. These are highly customizable with 20+ requirement types, 40+ script commands, and thousands of different ways to use them together. This with the Denizen Script Engine also allows commands to help control the rest of Denizen with script flow commands and such.
  • Activity Scripts are exciting. Imagine Johnny Appleseed planting trees, on his own, or simple villagers wandering around and socializing. Activities, of course, work with the rest of Denizen's other functions and features, allowing hundreds of ways to use Activities to add automation and liveliness to your world.
  • Activity Scheduler takes Activity Scripts one step further, allowing Denizen NPCs to have daily schedules, based on the Minecraft day, to allow certain functionality to different times of the day. This also enables certain Script Commands to be executed and carried out, as well.
  • Task Scripts are simple scripts that can be carried out in a variety of different ways. These can be used along side both Activity and Interact Scripts, but perhaps the most powerful way to use them is by allowing your plugin to utilize them, if you're a developer, or using other plugins that harness the ability to run a Denizen Task Script as well.
  • Listeners are currently in an 'experimental phase', but are already allowing control over minecraft and bukkit events like nothing other. This already allows scripts to keep track of and assign 'quest-like' objectives, such as a 'kill quest', if you're familiar with the C1 Quester. But whereas many quest plugins are limited to this feature alone, Denizen, of course, allows you to use this in addition and along side the rest of the plugin, making room for extremely dynamic and intricate 'quest scripts'.
  • Flag System is the key to Denizen being dynamic. An intricate, yet easy to learn 'Flag/Variable' system has been implemented into Denizen to help keep track of events, items, numbers, players, and more. The new Flag System is still getting more powerful each and every day.. it's the key to a spectacular script is sure to have a flag or two.
  • Extensible Commands/Requirements/Activities and more make it easy to add-on to Denizen with very little Java knowledge. This also makes it extremely easy to let users utilize your plugin with script commands. Denizen also has API Events to use.
  • Denizen Debugger' is an extremely friendly and informative way to test out scripts and interactions. Commands, events, and interactions are all logged in an easy to read format to show the exact progression of a script and its surroundings. No more guessing! Less headaches!


Seem overwhelming? Stop! Start small! Denizen is easy, Denizen is simple. But. Denizen is hard, Denizen is complex. Simply put: Denizen is what you make it! Our advice? Start small, and build upon what you have. Read the wiki articles, watch the youtube videos, test our your scripts, and test out some of the sample scripts! Before you know it, you'll be a Denizen poweruser, drunken with power, just like us!


Denizen

If you are new to Denizen, see Before Using Denizen: Getting Started.
If you are having problems getting a script working please see Troubleshooting.
If you're hooked, we recommend you read all the sections in order and try out some sample scripts!

Index

If you are having problems getting a script working please see Denizen/Troubleshooting.

Change Log

Here's what's changed!


0.7.5 BETA build #455

  • New! OWNER requirement will require ownership of the NPC interacting. Could be used for 'command interfaces' that only the owner can access.
  • New! SNEAKING requirement requires the player be crouched when clicking. Careful on conflict with info-click for ops! Info-click can be disabled in the config.
  • New! Queue-time flag replacement can let you dynamically use flag data in a script entry. For example: - GIVE <FLAG:ExampleItemFlag> QTY:<FLAG:ExampleQtyFlag>
  • Experimental! Denizen NPCs now have their own Command Queue, and a TASK activity. This allows NPC's to use the activity scheduler to do tasks at certain times of the day.
  • Experimental! LISTEN command implemented, KILL type implemented. Return of the 'Quester'. More types coming soon. Example usage: - LISTEN KILL ID:UniqueId TYPE:ENTITY NAME:ZOMBIE QTY:5 SCRIPT:FinishIt would require the player to kill 5 zombies. When completed, it will run the task script 'FinishIt'.
  • New! Use <*> to use Chat Trigger text in EXECUTE or talk commands.
  • New! Use <*> in FLAG command to remember player input. Example usage: - FLAG PLAYER_RESPONSE:<*>


0.7.5 BETA build #440:

  • New! API Events make extending Denizen more powerful than ever!
  • New! RUNTASK/CANCELTASK allows delayed tasks to be set, and cancelled.
  • New! HOLD command can change what a Denizen NPC is wielding.
  • New! Replaceable data for dynamically putting flags into texts!
  • New! ISLIQUID requirement can sense if a block bookmark is solid, or liquid.
  • New! IF command can evaluate a FLAG and run a TASK script.


0.7 BETA builds #125 - #280:

  • Updated! Less bugs! We're still in beta, but there has been some major code cleanup!
  • New! Debug Mode will let you see the logic of interaction and script execution to help you find problems in scripts faster than ever. I'm striving to make this as informational and clean as possible to help you test your scripts and get good feedback on behavior.
  • New! Info-Click lets you see Denizen stats and specifics, such as script assignments, trigger status, activity schedule and associated bookmarks with just a crouch and a click. Requires OP.. use this!
  • New! Proximity Triggers can trigger a script when a Player comes near. The most requested trigger type I got during the previous betas.
  • New! Location Triggers can trigger a script when a Player walks over a Location Bookmark. This is kind of like a PLAYERTASK LOCATION, but better! :)
  • New! Damage Triggers separate the left and right clicks for more control over interaction. Look forward to a whole new set of commands to go along with this!
  • New! Script 'Overlay' Assignment mode is a whole new way to assign a script. Less copying/pasting when working with multiple scripts, not to mention more control! If you're an advanced script-user, this is for you!
  • New! RANDOM command will leave command execution to chance. Duck-duck-goose.
  • New! HINT command will hint to the Player acceptable Chat Triggers for the current step and script. Language support coming soon!
  • New! FLAG command lets you set 'flags', on players to store progress, important information, or other variables that can be used with the FLAG requirement. This is HUGE!
  • New! FLAG requirement can require special flags and values to be set in order to be eligible for a script. Again, this is HUGE!
  • New! POWERED requirement can check if a block bookmark has redstone power. Great idea, instinx!
  • New! The activity engine has been implemented which will allow your Denizen to do things on their own. There's a whole lot more to this concept, but you can try out the new WANDER activity in all its glory. This thing is cool, and customizable!
  • New! In-game commands now let you easily manage triggers, bookmarks, and debug info.
  • Updated! Extended/unified command syntax for almost every existing command. Once you get over the pain of upgrading, you will drop a jaw at the new capabilities!


You can see more at the full Denizen Changelog.