Staff Pick: Chest (RE)Populator
By
NLBlackEagleCreated: 2015/12/02 21:15:39 UTC-08:00 (9 years and 22 days ago)
Edited: 2015/12/03 16:28:33 UTC-08:00 (9 years and 21 days ago)
Likes: 1
Staff pick as of: 2015/12/03 16:27:32 UTC-08:00 (9 years and 21 days ago)
Denizen Version: Build 1581
Script Version: 0.1 Script Part
Description:
This script populates generated chest ( By any generator ) Chests placed by players wont get populated.
For this script to work You'll also need the lootcrates.yml which can be found here: http://mcmonkey.org/denizen/repo/entry/66
Download script |
View raw script#####################################
# Created by NLBlackEagle #
# Website: www.craftrealms.org #
# TeamSpeak: ts3.craftrealms.org #
#####################################
Chest100Script:
type: world
default constants:
#The RepopulateCooldown value is in minutes and determines the amount of time before a re-population
#should be executed. This causes no server load since the re-population is player-bound.
#Change the value "300m" to any number you'd like. 300m equals 5 hours.
RepopulateCooldown: 300m
#PopulateAttemts, lower this number to decrease the amount of items in a chest.
PopulateAttemts: 15
#PopulateMinimalItems, Minimal items in a chest upon populating. 0 Makes items more rare but not impossibile to populate.
PopulateMinimalItems: 2
debug: true
events:
on server start:
- yaml load:lootcrates.yml id:lootcrates
on player opens chest:
- if !<player.has_flag[<context.inventory.location.simple>]> {
- flag player <context.inventory.location.simple>:true duration:<s@chest100script.constant[RepopulateCooldown]>
- if <server.flag[chest].as_list.contains[<context.inventory.location.simple>]> {
- queue clear
}
- repeat <s@chest100script.constant[PopulateMinimalItems]> {
- inventory add d:<context.inventory> o:<yaml[lootcrates].read[loot].random.as_item> slot:<util.random.int[1].to[27]>
}
- repeat <s@chest100script.constant[PopulateAttemts]> {
- if <util.random.int[1].to[5]> == 5 {
- inventory add d:<context.inventory> o:<yaml[lootcrates].read[loot].random.as_item> slot:<util.random.int[1].to[27]>
}
}
}
on player places block:
- if li@chest|trapped_chest contains <context.material.name> {
- flag server chest:->:<context.location.simple>
}
View History