Denizen/0.7/Example Scripts/Beginner Scripts
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
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.
Joe the Builder Script and Assignment |
---|
---- assignments.yml ---- Denizens: 'Steve': #This is the name of the Denizen Interact Scripts: #These are the assigned interact scripts. The number before the script is the priority. - 0 Regular Joe - 10 ^Joe the Builder ---- script.yml ---- 'Regular Joe': Type: Interact Requirements: #There is no list of requirements, so this script can always be picked. That's why we assign it with low priority. Mode: None Steps: 1: Click Trigger: Script: #This sends a basic message to the interacting player. - CHAT "Hello <PLAYER>! I supply builders only!" Proximity Trigger: Script: #This sends a basic message to the player when he walks near. - CHAT "Hello <PLAYER>! Welcome to <WORLD>!" 'Joe the Builder': Type: Interact Requirements: Mode: All List: #Here we check if the player has this permission. If he does, this script is selected because it is higher priority. - PERMISSION modifyworld.* Steps: 1: Click Trigger: Script: - ENGAGE #Engage prevents all interaction with this NPC until DISENGAGE is called. - CHAT "Hello <PLAYER> the Builder! Take this shovel!" - GIVE WOOD_SPADE - WAIT 1 - CHAT "If you have any questions, just say 'help'" - FINISH #This increments the number of times this script (Joe The Builder) has been completed by this player. - DISENGAGE #This sets the NPC Interactable again. Chat Trigger: #There can be multiple entries under a Chat Trigger or Location Trigger node. Hence the 1: on the next line. 1: Trigger: I need some /help/ Script: - CHAT "Press 'e' to open your inventory, and drag the shovel to your item bar" - CHAT "Press the number 1-9 to select the shovel, then start digging!" |
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 Repeatable Fetch Quest |
---|
#--- assignments.yml ---- Denizens: John Q QuestGiver: Interact Scripts: - 0 StartFetch - 1 EndFetch #--- RepeatableFetchQuest.yml ---- StartQuest: Type: Interact Requirements: Mode: None Steps: 1: Click Trigger: Script: - CHAT "Hey, you there!" - CHAT "I have a special request of you!" - CHAT "Will you help me?" Chat Trigger: 1: Trigger: /Yes/. I will. Script: #Tell the player what to do. - CHAT "I need you to bring me some thing. For testing!" - WAIT 1 - CHAT "I need: 1 Iron Block, 1 Feather, and 3 Eggs." - WAIT 1 - CHAT "Come back when you have them and I will reward you!" #Set this script as finished, so we know they're on the quest - FINISH #set this script to step 2. So the player gets the hint message. - ZAP 2: Trigger: /No/. I will not. Script: - CHAT "Are you sure? OK. maybe later?" 2: Click Trigger: Script: - CHAT "Come back you have 1 Iron Block, 1 Feather, and 3 Eggs!" EndFetch: Type: Trigger Requirements: Mode: All List: #Here we check if they are on the quest and have the items. - FINISHED StartQuest - ITEM 42 1 - ITEM 288 1 - ITEM 344 3 Steps: '1': Click Trigger: Script: #Engage is used to keep the player from clicking twice. - ENGAGE - TAKE 42 QTY:1 - TAKE 288 QTY:1 - TAKE 344 QTY:3 - CHAT "Thank you so much! Here, take this as a reward!" - GIVE 133 QTY:1 - WAIT 1 - CHAT "Bring me those items again, and I'll give you another!" #Always disengagae after an Engage - DISENGAGE |
Basic Unrepeatable Fetch Quest
By adding 3 lines to the script above, it becomes un-repeatable.
Basic Repeatable Fetch Quest |
---|
#--- assignments.yml ---- Denizens: John Q QuestGiver: Interact Scripts: - 0 StartFetch - 1 EndFetch #--- UnRepeatableFetchQuest.yml ---- StartQuest: Type: Interact Requirements: Mode: None Steps: 1: Click Trigger: Script: - CHAT "Hey, you there!" - CHAT "I have a special request of you!" - CHAT "Will you help me?" Chat Trigger: 1: Trigger: /Yes/. I will. Script: - CHAT "I need you to bring me some thing. For testing!" - WAIT 1 - CHAT "I need: 1 Iron Block, 1 Feather, and 3 Eggs." - WAIT 1 - CHAT "Come back when you have them and I will reward you!" - FINISH - ZAP 2: Trigger: /No/. I will not. Script: - CHAT "Are you sure? OK. maybe later?" 2: Click Trigger: Script: - CHAT "Come back you have 1 Iron Block, 1 Feather, and 3 Eggs!" 3: Click Trigger: Script: - CHAT "Thanks for the help before!" EndFetch: Type: Interact Requirements: Mode: All List: #Here we check if they are on the quest and have the items, and haven't completed this yet. - FINISHED StartQuest - -FINISHED EndFetch - ITEM 42 1 - ITEM 288 1 - ITEM 344 3 Steps: '1': Click Trigger: Script: - ENGAGE - TAKE 42 QTY:1 - TAKE 288 QTY:1 - TAKE 344 QTY:3 - CHAT "Thank you so much! Here, take this as a reward!" - GIVE 133 QTY:1 - WAIT 1 - CHAT "Tbanks so much! see you around!" #This handy command will move the first script to Step 3. - ZAP 3 SCRIPT:StartFetch #Mark this script as completed. - FINISH - DISENGAGE |
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.
Joe the Builder Script and Assignment |
---|
---- assignments.yml---- Denizens: Coach: Interact Scripts: - 0 Coaches Race ---- Scripts.yml ----- 'RaceEnd': Type: Task Script: - NARRATE "%%cTimes Up!" - ZAP 'SCRIPT:Coaches Race' 3 "Coaches Race": Type: Interact Requirements: Mode: All List: - -FINISHED Coaches Race Steps: 1: Click Trigger: Script: - CHAT "Think you're fast, sonny-jim?" - CHAT "Lets see how fast you are. Run up that hill, around the tree, and back in 15 seconds, if you can!" - WAIT 1 - CHAT "On your mark, get set, go!" - RUNTASK SCRIPT:RaceEnd DELAY:15 - ZAP 2 2: Location Trigger: 1: Trigger: theTree Script: - ZAP 4 Click Trigger: Script: - CANCELTASK RaceEnd - CHAT "Trying to cheat eh?, you have to go around the tree!, try again later, slowpoke!" - ZAP 1 3: Click Trigger: Script: - CHAT "Aww too slow!, go run some laps and try again!" - ZAP 1 4: Click Trigger: Script: - CANCELTASK RaceEnd - CHAT "Woo, you are quick! Good job!" - GIVE MONEY QTY:1000 - FINISH |