Paste #44590: Untitled Paste

Date: 2017/09/23 03:55:23 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


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
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423


TheFarmerCommand:
    type: command
    debug: false
    speed: 0
    name: thefarmer
    aliases:
    - farm
    - farmer
    script:
    - if <context.args.size> == 0  {
        - inject locally upgrade
        - queue clear
    }
    # antispam
    - if <player.is_player||false> {
        - if <player.has_flag[thefarmer.antispam]> {
            - queue clear
        }
        - flag <player> thefarmer.antispam duration:2s
    }
    - inject locally <context.args.get[1]>

    upgrade:
    - define page <def[1]||1>
    - inventory close
    - define GUI TheFarmerGUI_<def[page]>_<player.name>
    - note "in@TheFarmerInventory" as:<def[GUI]>
    - define TheFarmerHead "i@human_skull[display_name=<gold><player.name>;lore=li@<aqua>Niveau:<white> <player.flag[thefarmer.level]||0>|<aqua>Argent:<white> <player.flag[thefarmer.money]||0>|<aqua>Revenus:<white> <player.flag[thefarmer.income]||0>;skull_skin=<player.name>]"
    - inventory add d:in@<def[GUI]> o:<def[TheFarmerHead]> slot:50
    - if <def[page]> == 1 {

        - inventory add d:in@<def[GUI]> "o:i@seeds[display_name=<yellow>Graine de blé;lore=<aqua>Niveau<&co> <player.flag[thefarmer.items.seeds.level]||1>|<aqua>Coût<&co> <player.flag[thefarmer.items.seeds.level].mul[300]||300>$;nbt=price/<player.flag[thefarmer.items.seeds.level].mul[300]||300>]" slot:12
        - inventory add d:in@<def[GUI]> "o:i@wheat[display_name=<yellow>Blé;lore=<aqua>Niveau<&co> 1|<aqua>Coût<&co> 1500$]" slot:21
        - inventory add d:in@<def[GUI]> "o:i@bread[display_name=<yellow>Pain;lore=<aqua>Niveau<&co> 1|<aqua>Coût<&co> 6000$]" slot:30

        - inventory add d:in@<def[GUI]> "o:i@carrot_item[display_name=<yellow>Carotte;lore=<aqua>Niveau<&co> 1|<aqua>Coût<&co> 18000$]" slot:14
        - inventory add d:in@<def[GUI]> "o:i@pumpkin_pie[display_name=<yellow>Tarte à la carotte;lore=<aqua>Niveau<&co> 1|<aqua>Coût<&co> 27000$]" slot:23
        - inventory add d:in@<def[GUI]> "o:i@golden_carrot[display_name=<gold>Carotte dorée;lore=<aqua>Niveau<&co> 1|<aqua>Coût<&co> 90000$]" slot:32

        - inventory add d:in@<def[GUI]> "o:i@potato_item[display_name=<yellow>Patate;lore=<aqua>Niveau<&co> 1|<aqua>Coût<&co> 63k$]" slot:16
        - inventory add d:in@<def[GUI]> "o:i@baked_potato[display_name=<yellow>Patate cuite;lore=<aqua>Niveau<&co> 1|<aqua>Coût<&co> 130k$]" slot:25
        - inventory add d:in@<def[GUI]> "o:i@poisonous_potato[display_name=<gold>Patate empoisonnée;lore=<aqua>Niveau<&co> 1|<aqua>Coût<&co> 850k$]" slot:34

    } else if <def[page]> == 0 {
        - choose <player.flag[thefarmer.level]||0>:
            - case "0":
                - inventory add d:in@<def[GUI]> "o:i@coarse_dirt[display_name=<yellow>Ferme Niveau 1;lore=<aqua>Niveau<&co> 0|<aqua>Coût<&co> 90 000$;nbt=price/90000]" slot:11
            - case "1":
                - inventory add d:in@<def[GUI]> "o:i@grass[display_name=<yellow>Ferme Niveau 2;lore=<aqua>Niveau<&co> 1|<aqua>Coût<&co> 850 000$];nbt=price/850000]" slot:11
            - case "2":
                - inventory add d:in@<def[GUI]> "o:i@cobblestone[display_name=<yellow>Ferme Niveau 3;lore=<aqua>Niveau<&co> 2|<aqua>Coût<&co> 25k$];nbt=price/25000000]" slot:11
            - case "3":
                - inventory add d:in@<def[GUI]> "o:i@hay_block[display_name=<gold>Ferme Niveau 4;lore=<aqua>Niveau<&co> 3|<aqua>Coût<&co> 277k$];nbt=price/277000000]" slot:11
            - default:
                - narrate format:error_format "Niveau <player.flag[thefarmer.level]||0> non reconnu !"
    }
    - inventory open d:in@<def[GUI]>

    tp:
    - define cuboid <player.flag[thefarmer.cuboid].as_cuboid>
    # return first cuboid location (lowest)
    - define origin <def[cuboid].full.split[@].get[2].split[|].first.as_location>
    # abs(x/6)+1%2 si 0 alors pair, sinon 1 impaire
    - define mod <def[cuboid].split[_].get[2].div[6].abs.add_int[1].mod[2]>
    # pair: -78 7 -38
    # impair: -78 7 +38
    - if <def[mod]> == 1 {
        - define loc <def[origin].add[24,7,38]>
    } else {
        - define loc <def[origin].add[26,7,65]>
    }
    - teleport <player> <def[loc]>

# Assignment Script for Quester NPCs
TheFarmerAssignment:
  type: assignment
  debug: true
  actions:
    on assignment:
      - inject locally init instantly
    on spawn:
      - inject locally init instantly
    on click:
      - if <player.has_flag[thefarmer.money].not||true> {
          - inject locally start
          - queeu clear
      }
      - define product <player.item_in_hand.material.name||air>
      - inject locally <def[product]>
  init:
    - trigger name:click state:true cooldown:4 radius:8
  start:
    - define money 2000
    - narrate "<blue>The Farmer: <yellow>Bonjour <player.name> et bienvenue dans <dark_purple>The Farmer <yellow>!"
    - wait 3
    - narrate "<blue>The Farmer: <yellow>Le principe est simple, devenir le plus riche du monde !"
    - wait 4
    - narrate "<blue>The Farmer: <yellow>Pour cela, cherche une ferme à vendre et achete la."
    - wait 5
    - narrate "<blue>The Farmer: <yellow>Je te donne <def[money]>£ pour ça. Ensuite tu travaillera pour moi."
    - wait 8
    - narrate "<blue>The Farmer: <yellow>Bonne récolte !"
    - wait 2
    - flag player thefarmer.money:<def[money]>
    - actionbar "<green>+<def[amount]>$"
    - run instantly TheFarmerWorldEvents p:updatePlayerSidebar player:<player> delay:1t
    - wait 30
    - narrate "[Astuce] Utilisez <gray>/spawn<white> pour quitter."
  air:
    - narrate "<blue>The Farmer: <yellow>Ce n'est pas avec les mains vide que tu va gagner de l'argent."
  seeds:
    - narrate "<blue>The Farmer: <yellow>Super des graines !"
    - define price 1
    - define level <player.flag[thefarmer.items.seeds.level]||1>
    - define price <def[price].add[<def[level].mul[2]>]>
    - inject locally buy
  wheat:
    - narrate "<blue>The Farmer: <yellow>Le foin, les vaches adorent !"
    - define price 4
    - inject locally buy
  carrot_item:
    - narrate "<blue>The Farmer: <yellow>ça donne les fesse roses."
    - define price 8
    - inject locally buy
  potato_item:
    - narrate "<blue>The Farmer: <yellow>J'adore les patates."
    - define price 10
    - inject locally buy
  beetroot:
    - narrate "<blue>The Farmer: <yellow>Rouge comme le sang. J'achète."
    - define price 20
    - inject locally buy

  # define amount
  buy:
    - define quantity <player.inventory.quantity[<def[product]>]>
    - define amount <def[price].mul[<def[quantity]>]>
    - take <def[product]> from:<player.inventory> quantity:<def[quantity]>
    - wait 1
    - flag player thefarmer.money:+:<def[amount]>
    - actionbar "<green>+<def[amount]>$"
    - run instantly TheFarmerWorldEvents p:updatePlayerSidebar player:<player> delay:1t

TheFarmerWorldEvents:
    type: world
    debug: false
    events:
        on system time minutely:
        - foreach <w@Farmer.players||li@> {
            - define income <def[value].flag[thefarmer.income]||0>
            - if <def[income]> != 0 {
                - flag <def[value]> thefarmer.money:+:<def[income]>
                - run instantly TheFarmerWorldEvents p:updatePlayerSidebar player:<def[value]> delay:1t
                - actionbar "<green>+<def[income]>$" player:<def[value]>
            }
        }

        on reload scripts:
        # reload -a
        - if <context.all> {
            # create notable cuboids if not exist
            - if <farm_001.as_cuboid.notable_name||nope> == nope {
                - note cu@1089,55,1728,Farmer|1191,78,1831,Farmer as:farm_001
            }
            - if <farm_002.as_cuboid.notable_name||nope> == nope {
                - note cu@985,55,1728,Farmer|1087,78,1831,Farmer as:farm_002
            }
            - if <farm_003.as_cuboid.notable_name||nope> == nope {
                - note cu@881,55,1728,Farmer|983,78,1831,Farmer as:farm_003
            }
            - if <farm_004.as_cuboid.notable_name||nope> == nope {
                - note cu@777,55,1728,Farmer|879,78,1831,Farmer as:farm_004
            }
            - if <farm_005.as_cuboid.notable_name||nope> == nope {
                - note cu@673,55,1728,Farmer|775,78,1831,Farmer as:farm_005
            }
            - if <farm_006.as_cuboid.notable_name||nope> == nope {
                - note cu@569,55,1728,Farmer|671,78,1831,Farmer as:farm_006
            }

            - if <farm_007.as_cuboid.notable_name||nope> == nope {
                - note cu@1089,55,1839,Farmer|1191,78,1942,Farmer as:farm_007
            }
            - if <farm_008.as_cuboid.notable_name||nope> == nope {
                - note cu@985,55,1839,Farmer|1087,78,1942,Farmer as:farm_008
            }
            - if <farm_009.as_cuboid.notable_name||nope> == nope {
                - note cu@881,55,1839,Farmer|983,78,1942,Farmer as:farm_009
            }
            - if <farm_010.as_cuboid.notable_name||nope> == nope {
                - note cu@777,55,1839,Farmer|879,78,1942,Farmer as:farm_010
            }
            - if <farm_011.as_cuboid.notable_name||nope> == nope {
                - note cu@673,55,1839,Farmer|775,78,1942,Farmer as:farm_011
            }
            - if <farm_012.as_cuboid.notable_name||nope> == nope {
                - note cu@569,55,1839,Farmer|671,78,1942,Farmer as:farm_012
            }

            - if <farm_013.as_cuboid.notable_name||nope> == nope {
                - note cu@1089,55,1946,Farmer|1191,78,2049,Farmer as:farm_013
            }
            - if <farm_014.as_cuboid.notable_name||nope> == nope {
                - note cu@985,55,1946,Farmer|1087,78,2049,Farmer as:farm_014
            }
            - if <farm_015.as_cuboid.notable_name||nope> == nope {
                - note cu@881,55,1946,Farmer|983,78,2049,Farmer as:farm_015
            }
            - if <farm_016.as_cuboid.notable_name||nope> == nope {
                - note cu@777,55,1946,Farmer|879,78,2049,Farmer as:farm_016
            }
            - if <farm_017.as_cuboid.notable_name||nope> == nope {
                - note cu@673,55,1946,Farmer|775,78,2049,Farmer as:farm_017
            }
            - if <farm_018.as_cuboid.notable_name||nope> == nope {
                - note cu@569,55,1946,Farmer|671,78,2049,Farmer as:farm_018
            }

            - if <farm_019.as_cuboid.notable_name||nope> == nope {
                - note cu@1089,55,2057,Farmer|1191,78,2160,Farmer as:farm_019
            }
            - if <farm_020.as_cuboid.notable_name||nope> == nope {
                - note cu@985,55,2057,Farmer|1087,78,2160,Farmer as:farm_020
            }
            - if <farm_021.as_cuboid.notable_name||nope> == nope {
                - note cu@881,55,2057,Farmer|983,78,2160,Farmer as:farm_021
            }
            - if <farm_022.as_cuboid.notable_name||nope> == nope {
                - note cu@777,55,2057,Farmer|879,78,2160,Farmer as:farm_022
            }
            - if <farm_023.as_cuboid.notable_name||nope> == nope {
                - note cu@673,55,2057,Farmer|775,78,2160,Farmer as:farm_023
            }
            - if <farm_024.as_cuboid.notable_name||nope> == nope {
                - note cu@569,55,2057,Farmer|671,78,2160,Farmer as:farm_024
            }

            - if <farm_025.as_cuboid.notable_name||nope> == nope {
                - note cu@1089,55,2164,Farmer|1191,78,2267,Farmer as:farm_025
            }
            - if <farm_026.as_cuboid.notable_name||nope> == nope {
                - note cu@985,55,2164,Farmer|1087,78,2267,Farmer as:farm_026
            }
            - if <farm_027.as_cuboid.notable_name||nope> == nope {
                - note cu@881,55,2164,Farmer|983,78,2267,Farmer as:farm_027
            }
            - if <farm_028.as_cuboid.notable_name||nope> == nope {
                - note cu@777,55,2164,Farmer|151,78,2267,Farmer as:farm_028
            }
            - if <farm_029.as_cuboid.notable_name||nope> == nope {
                - note cu@673,55,2164,Farmer|775,78,2267,Farmer as:farm_029
            }
            - if <farm_030.as_cuboid.notable_name||nope> == nope {
                - note cu@569,55,2164,Farmer|671,78,2267,Farmer as:farm_030
            }
        }

        on player changes world to Farmer:
        - run instantly TheFarmerWorldEvents p:updatePlayerSidebar player:<player> delay:1t

        on player changes world from Farmer:
        - sidebar remove

        on player enters notable cuboid:
        - foreach <c.cuboids> {
            - define cuboid <def[value]>
            - define cuboidSplit <def[cuboid].notable_name.split[_]>
            - if <def[cuboidSplit].get[1]||null> != farm || <def[cuboidSplit].size> < 2 {
                - foreach next
            }
            - define owner <server.flag[thefarmer.cuboids.<def[cuboid]>.owner]||null>
            - if <player> == <def[owner]> {
                - narrate "<yellow>Bienvenue chez vous !"
            } else if <def[owner]> != null {
                - narrate "<yellow>Vous entrez chez <def[owner].name>."
            }
        }

        on player exits notable cuboid:
        - foreach <c.cuboids> {
            - define cuboid <def[value]>
            - define cuboidSplit <def[cuboid].notable_name.split[_]>
            - if <def[cuboidSplit].get[1]||null> != farm || <def[cuboidSplit].size> < 2 {
                - foreach next
            }
            - define owner <server.flag[thefarmer.cuboids.<def[cuboid]>.owner]||null>
            - if <player> == <def[owner]> {
                - narrate "<yellow>Revenez vite !"
            } else if <def[owner]> != null {
                - narrate "<yellow>Vous quittez la ferme à <def[owner].name>."
            }
        }

        on player clicks block in Farmer:
        # read sign
        - if <context.location.material.name> == sign_post || <context.location.material.name> == wall_sign {
            - if <context.location.sign_contents.first> != "<red>A vendre" {
                - queue clear
            }
            - if <player.flag[thefarmer.cuboid]||none> != none {
                - narrate format:error_format "Tu as déjà une ferme ! Tape /farmer home pour t'y rendre."
                - queue clear
            }
            - define cuboid <context.location.cuboids.first>
            - if <server.flag[thefarmer.cuboids.<def[cuboid]>.owner]||none> != none {
                - narrate format:error_format "Cette ferme appartient déjà à quelqu'un."
                - queue clear
            }
            - flag server thefarmer.cuboids.<def[cuboid]>.owner:<player>
            - flag player thefarmer.cuboid:<def[cuboid]>
            - define amount 2000
            - define money <player.flag[thefarmer.money]||0>
            - define income <player.flag[thefarmer.income]||0>
            - define level <player.flag[thefarmer.level]||0>
            - if <def[money]> < <def[amount]> {
                - narrate format:error_format "Vous n'avez pas assez d'argent."
                - queue clear
            }
            - define signText li@<gold>----|<blue>Chez|<blue><player.name>|<gold>----
            - adjust <c.location> sign_contents:<def[signText]>
            - actionbar "<red>-<def[amount]>$"
            - flag player thefarmer.money:-:<def[amount]>
            - run instantly TheFarmerWorldEvents p:updatePlayerSidebar player:<player> delay:1t
            - narrate "<gold>Bienvenue dans votre nouvelle ferme !"
        }

        #check if player is cubo owner
        - if <player.is_op.not> && <player.flag[thefarmer.cuboid].contains_any[<player.location.cuboids>].not||true> {
            - narrate format:error_format "Vous n'avez pas la permission"
            - determine passively cancelled
            - queue clear
        }

        on player breaks block in Farmer:
        - if <player.gamemode> == CREATIVE {
            - queue clear
        }
        - wait 2s
        - modifyblock <c.location> <context.material>

        on player closes inventory:
        - if <player.location.world> != "w@Farmer" {
            - queue clear
        }
        - if <c.inventory.notable_name.split[_].get[1]||null> == "TheFarmerGUI" {
            - note remove as:<context.inventory.notable_name>
        }

        on player clicks in inventory:
        - if <player.location.world> != "w@Farmer" {
            - queue clear
        }
        - if <c.inventory.notable_name.split[_].get[1]||null> != "TheFarmerGUI" {
            - queue clear
        }
        - if <c.slot_type> == "OUTSIDE" || <c.item> == i@air {
            - queue clear
        }
        - determine passively cancelled
        - define page <c.inventory.notable_name.split[_].get[2]||1>
        - inject locally p:inventoryClick

    # CLICK HANDLERS
    #################

    inventoryClick:
      # menu buttons
      - if <c.raw_slot> > 45 {
          - if <c.item> == <i@PreviousItem> {
              # show previous page
              - inventory close
              - run instantly TheFarmerCommand p:upgrade def:<def[page].sub[1]> player:<player> delay:1t
              - queue clear
          }
          - if <c.item> == <i@NextItem> {
              # show next page
              - inventory close
              - run instantly TheFarmerCommand p:upgrade def:<def[page].add[1]> player:<player> delay:1t
              - queue clear
          }
          - queue clear
      }

      - define price <c.item.nbt[price]>
      - define level <player.flag[thefarmer.items.seeds.level].add[1]||1>
      - narrate "<gold><c.item.display_name> est maintenant niveau <aqua><def[level]> <gold>!"
      - playsound <player> sound:BLOCK_COMPARATOR_CLICK
      - flag <player> thefarmer.items.<c.item.material.name>.level:<def[level]>
      - flag player thefarmer.money:-:<def[price]>
      - run instantly TheFarmerCommand p:upgrade def:<def[page]> player:<player> delay:1t

    updatePlayerSidebar:
      - define level <player.flag[thefarmer.level]||0>
      - define money <player.flag[thefarmer.money]||0>
      - define income <player.flag[thefarmer.income]||0>
      - sidebar set "title:The Farmer" "values:<blue>--------------------|<yellow>Niveau<&co><red><&sp><&sp><&sp><&sp><def[level]>|<yellow>Argent<&co><red><&sp><&sp><&sp><&sp><def[money]>|<yellow>Revenus<&co><red><&sp><&sp><def[income]>" "players:<player>"

TheFarmerInventory:
    type: inventory
    title: "<gold>The Farmer - Achats"
    size: 54
    slots:
    - "[] [] [] [] [] [] [] [] []"
    - "[] [] [] [] [] [] [] [] []"
    - "[] [] [] [] [] [] [] [] []"
    - "[] [] [] [] [] [] [] [] []"
    - "[] [] [] [] [] [] [] [] []"
    - "[i@PreviousItem] [i@SeparatorItem] [i@SeparatorItem] [i@SeparatorItem] [] [i@SeparatorItem] [i@SeparatorItem] [i@SeparatorItem] [i@NextItem]"

FarmerItem:
    type: item
    debug: false
    material: "i@human_skull[display_name=<blue>Oruss7;lore=<yellow>Niveau<&co> 2|<yellow>Argent<&co> 5000$|<yellow>Revenus<&co> 120$/m]"

PreviousItem:
    type: item
    debug: false
    material: i@stained_glass_pane:4[display_name=<yellow><&lt><&lt><&lt>]

NextItem:
    type: item
    debug: false
    material: i@stained_glass_pane:4[display_name=<yellow><&gt><&gt><&gt>]