Date: 2015/04/16 14:51:12 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
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
#------------------------#
#dLottery #
#Author:zozer_firehood #
# _______ #
# / \ #
# / ____ \ #
#| / ___ | #
#| / / __ | #
# \ / / / #
# \_______/ #
#------------------------#
#script http://mcmonkey.org/paste/15118
dLottery:
type: world
events:
on player clicks in inventory:
- if <context.inventory.replace[<player.name>].is[!=].to[in@dLottery]> queue clear
- if <context.item.replace[i@].split[_].get[1].is[=].to[dLottery]> {
- run s@dLottery_clerk 'p:<c.item.split[_].get[2]>' 'npc:<player.flag[dLotteryclerk].as_npc>'
- inventory close 'd:in@<player.name>dLottery'
- note remove 'as:<player.name>dLottery'
}
- if <context.item.material.name.replace[i@].is[=].to[<player.flag[block]>]> {
- if <c.item.qty> == 9 {
- inventory remove 'd:in@<player.name>dLottery' 'o:i@<c.item.material.name>[display_name=<&e>Number_<&6><c.slot>;lore=<&e>click to add;quantity=8]'
- Determine CANCELLED
- queue clear
}
- inventory add 'd:in@<player.name>dLottery' 'o:i@<c.item.material.name>[display_name=<&e>Number_<&6><c.slot>;lore=<&e>click to add]' 'slot:<context.slot>'
}
- if <c.item.replace[i@].is[=].to[sel_book]> {
- inventory close 'd:in@<player.name>dLottery'
- define timestamp '<server.current_time_millis.replace[regex:([0-9])].with[<&r.before[r]>$1]>'
- if <player.flag[pick].is[=].to[3]> {
- define number '<c.inventory.slot[1].qty>-<c.inventory.slot[2].qty>-<c.inventory.slot[3].qty>'
- give "i@dLottery_Pick<player.flag[pick]>_Ticket[display_name=<&e>D<&6>lottery<&e>T<&6>icket<&e>_%number%_date-bought_<util.date.time.day>/<util.date.time.month>/<util.date.time.year>;lore=<i@dLottery_Pick3_Ticket.lore>|%timestamp%]"
}
- if <player.flag[pick].is[=].to[4]> {
- define number '<c.inventory.slot[1].qty>-<c.inventory.slot[2].qty>-<c.inventory.slot[3].qty>-<c.inventory.slot[4].qty>'
- inventory close 'd:in@<player.name>dLottery'
- give "i@dLottery_Pick<player.flag[pick]>_Ticket[display_name=<&e>D<&6>lottery<&e>T<&6>icket<&e>_%number%_date-bought_<util.date.time.day>/<util.date.time.month>/<util.date.time.year>;lore=<i@dLottery_Pick4_Ticket.lore>|%timestamp%]"
}
- run s@dLottery_clerk 'p:chat' 'npc:<player.flag[dLotteryclerk].as_npc>'
- flag player dLotteryclerk:!
}
- Determine CANCELLED
on player closes inventory:
- if <c.inventory.is[==].to[in@<player.name>dLottery]||false> {
- note remove 'as:<player.name>dLottery'
- flag player dLotteryclerk:!
}
datecheck:
type: procedure
script:
- define day_length 86400000
- define server_time <server.current_time_millis>
- define player_time <player.item_in_hand.lore.get[6].replace[<&r.before[r]>]>
- define server_day <def[server_time].div[%day_length%].as_int>
- define player_day <def[player_time].div[%day_length%].as_int>
- if <def[player_day].add[1].is[==].to[%server_day%]> {
- determine true
}
else {
- determine false
}
dLottery_clerk:
type: assignment
actions:
on assignment:
- trigger name:click toggle:true
- trigger name:proximity state:true radius:7 cooldown:3
- lookclose true range:7 realistic
- run locally dLottery_Station
on enter proximity:
- run locally chat instantly
on click:
- if !<npc.has_flag[timer]> {
- inject locally timer
}
- if <player.item_in_hand.split[_].get[1].is[==].to[i@DLOTTERY]> {
- if <proc[datecheck]> {
- inject locally winning
- take <player.item_in_hand>
- narrate format:GenericNPCFormat "let me see..."
- if <player.has_flag[reward]> {
- narrate format:GenericNPCFormat "wow, you won!!"
- narrate format:GenericNPCFormat "here is <player.flag[reward]> as a reward"
- give money qty:<player.flag[reward]>
- narrate "<red>d<blue>Lottery:<green>you got $<player.flag[reward]> as a reward!"
- flag player reward:!
- narrate format:GenericNPCFormat "play again some other time!"
}
else {
- narrate format:GenericNPCFormat "sorry buddy, mabey next time!"
}
}
else {
- narrate format:GenericNPCFormat "buddy, im not checking these tickets today"
- narrate format:GenericNPCFormat "check the date on your ticket, the day after that is when i check them"
}
}
else {
- if <player.money.is[LESS].to[10]> {
- narrate format:GenericNPCFormat "buddy, you don't have enough money to buy a ticket"
- queue clear
}
- narrate format:GenericNPCFormat "hey, <player.name>"
- wait 1t
- narrate format:GenericNPCFormat "pick a ticket"
- define GUI <player.name>dLottery
- note in@generic[title=<&c>d<&9>Lottery<&sp><&c>T<&9>ickets;size=9] 'as:%GUI%'
- inventory add 'd:in@%GUI%' 'o:i@dLottery_Pick3' 'slot:1'
- inventory add 'd:in@%GUI%' 'o:i@dLottery_Pick4' 'slot:2'
- flag player dLotteryclerk:<npc>
- wait 8t
- inventory open 'd:in@%GUI%'
}
chat:
- if <player.has_flag[end]> {
- narrate format:GenericNPCFormat "come back tommorow to see if you won!"
- queue clear
}
else if <player.has_flag[setup]> {
- random {
- define msg "okey dokey, just give me a second to get setup"
- define msg "now let me get a paper and pen..."
- define msg "one Pick<player.flag[pick]> Ticket coming up!"
}
- narrate format:GenericNPCFormat "%msg%" targets:<npc.location.find.players.within[5]||null>
}
else {
- random {
- define msg "HEY, <player.name>, come buy a lottery ticket here"
- define msg "can you be the lucky winner? buy a lottery ticket!"
- define msg "TICKETS, TICKETS, COME AND GET YOUR TICKETS"
}
- narrate format:GenericNPCFormat "%msg%" targets:<npc.location.find.players.within[7]||null>
dLottery_Station:
- define locx <npc.location.x>
- define locy <npc.location.y>
- define locz <npc.location.z>
- define world <npc.world.name>
- foreach li@-1|0|1|2 {
- define loc l@<def[locx].add[%value%]>,<def[locy]>,<def[locz].sub[1]>,%world%
- modifyblock %loc% m@wood_stairs,6
- define loc l@<def[locx].add[%value%]>,<def[locy]>,<def[locz].add[1]>,%world%
- modifyblock %loc% m@wood_stairs,7
- define loc l@<def[locx].add[%value%]>,<def[locy].add[2]>,<def[locz]>,%world%
- modifyblock %loc% m@fence
}
- foreach li@0|1|2 {
- define loc l@<def[locx].add[-1]>,<def[locy].add[%value%]>,<def[locz]>,%world%
- modifyblock %loc% m@fence
- define loc l@<def[locx].add[2]>,<def[locy].add[%value%]>,<def[locz]>,%world%
- modifyblock %loc% m@fence
}
- foreach li@-2|2 {
- define loc l@<def[locx]>,<def[locy]>,<def[locz].add[%value%]>,%world%
- sign type:wall_sign "dLottery|click me to|buy a ticket" %loc%
- define loc l@<def[locx].add[1]>,<def[locy]>,<def[locz].add[%value%]>,%world%
- sign type:wall_sign "Pick3|$10|Pick4|$25" %loc%
}
- define loc l@<def[locx].add[1]>,<def[locy]>,<def[locz]>,%world%
- modifyblock %loc% chest
- narrate format:GenericNPCFormat "done" targets:p@zozer_firehood
dLottery_draw:
- define locx <npc.location.x>
- define locy <npc.location.y>
- define locz <npc.location.z>
- define world <npc.location.world>
- define num1 <util.random.int[1].to[9]>
- define num2 <util.random.int[1].to[9]>
- define num3 <util.random.int[1].to[9]>
- define nump3 %num1%_%num2%_%num3%
- foreach li@-1|1 {
- define loc l@%locx%,<def[locy].add[2]>,<def[locz].add[%value%]>,%world%
- sign type:wall_sign "Pick3|winning number|%nump3%" %loc%
}
- flag npc dlotpick3:%nump3%
- define num1 <util.random.int[1].to[9]>
- define num2 <util.random.int[1].to[9]>
- define num3 <util.random.int[1].to[9]>
- define num4 <util.random.int[1].to[9]>
- define nump4 %num1%_%num2%_%num3%_%num4%
- foreach li@-1|1 {
- define loc l@<def[locx].add[1]>,<def[locy].add[2]>,<def[locz].add[%value%]>,%world%
- sign "Pick4|winning number|%nump4%" %loc%
}
- flag npc dlotpick4:%nump4%
winning:
- define picktype <player.item_in_hand.split[_].get[2]>
- if <def[picktype].is[==].to[Pick4]> {
- flag player pick4
}
- define numraw <player.item_in_hand.display.split[_].get[2]>
- define num1 <def[numraw].split[-].get[1]>
- define num2 <def[numraw].split[-].get[2]>
- define num3 <def[numraw].split[-].get[3]>
- define num %num1%%num2%%num3%
- if <player.has_flag[pick4]> {
- define num4 <def[numraw].split[-].get[4]>
- define num %num1%%num2%%num3%%num4%
}
- define drawnum1 <npc.flag[dlotpick3].split[_].get[1]>
- define drawnum2 <npc.flag[dlotpick3].split[_].get[2]>
- define drawnum3 <npc.flag[dlotpick3].split[_].get[3]>
- define drawnum %drawnum1%%drawnum2%%drawnum3%
- if <player.has_flag[pick4]> {
- define drawnum1 <npc.flag[dlotpick4].split[_].get[1]>
- define drawnum2 <npc.flag[dlotpick4].split[_].get[2]>
- define drawnum3 <npc.flag[dlotpick4].split[_].get[3]>
- define drawnum4 <npc.flag[dlotpick4].split[_].get[4]>
- define drawnum %drawnum1%%drawnum2%%drawnum3%%drawnum4%
}
- if <def[num].is[==].to[%drawnum%]> {
- if <player.has_flag[pick4]> {
- flag player reward:5000
}
else {
- flag player reward:1000
}
}
- if <li@%num1%|%num2%|%num3%.contains[li@%drawnum1%|%drawnum2%|%drawnum3%]> {
- if !<player.has_flag[reward]> {
- if <player.has_flag[pick4]> {
- flag player reward:2000
}
else {
- flag player reward:350
}
}
}
- if !<player.has_flag[reward]> {
- if <player.has_flag[pick4]> {
- if <def[num].is[MORE].to[<def[drawnum].sub[16]>]> && <def[num].is[LESS].to[<def[drawnum].add[16]>]> {
- flag player reward:1000
}
}
else {
- if <def[num].is[MORE].to[<def[drawnum].sub[6]>]> && <def[num].is[LESS].to[<def[drawnum].add[6]>]> {
- flag player reward:250
}
}
}
- flag player pick4:!
timer:
- flag npc timer
- define hour <util.date.time.hour>
- wait 1h
- if <def[hour].is[==].to[24]> {
- inject locally dLottery_draw
- inject locally timer
}
else {
- inject locally timer
}
action:
- define loc <npc.location.add[-1,0,0]>
- look <npc> %loc%
- wait 1t
- animate <npc> animation:SNEAK
- repeat 3 {
- wait 1s
- animate <npc> animation:ARM_SWING
- if <npc.has_flag[openchest]> {
- if <npc.flag[openchest].is[==].to[2]> {
- animatechest %loc% close
- repeate stop
}
else {
- flag npc openchest:++:1
}
}
else {
- flag npc openchest:0
- animatechest %loc%
}
Pick3:
- ^narrate format:TBFormat "i'll have a Pick3 Ticket"
- ^flag player pick:3
- ^flag player name:<player.name>
- ^flag player foreachadd:3
- ^flag player setup
- ^inject locally chat
- ^inject locally action
- ^flag player setup:!
- ^flag player name:!
- ^take money qty:10
- ^flag player block:lime_clay
- ^run locally Picksetup
Pick4:
- ^narrate format:TBFormat "i'll have a Pick4 Ticket"
- ^if <player.money.is[LESS].to[25]> {
- ^narrate format:GenericNPCFormat "buddy, you don't have enough for this ticket, but you can buy a Pick3 ticket..."
- ^narrate format:GenericNPCFormat "click on me again and choose the Pick3 if you want a Pick3 ticket"
- ^queue clear
}
- ^flag player pick:4
- ^flag player name:<player.name>
- ^flag player foreachadd:3|4
- ^flag player setup
- ^inject locally chat
- ^inject locally action
- ^flag player setup:!
- ^flag player name:!
- ^take money qty:25
- ^flag player block:red_clay
- ^run locally Picksetup
Picksetup:
- define num <player.name>dLottery
- narrate format:GenericNPCFormat "now where did the pen go..."
- note in@generic[title=<&c>d<&9>Lottery<&sp><&c>T<&9>ickets;size=18] 'as:%num%'
- foreach li@1|2|<player.flag[foreachadd]> {
- inventory add 'd:in@%num%' 'o:<player.flag[block]>[display_name=<&e>Number_<&6>%loop_index%;lore=<&e>click to add]' 'slot:%loop_index%'
- flag player foreachadd:!
}
- inventory add 'd:in@%num%' 'o:i@sel_book' 'slot:18'
- wait 8t
- inventory open 'd:in@%num%'
dLottery_Pick3:
type: item
material: 339
display name: "<&e>M<&6>ine<&e>C<&6>onomy <&e>D<&6>lottery"
lore:
- "<&5><&sp><&sp><&sp><&sp><&sp><&sp><&sp><&sp><&sp><&a>P<&2>ick <&a>3"
- "<&5>-------------------------"
- "<&5>"
- "<&5><&f><&sp><&sp><&sp><&sp><&sp><&sp><&sp><&sp><&a>C<&2>ost <&f>$10"
- "<&5><&f><&sp>Pick 3 numbers and see if you win"
- "<&5>"
- "<&5><&sp><&sp><&sp><&a><&n>W<&2><&n>inings"
- "<&5>"
- "<&a><&sp>E<&2>xact <&a>N<&2>umber➛<&sp><&f>$1000"
- "<&a><&sp>S<&2>ame <&a>N<&2>umbers➛<&sp><&f>$350"
- "<&a><&sp>W<&2>ithin <&a>5➛<&sp><&f>$250"
- "<&5>"
dLottery_Pick4:
type: item
material: 339
display name: "<&e>M<&6>ine<&e>C<&6>onomy <&e>D<&6>lottery"
lore:
- "<&5><&sp><&sp><&sp><&sp><&sp><&sp><&sp><&sp><&sp><&c>P<&4>ick <&c>4"
- "<&5>-------------------------"
- "<&5>"
- "<&5><&f><&sp><&sp><&sp><&sp><&sp><&sp><&sp><&sp><&c>C<&4>ost <&f>$25"
- "<&5><&f><&sp>Pick 4 numbers and see if you win"
- "<&5>"
- "<&5><&sp><&sp><&sp><&c><&n>W<&4><&n>inings"
- "<&5>"
- "<&c><&sp>E<&4>xact <&c>N<&4>umber➛<&sp><&f>$5000"
- "<&c><&sp>S<&4>ame <&c>N<&4>umbers➛<&sp><&f>$2000"
- "<&c><&sp>W<&4>ithin <&c>15➛<&sp><&f>$1000"
- "<&5>"
sel_book:
type: item
material: book
display name: "<&e>click when done"
dLottery_Pick3_Ticket:
type: item
material: 339
display name: "<&e>M<&6>ine<&e>C<&6>onomy <&e>D<&6>lottery"
lore:
- "<&5><&sp><&sp><&sp><&sp><&sp><&sp><&sp><&sp><&sp><&a>P<&2>ick <&a>3"
- "<&5>-------------------------"
- "<&5>"
- "<&5><&f><&sp>Hand this to the clerk tomorrow"
- "<&5><&f><&sp>to see if you won!"
dLottery_Pick4_Ticket:
type: item
material: 339
display name: "<&e>M<&6>ine<&e>C<&6>onomy <&e>D<&6>lottery"
lore:
- "<&5><&sp><&sp><&sp><&sp><&sp><&sp><&sp><&sp><&sp><&c>P<&4>ick <&c>4"
- "<&5>-------------------------"
- "<&5>"
- "<&5><&f><&sp>Hand this to the clerk tomorrow"
- "<&5><&f><&sp>to see if you won!"