Denizen/0.7/Example Scripts/Beginner Scripts: Difference between revisions

From Citizens Wiki

< Denizen‎ | 0.7

No edit summary
No edit summary
Line 20: Line 20:
A great way to provide some nice immersion into your world is as simple as a basic interaction with a Denizen NPC outputting a random response. There are a couple different ways this can be done, as provided in the examples below. Since this concept is simple, it can be done with a Quick Script as well as an Interact Script.
A great way to provide some nice immersion into your world is as simple as a basic interaction with a Denizen NPC outputting a random response. There are a couple different ways this can be done, as provided in the examples below. Since this concept is simple, it can be done with a Quick Script as well as an Interact Script.


{{codebox|height=250px|Quick Script conversation with the RANDOM command.|<syntaxhighlight line='true' lang="yaml">
====A conversation with RANDOM====
{{codebox|height=250px|Quick Script conversation with the RANDOM command.|<syntaxhighlight line='false' lang="yaml">
# A quick script conversation with RANDOM
# A quick script conversation with RANDOM
#  
#  
Line 40: Line 41:




{{codebox|height=250px|Interact Script conversation with the ZAP command.|<syntaxhighlight line='true' lang="yaml">
====A conversation with ZAP RANDOM====
{{codebox|height=250px|Interact Script conversation with the ZAP command.|<syntaxhighlight line='false' lang="yaml">
# An interact script for conversation with ZAP
# An interact script for conversation with ZAP
#  
#  
Line 76: Line 78:
}}
}}


{{codebox|height=250px|Notch loves cookies, and RANDOM chat.|<syntaxhighlight line='true' lang="yaml">
 
====Notch's Cookies====
{{codebox|height=250px|Notch loves cookies, and RANDOM chat.|<syntaxhighlight line='false' lang="yaml">
# A small script for conversing with Notch, with an easter egg
# A small script for conversing with Notch, with an easter egg
# if you can figure out the magic word.
# if you can figure out the magic word.
Line 85: Line 89:
   Notch:
   Notch:
     Interact Scripts:
     Interact Scripts:
     - 10 Notch Greeting
     - 10 Notch Cookies




# ---- Random conversations.yml
# ---- Random conversations.yml


'Notch Greeting':
'Notch Cookies':
   Type: Interact
   Type: Interact
   Requirements:
   Requirements:
Line 118: Line 122:
}}
}}


==Joe the Builder==
 
== Joe the Builder ==


This is the script from the start-up kit. It's 2 interact scripts assigned to 1 Denizen named Steve. He will respond different to a right-click by a player depending on whether or not the player has the modifyworld.* permission.
This is the script from the start-up kit. It's 2 interact scripts assigned to 1 Denizen named Steve. He will respond different to a right-click by a player depending on whether or not the player has the modifyworld.* permission.

Revision as of 16:04, 19 September 2012

Sometimes the best way to learn is by looking at some examples. The following beginner scripts use basic denizen commands and requirements to provide some nice basic functionality for your Denizens.

Example scripts are provided with both the assignments and the scripts in the same box. Be sure and put the text in the correct file in your plugins folder.
  • Assignments should always be appended to plugins\Denizen\assignments.yml
  • Scripts can be placed in any .yml file in the plugins\Denizen\scripts\ directory. Remember: You can have multiple scripts per file!



and now... the scripts!


Simple, random conversations

A great way to provide some nice immersion into your world is as simple as a basic interaction with a Denizen NPC outputting a random response. There are a couple different ways this can be done, as provided in the examples below. Since this concept is simple, it can be done with a Quick Script as well as an Interact Script.

A conversation with RANDOM

Code: Quick Script conversation with the RANDOM command.
{{{2}}}


A conversation with ZAP RANDOM

Code: Interact Script conversation with the ZAP command.
{{{2}}}


Notch's Cookies

Code: Notch loves cookies, and RANDOM chat.
{{{2}}}


Joe the Builder

This is the script from the start-up kit. It's 2 interact scripts assigned to 1 Denizen named Steve. He will respond different to a right-click by a player depending on whether or not the player has the modifyworld.* permission.

Basic Repeatable Fetch Quest

Here is the fastest way to do a repeatable 'fetch' quest. Useful for custom crafting-type NPCs. Once the player agrees to help, he can turn in the items as often as he wants to receive the reward.

Basic Unrepeatable Fetch Quest

By adding 3 lines to the script above, it becomes un-repeatable.

The Race

Coach wants you to RUN, BOY! This script uses a TASK script and a Location trigger to make a timed race for the player. Good example of ZAP and RUNTASK/CANCELTASK command usage. Be sure and define a Location Bookmark called 'theTree' using the /denizen bookmark location command.