Denizen

Meta Documentation | Issue Tracker | New Script Repository | Old Script Repository | Tutorial Videos | Forums
Development builds of this project can be acquired at the provided continuous integration server. These builds have not been approved by the BukkitDev staff. Use them at your own risk.
Denizen uses a pasting service provided by its developers to enable recording of debug sessions. This allows an easy and universal way to troubleshoot a script. It is only used on '/denizen submit', however this service is not endorsed by the BukkitDev staff. Use it at your own risk.
HEY!
This project is moved!
Please download from:
https://www.spigotmc.org/resources/denizen.21039/
View resources at:
This Bukkit page won't be updated much!
About
Hey there! Thanks for using Denizen for Bukkit and Citizens2. Looking for a quick starting guide? Here's the place!
So, what is Denizen? It's is best classified as a scripting platform. Denizen for Bukkit and Citizens2 utilizes the scripting, and various other components provided by DenizenAPI. The scripting component of Denizen features easy to use script containers, replaceable tags, commands, and a queue system. Built aside is a slew of components that deal with many kinds of event handlers, many additional NPC features, a fully-featured variable system (we call them 'flags'), and a rich object-oriented set of features. I encourage users to start small when first getting into Denizen, but rest assured there are tons of features to explore.
Denizen NPCs? Yep, that's right. Denizen is probably best known as a way to create scripted Citizen NPCs. In fact, this whole project started out as an extension to Citizens2. You can use it to make interactive NPCs with the use of Assignment Scripts and Interact Scripts. This is pretty easy to do, and there's a bunch of cool NPC specific (among many other) commands and tags that you can utilize as well.
Here's a small example I call 'cookies'. I normally like to comment my scripts, but this one below is presented without any as to show the flow.
Cookies: type: assignment interact scripts: - 100 Cookie Handler Cookie Handler: type: interact steps: 'Spreading the Word*': click trigger: script: - random 3 - chat 'I like cookies!' - chat 'MMmm.. cookies are favorite!' - chat 'Cocoa and wheat me freak!' chat trigger: 'Cookies': trigger: 'I love /cookie/s!' script: - chat 'Me too!' - narrate '<npc.name> gives you some cookies.' - give i@cookie qty:6 - zap 'step:Cookies given' 'Cookies given': click trigger: script: - chat 'How were the cookies?' - zap 'step:Spreading the Word'
It's a simple 2-step, multi-trigger script that creates a cookie loving NPC. For some reason I think it's funny to name the NPC 'Notch'. Making a NPC use this script couldn't be easier, either. Simply use a bukkit command while having the NPC selected. It looks like this:
/npc assignment --set cookies
Now clicking on your NPC will use Denizen Triggers to activate the script above. An instant Denizen NPC! Cookies is funny, but hardly useful, and it's my personal philosophy that NPCs should be useful. How 'bout a simple healer? This NPC will heal you, but only when you're seriously injured.
Basic Healer: type: assignment interact scripts: - 100 heal me, bro! Heal me, bro!: type: interact steps: "Need a heal?*": click trigger: script: - if '<player.health>' < '<m:<player.health.max> / 2>' { - look <player.location> - chat 'Woah dude, you are <player.health.formatted>! You could use a heal!' - chat 'Just give me another click to get some power!' - zap "Healin'" duration:30s } else { - look <player.location> - chat 'Nice an healthy. Keep it up!' } "Healin'": click trigger: script: - ^zap 'need a heal?' - ^engage - chat "Here goes nothin'!" - playeffect instant_spell <npc.location> qty:25 - playeffect heart <player.location> qty:25 offset:1 - heal <player> - disengage
How do you make a Healer NPC with this script? You guess it! Just select that NPC, and type:
/npc assignment --set 'basic healer'
It's not just for NPCs. I guess I already told you that, but Denizen has some other script types that open up possibilities that extend far beyond it's core functionality of utilizing NPCs. One of my favorite 'simple scripts' that I like to show people is one that my friend Blankiito showed me. The one below is slightly modified, but basically it enables a 'rogue-like feature' that makes a player invisible when sneaking. It's a simple concept, but perfectly illustrates the flow of a Denizen Script.
Rogue: type: world debug: false events: on player starts sneaking: - playeffect <p.location> magic_crit qty:10 - invisible <player> state:true on player stops sneaking: - invisible <player> state:false
Even small scripts can be incredibly useful for your server. Sometimes scripts can replace entire bukkit plugins, and since the 'code' is in Denizen Script, the end result is often times more flexible to you, the server operator. Have a plugin that run some commands every once in awhile? Replace it with a simple Denizen script.
Auto Save Event Handler: type: world debug: false events: on 5:00 in world: - announce 'Autosaving...' - execute as_server 'denizen save' - execute as_server 'citizens save' - execute as_server 'save-all'
Use Denizen to solve problems, or to make features easier to use. Example: If you're familiar with Citizens, you may have realized that WorldGuard's /butcher command is not friendly to mob-type NPCs. It removes them, too, which can be a pain! Why not write your own /butcher command?
Safer Butcher Handler: type: world debug: false events: on sbutcher command: - narrate 'Removing all mob entities within 15 blocks... your NPCs are safe!' - foreach <player.location.find.entities.within[15]> { - if <%value%.is_mob> remove %value% }
Denizen Quests are the best quests. If you're like me, this whole thing started by using the Quester for Citizens1. It featured a fairly simple questing structure to implement things like 'kill quests' and 'collection quests'. When Citizens went to version 2, that functionality was no longer 'core', but no worries Denizen can help! By utilizing Denizen's Player Listeners, simple questing can be done easily, and it's more robust because you can use all the other features implemented by Denizen, too!
So, how do you best get started? This is a question we get all the time. Because of the enormous amount of ways to use and customize Denizen, we suggest that you simply START SMALL! Checking out the videos, scripts, and articles on denizen-docs you're sure to find a comfortable place to start. While scripting, utilize the tools provided, such as the SublimeText2 grammar pack, and the reference and search for meta lookup on this site.
Like any programming language, there is a learning curve with code structure and syntax that will only be overcome by trial and error. While using some user-made scripts can be as easy as dragging-and-dropping, many scripts will likely require at least a basic understanding of the denizen-script structure to fully utilize their features. But don't worry! Denizen is purposefully made to be easy to read and easy to customize! Tags, commands and events are all very verbose, easy to follow. With a little bit of research we know you'll soon be drunken with power, just like us!
Videos
Other useful links
- Denizen Handbook (Outdated kind of, but has some useful information still.)
- User-made beginner's guide
- Citizens2 Wiki
-
View User Profile
-
Send Message
Posted Mar 6, 2014@KewCrew
Inventories are weird. That massive error is trying to tell you that you need to add arguments to the inventory command to make it work. Check the command's usage information here: http://mcmonkey.org/cmds/inventory
@KewCrew
Read the info / watch tutorials to learn how to make a script run when an NPC is clicked (the first thing taught usually) -> then combine that with the inventory script / command / etc. as I described below.
Since you thought "/inventory" would be a valid Bukkit command, I assume you're very new to Denizen, in which case this is likely too advanced for you currently, and you'll want to practice simpler scripts first.
If you just want a standard shop where you buy items, and don't want to spend time learning Denizen before trying this, you might want to instead use a plugin like DTLTraders ( http://wiki.citizensnpcs.co/DtlTraders ) which is built for that one specific purpose and will be easier to setup.
If you're feeling confident and you want to see example scripts of interactive inventories / track Denizen's progress towards making this much simpler to do, watch this Denizen issue: https://github.com/aufdemrand/Denizen/issues/707
-
View User Profile
-
Send Message
Posted Mar 6, 2014@mcmonkey4eva
and also when i type /ex inventory add i get this : http://mcmonkey4eva.dyndns.org/paste/2430
-
View User Profile
-
Send Message
Posted Mar 6, 2014@mcmonkey4eva
ok so i got that to work but how do i make it to where if i right click the mob i can open the shop
-
View User Profile
-
Send Message
Posted Mar 5, 2014@KewCrew
That's not how Denizen works. I very strongly encourage you to look at some of the help resources listed here: https://github.com/aufdemrand/Denizen/blob/master/README.md so you can get to know how Denizen works.
If you want a really short answer... it's not "/inventory", /commands are Bukkit commands... Denizen commands have to be inside scripts. If you want to quick-test a Denizen script command in-game, you use the Bukkit command "/ex".
-
View User Profile
-
Send Message
Posted Mar 5, 2014@mcmonkey4eva
by it doesnt work i mean it says the command doesnt exist. i type /inventory
-
View User Profile
-
Send Message
Posted Mar 3, 2014@KewCrew
That's way too vague. Don't just say it "doesn't work". It does work (or there's a bug we need to fix, after which it will work)
What precisely isn't working? What are you trying? What's the debug output? To quote our IRC bot...
[18:41:37] <monkeybot> Help us help you by pasting your script to http://mcmonkey.org/paste - From there, save the page and paste the link back in this [comment section] In-game, type '/denizen debug -r', then run through the broken parts of the script, then type '/denizen submit'. Open the link it gives you, and paste that link back in this channel as well.
-
View User Profile
-
Send Message
Posted Mar 3, 2014@mcmonkey4eva
ok so i am still confused on this whole thing. i watched tutorials and the inventory commands dont work for some reason, is there a plugin i am missing? or do i have to code the commands myself?
-
View User Profile
-
Send Message
Posted Mar 3, 2014@KewCrew
Assuming you've looked the tutorial / help info and can make a script fire when an NPC is clicked... (and are ready for some advanced Denizen usage)
Inventories are complex things right now, not the best to be dealt with... but it can be done.
You'll need to use the Inventory command -> http://www.mcmonkey.org/cmds/inventory -> an inventory script -> http://www.mcmonkey.org/lngs/inventory%20script%20containers -> and some inventory events -> http://www.mcmonkey.org/evts/inventory
Create an Inventory script of your menu design, filled with unique items. EG in one slot you might have "itemone" (an item script). Then have a world event, something like "on player clicks itemone in inventory:" - fire whatever actions that menu button should do, and then "determine cancelled" the event. Repeat for each item.
Here's the complicated / confusing Inventory part: As they're not so perfectly set up at the moment (in either Bukkit or Denizen), two things you'll have to deal with: First, you cannot give or take items inside an inventory event, you have to run a delayed task to do that. Second, once you get a base script worked out with an item or two... test it. A lot. Try to break it (by shift-clicking, right-clicking, swapping items, etc) - it's likely you'll need to handle other events like "on player shift_right clicks itemone" and so on. (We have plans to make this a lot easier to deal with, but they're getting pushed behind other issues, especially with our lead Inventory dev currently unable to contribute)
-
View User Profile
-
Send Message
Posted Mar 3, 2014how do i make it to where when you right click a villager, a menu shop opens?
-
View User Profile
-
Send Message
Posted Mar 1, 2014@joeistek
<server.list_online_players.random.as_player.name> or <<server.list_online_players.random>.name>
-
View User Profile
-
Send Message
Posted Mar 1, 2014Is There a tag to Randomly Pick A Online players name
-
View User Profile
-
Send Message
Posted Feb 26, 2014@mcmonkey4eva
Thanks for the heads up about ItemDrop listeners, I thought I was going insane.
-
View User Profile
-
Send Message
Posted Feb 22, 2014@dwatsX
If the info you gave is call correct, you could fix it fairly quickly by just removing any item listeners you have. They only run if you make them run.
Also, the issue you linked was an entirely unrelated problem from *January 2013* over a year ago. That particular issue is long since fixed.
... and a well created item listener script shouldn't have any such issues.
EDIT: Actually, I see a minor issue that might leak memory if you create thousands of item listeners... will fix ASAP.
EDIT2: Fixed in https://github.com/aufdemrand/Denizen/commit/08f2b05165820359d23d2697e5561571d2950b11 (Denizen dev build #1453, see dev build link in plugin description)
-
View User Profile
-
Send Message
Posted Feb 22, 2014@deleted_10306201
I'm having the same issue. It's definitely Denizen causing the Out Of Memory error; I believe it's related to a memory leak that stems from item listeners. What's interesting is that I did not have this issue until I turned my server into a BungeeCord hub. Now that I'm using Bungee, the server on which this plugin is installed will run for about a day before crashing (this server is allocated 16GB). When I remove Denizen everything works fine. The reason I think it's related to item listeners causing a memory leak is just because I've done a bunch of research into the issue and I've read that an item listener that isn't stored properly can cause issues for Bungee when the player disconnects, as it's still trying to allocate data to a location that doesn't exist.
I love Denizen but this issue is making it unusable for me, and apparently this other individual below. I wonder if he is using Bungee also?
Hopefully this info will allow you to fix the issue or suggest something I can do to fix? Thanks very much.
-
View User Profile
-
Send Message
Posted Feb 21, 2014@fritzbuild3r
For the cookies thing... in the script, just add " - zap 'step:Spreading the Word' " to the end to make it jump back.
If you want an in-game command, use " /ex zap s@cookies 'step:Spreading the Word' "
@fritzbuild3r
For the scribe thing -> the scribe command is a weird one... I recommend you just don't bother with it. Use " - give book_script_name " or " - drop book_script_name" <- the commands for giving/dropping items will take book script names just like an item name.
@XLighterShadowX
We have plans for better control of the chats in interact triggers (hiding them, changing them, ... ) but for now, all you can use is the world event "on player chats" (see here for meta-info: http://mcmonkey.org/evts/chat ) to modify or cancel it.
@nathank33
ItemDrop listeners don't actually work right now, actually. Sorry.
If you're experienced with Denizen, you can use the world event "on zombie death" (meta-info: http://mcmonkey.org/evts/death ) to check if the damager is a player, and if so if the player is a flagged with a quest, and, if so, adjust the flag as needed (EG, for a countdown) and "- determine i@apple"
@Everyone replied to: If any of what I said isn't clear / or you're new to Denizen and don't know how to use some of the more advanced features like that, please come to our IRC channel (link: http://webchat.esper.net/?nick=random_denizen_...&channels=denizen-dev&prompt=1 ) - it's the best place to get Denizen help, and we'll be sure to help you get set up with world events and other fun features!
-
View User Profile
-
Send Message
Posted Feb 19, 2014Actually I am trying to use scribe to write book scripts, and I can't seem to get any of the examples to execute. I've tried about every permutation that I can think of here.
19.02 22:05:17 [Server] INFO +> [CommandExecuter] +> MESSAGE follows: 'Missing SCRIPT 19.02 22:05:17 [Server] INFO ERROR! Woah! Invalid arguments were specified! 19.02 22:05:17 [Server] INFO ERROR! 'script:test_book' is an unknown argument! 19.02 22:05:17 [Server] INFO +- Executing dCommand: SCRIBE/BlastMinerDad
-+Shouldn't I be able to do:
- scribe script:book_script_name drop
book_script_name: type: book title: Title of the Book author: Author of the Book text: - Each item on this list - represents a new page - in the book. You can use - <n> to create a new line - and <p> to create a new - paragraph.
-
View User Profile
-
Send Message
Posted Feb 19, 2014Hi I LOOVE this plugin. I am already working on several Denizen's on my server to work as quest givers and helpers.
My question is, I am doing some testing and dev work... so I am editing NPC scripts while the server is live. Other than reloading with /denizen reload -a I notice that the steps in saves.yml are still fixed. Is there a way I can reset specific NPC questlines? I dont want to trash my whole file because server users already have specific questlines completed.
Well, other than running a bash script to do this.. but I assumed there should be some sort of denizen command.
Example: running the cookies script you finish the questline and then can't restart until manually removing the lines in saves.yml
THANKS!
-
View User Profile
-
Send Message
Posted Feb 15, 2014I'm having a hard time getting this Listener to work, it loads up without a problem but the apples do not drop.
- ^listen itemdrop "id:ZombieKilling ItemDrop Listener" type:mobkill dropsfrom:Zombie item:apple qty:5 region:questarea droprate:50 "script:ZombieKilling Flag Done"
-
View User Profile
-
Send Message
Posted Feb 12, 2014Hi, i need to make Guild Master that will create a guild for player (plugin factions) if they will pay some amount of money. It should check if they have any money and if they are members of any guild, if not they can't do that.. if yes the NPC should ask player of the name of the guild ant the create it. How to make it or remake it of that script http://scripts.citizensnpcs.co/view/j3mg6r ??
-
View User Profile
-
Send Message
Posted Feb 3, 2014@Jeebs12491
Jeebs - great job! Do some more.