Date: 2015/02/25 23:54:11 UTC-08: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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
lantern_world_handler:
type: world
debug: true
events:
on player picks up i@lantern:
- if <player.inventory.contains.display[strict:lantern].qty:3||false> {
- determine cancelled
}
- inventory update
on player picks up i@fueledlantern:
- if <player.inventory.contains.display[strict:lantern]||false> {
- determine cancelled
}
on player steps on block:
- if <player.item_in_hand.material> == m@torch || <player.has_flag[lanternon]> {
- define last <player.flag[torchlight.last]||null>
- if %last% != null {
- light %last% reset
}
- light <context.new_location> 10
- flag player "torchlight.last:<context.new_location>"
- wait 1t
- if <c.new_location.simple> == <player.location.simple> {
- light <player.location.standing_on> d:<player.flag[lanternon].expiration||false>
}
}
on player holds item:
- if <player.inventory.slot[<context.previous_slot>].material> == m@torch {
- define last <player.flag[torchlight.last]||null>
- if %last% != null {
- light %last% reset
- flag player "torchlight.last:!"
}
}
- if <player.inventory.slot[<context.new_slot>].material> == m@torch {
- light <player.location> 10
- flag player "torchlight.last:<player.location>"
}
on player right clicks with i@fueledlantern:
- if <player.has_flag[lanternon]> {
- adjust i@fueledlantern 'lore:burn_time_left<&co><player.flag[lanternon].expiration||0>' save:lantern
- if <player.item_in_hand.lore.before[<&co>]> == li@burn_time_left {
- take <player.item_in_hand.full>
}
else {
- take i@fueledlantern
}
- wait 1t
- give <entry[lantern].result.full>
- flag player lanternon:!
- light <player.location> reset
}
else if !<c.item.lore.after_last[<&co>]||true> == true {
- flag player lanternon d:<c.item.lore.after_last[<&co>]>
- flag player fuelleft:!
- wait 1t
- light <player.location> 10 d:<player.flag[lanternon].expiration||false>
}
else {
- flag player lanternon d:5m
- wait 1t
- light <player.location> 10 d:<player.flag[lanternon].expiration||false>
}
on player flag lanternon expires:
- take bydisplay:lantern
- wait 1t
- give i@lantern
on player jumps:
- if <player.has_flag[lanternon]> {
- light <player.flag[prevloc]> d:1t
}
on player drops i@fueledlantern:
- if <c.item.lore.before[<&co>]> == li@burn_time_left && !<player.has_flag[lanternon]> {
- queue clear
}
else if <c.item> == i@fueledlantern && !<player.has_flag[lanternon]> {
- queue clear
}
else {
- determine passively cancelled
- adjust <c.item.full> 'lore:burn_time_left<&co><player.flag[lanternon].expiration>' save:lantern
- wait 1t
- take bydisplay:lantern
- drop <player.location.add[<player.location.direction.vector.mul[3]>]> <entry[lantern].result.full>
- light <player.location.add[0,-1,0]> d:1t
- flag player lanternon:!
}
lantern:
type: item
material: m@glass_bottle
display name: lantern
lore:
- this lantern needs fuel
recipe:
- i@iron|i@glass|i@iron
- i@glass|i@string|i@glass
- i@iron|i@iron|i@iron
lanternfuel:
type: item
material: m@potion,8236
display name: lantern_fuel
recipe:
- i@potion|i@glowstone_dust|i@potion
- i@glass|i@coal|i@glass
- i@glass|i@glass|i@glass
fueledlantern:
type: item
material: m@glass_bottle
display name: lantern
lore:
- right click to turn this lantern on
- right click again to turn it off
recipe:
- i@lanternfuel|i@air|i@air
- i@lantern|i@air|i@air
- i@air|i@air|i@air