Denizen/Types of Scripts: Difference between revisions

From Citizens Wiki
No edit summary
No edit summary
Line 24: Line 24:
You can link interact scripts by adding:
You can link interact scripts by adding:


<pre>   Interact Scripts:
<pre>
    Interact Scripts:
     - 10 MyInteractScript
     - 10 MyInteractScript
    - 20 MyOtherInteractScript</pre>
</pre>


= Interact Scripts =
= Interact Scripts =


<pre>MyInteractScript:
<pre>
MyInteractScript:
     type: Interact
     type: Interact
    Requirements:
        Mode: None
        List:
     Steps:
     Steps:
         '1':
         '1':
Line 40: Line 39:
                 Entry:
                 Entry:
                     Script:
                     Script:
                     - CHAT "Hi there, <player.name>!"
                     - chat "Hi there, <player.name>!"
                     - run mytask</pre>
                     - run mytask
</pre>


Interact scripts control what the NPC does when a player fires triggers such as proximity, click, chat, or damage.
Interact scripts control what the NPC does when a player fires triggers such as proximity, click, chat, or damage.
Line 47: Line 47:
= Item Scripts =
= Item Scripts =


<pre>myitem:
<pre>
myitem:
     type: item
     type: item
     material: wool:3
     material: wool:3
Line 60: Line 61:
= World Scripts =
= World Scripts =


<pre>formatybit:
<pre>
formatybit:
   type: world
   type: world
   events:
   events:
     on formattybit command:
     on formattybit command:
     - NARRATE format:formatdemo "Hello, I'm a well-formatted narrate, caused by a world event '/formattybit' command!"
     - narrate format:formatdemo "Hello, I'm a well-formatted narrate, caused by a world event '/formattybit' command!"
     - DETERMINE cancelled</pre>
     - determine fulfilled
</pre>




Line 72: Line 75:
= Task Scripts =
= Task Scripts =


<pre>mytask:
<pre>
mytask:
     type: task
     type: task
     script:
     script:
     - chat "Here, a book for you!"
     - chat "Here, a book for you!"
     - give myfancybook</pre>
     - give myfancybook
</pre>


Task scripts contain random scripts to be run by other scripts using the command - run (taskscriptname)
Task scripts contain random scripts to be run by other scripts using the command - run (taskscriptname)
Line 82: Line 87:
= Book Scripts =
= Book Scripts =


<pre>myfancybook:
<pre>
myfancybook:
     type: book
     type: book
     title: My Fancy Book
     title: My Fancy Book
Line 99: Line 105:


= Format Scripts =
= Format Scripts =
<pre>formatdemo:
<pre>
formatdemo:
   type: format
   type: format
   format: "<&f>[<&b>Message<&f>- <&2><text><&f>]"</pre>
   format: "<&f>[<&b>Message<&f>- <&2><text><&f>]"
</pre>
 
= CommandScripts =
 
<pre>
my custom command:
  type: command
  name: formattybit
  script:
  - narrate format:formatdemo "Hello, I'm a well-formatted narrate, caused by a command script '/formattybit' command!"
</pre>
 
 
World scripts run world events.

Revision as of 23:54, 21 September 2014

In Denizen, there are multiple different types of scripts each made to fill a different purpose. When writing a script, you will need to use several of these, so they're important to know!

(Note: Page under construction! There's a lot more than just what's listed here!)

Types: interact, book, item, entity, task, assignment, procedure, world, format, inventory

Also: All the example scripts on this page work together...

To see them all work, add them all to your server and assign "MyAssignmentScript" to an NPC, then right-click it.

Assignment Script

MyAssignmentScript:
    type: assignment
    actions:
        on assignment:
        - chat "I has been assigned!"
        - trigger name:click state:true

The assignment script is the first script any NPC needs - it lists everything the NPC does!

One of the most important uses is the "on assignment:" action, which is run when the script is assigned to an NPC, in which you normally enable triggers, and run other important commands.

You can link interact scripts by adding:

    Interact Scripts:
    - 10 MyInteractScript

Interact Scripts

MyInteractScript:
    type: Interact
    Steps:
        '1':
            Proximity trigger:
                Entry:
                    Script:
                    - chat "Hi there, <player.name>!"
                    - run mytask

Interact scripts control what the NPC does when a player fires triggers such as proximity, click, chat, or damage.

Item Scripts

myitem:
    type: item
    material: wool:3
    recipe:
    - air|air|air
    - dirt|wool|dirt
    - air|air|air

Item scripts hold data on custom items.

World Scripts

formatybit:
  type: world
  events:
    on formattybit command:
    - narrate format:formatdemo "Hello, I'm a well-formatted narrate, caused by a world event '/formattybit' command!"
    - determine fulfilled


World scripts run world events.

Task Scripts

mytask:
    type: task
    script:
    - chat "Here, a book for you!"
    - give myfancybook

Task scripts contain random scripts to be run by other scripts using the command - run (taskscriptname)

Book Scripts

myfancybook:
    type: book
    title: My Fancy Book
    author: NotNotch
    text:
    - This is my book. There are many like it, but this one is mine!
    - Many <n>new <n> lines!
    - <p>Paragraphs, <p>too!

Book scripts hold information on a complex book item.

Each - line in the text: category is a new page.

After defining a book in a script, you can give it to a player in any runnable script using - give (bookname)

Format Scripts

formatdemo:
  type: format
  format: "<&f>[<&b>Message<&f>- <&2><text><&f>]"

CommandScripts

my custom command:
  type: command
  name: formattybit
  script:
  - narrate format:formatdemo "Hello, I'm a well-formatted narrate, caused by a command script '/formattybit' command!"


World scripts run world events.