Denizen

Denizen

Meta Documentation | Issue Tracker | New Script Repository | Old Script Repository | Tutorial Videos

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.

IRC channel | Source code | Development builds

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 w@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

You must login to post a comment. Don't have an account? Register to get one!

  • Avatar of mcmonkey4eva mcmonkey4eva Jan 19, 2015 at 22:34 UTC - 0 likes

    @silentspectr: Go

    Use the item script name, or item material name, not the ID number!

  • Avatar of silentspectr silentspectr Jan 19, 2015 at 15:14 UTC - 0 likes

    @mcmonkey4eva: Go

    hi thanks for the vid, it helped the last prolem i have with this i that i use a - if<player.inventory.contains[#ID]> - take item:[#ID]

    the new modified item is taken from my inventory with "take itemscript" but how to modifiy the "if inventory contains" that checks if you have the modified item in the inventory ? it doesn't work with the original item ID thanks

    EDIT: and also, it doesn't take the item i want, it takes the item generated by the itemscript how to change that ? it is possible ?

    Last edited Jan 19, 2015 by silentspectr
  • Avatar of mcmonkey4eva mcmonkey4eva Jan 16, 2015 at 20:12 UTC - 0 likes
    Last edited Jan 16, 2015 by mcmonkey4eva
  • Avatar of silentspectr silentspectr Jan 16, 2015 at 17:32 UTC - 0 likes

    Hi it's me again :p first thanks for all your answers, my script is perfectly functionnal secondly, it is possible to add a Lore to items in the "give" and "take" commands ? my NPC doesn't take my items with modified names

    Thanks

  • Avatar of silentspectr silentspectr Jan 15, 2015 at 09:31 UTC - 0 likes

    oh ok ok :p

    thank you

    Last edited Jan 15, 2015 by silentspectr
  • Avatar of mcmonkey4eva mcmonkey4eva Jan 15, 2015 at 05:27 UTC - 0 likes

    @silentspectr: Go

    SOmething like...

    on zombie death:

    - if <context.damager.is_player||false> {

    - ...

    }

  • Avatar of silentspectr silentspectr Jan 14, 2015 at 21:51 UTC - 0 likes

    @mcmonkey4eva: Go

    nice, hope sponge will go out quickly :p

    for the "on entity death", how do you specify which entity i suppose the term entity is global for mobs, villagers and animals i rapidly checked on google but no one uses it

    thanks again

  • Avatar of mcmonkey4eva mcmonkey4eva Jan 14, 2015 at 20:32 UTC - 0 likes

    @silentspectr: Go

    - It's known that that version can't submit, correct.

    - We will have a sponge version available when Sponge is sufficiently functional.

    We previously had issues with the 'kills' event firing several times for no good reason... it might be you're experiencing that bug, it happens in old version and in servers where plugins modify the damage applied. (IE, you hit a mob and do enough damage to kill it, so Denizen reacts, but then a different plugin makes it so the damage is lower and no longer is sufficient to kill)

    You can fix this in your old version by instead relying on "on entity death" which is guaranteed to fire only once, just gotta move a few context tags around and add an if check...

  • Avatar of silentspectr silentspectr Jan 14, 2015 at 09:35 UTC - 0 likes

    @mcmonkey4eva: Go

    well maybe requirements are best with this version but in the future, when i upgrade, my scripts won't work anymore so .. :p so it's a common bug in that version that i can't submit a debug ?

    thanks for all the vids, i'm going to have fun watching them all :p

    oh, and will you update denizen for sponge when it'll be out ? thanks

    EDIT: i just tried the equivalent in the video to the kill listener and ther is this weird bug i don't really understand: i have a "if <player.flag[counter]> >= 5 " and the condition validates itself when i kill 2 zombies instead of 5 after looking step by step in the saves.yml file, i saw that 1 zombie increase the counter by 3 and the second zombie i kill increase it to 7 , then the third one increase to 10 and so on this is really weird do you have any idea why it does that ? thanks

    Last edited Jan 14, 2015 by silentspectr
  • Avatar of mcmonkey4eva mcmonkey4eva Jan 13, 2015 at 22:06 UTC - 0 likes

    @silentspectr: Go

    Oi, that's an old version. You might be best off with listeners and requirements in that version.

    But, for modern scripting, we have nice tutorial videos: http://mcmonkey.org/denizen/vids

    this one -> http://mcmonkey.org/denizen/vids/Putting%20It%20Together:%20A%20Kill%20Quest -> explains the equivalent of a 'kill listener' in modern scripting style.

Facts

Date created
May 21, 2012
Categories
Last update
Dec 31, 2014
Development stage
Beta
Language
  • enUS
License
GNU General Public License version 3 (GPLv3)
Curse link
Denizen
Downloads
40,317
Recent files

Authors