- D1 Meta Docs - Denizen Script -
Home Page / Pi to one million places / Contact mcmonkey / Donate / Paste Scripts / Denizen Help /
You are browsing as a guest.
Login | Register








The script repo is an archive of historical scripts. For modern scripts, or to post your own, please use the Scripts forum section.





Staff Pick: Chest (RE)Populator


By NLBlackEagle
Created: 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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
4600

#####################################
#  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