Date: 2016/06/07 09:54:31 UTC-07:00
Type: Denizen 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
47
48
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.
PopulateAttempts: 10
#PopulateMinimalItems, Minimal items in a chest upon populating. 0 Makes items more rare but not impossibile to populate.
PopulateMinimalItems: 1
#PopulateRarity, this parameter sets the rarity of the rare loot table. Adjust the rarity from 1 to 100. 1 = common. 100 is extremely rare.
PopulateRarity: 5
#RarePopulateAttempts, Minimal items in a chest upon populating from the rare item loot table. 0 Makes items more rare but not impossibile to populate.
RarePopulateAttempts: 1
debug: false
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[PopulateAttempts]> {
- 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]>
}
}
- repeat <s@chest100script.constant[RarePopulateAttempts]> {
- if <util.random.int[1].to[<s@chest100script.constant[PopulateRarity]>]> == 1 {
- inventory add d:<context.inventory> o:<yaml[lootcrates].read[rareloot].random.as_item> slot:<util.random.int[1].to[27]>
}
}
}
on player places block:
# This is part of the ChestScript Script and detects if the chest was placed by TerrainControl
- if li@chest|trapped_chest contains <context.material.name> {
- flag server chest:->:<context.location.simple>
}
# This is part of the DispenserScript Script and detects if the Dispenser was placed by TerrainControl
- if dispenser contains <context.material.name> {
- flag server dispenser:->:<context.location.simple>
}