- 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: NPCItemShop


By Seq
Created: 2015/11/15 19:53:46 UTC-08:00 (8 years and 189 days ago)
Edited: 2015/11/16 05:33:41 UTC-08:00 (8 years and 189 days ago)
Likes: 1

Staff pick as of: 2015/11/15 21:17:55 UTC-08:00 (8 years and 189 days ago)
Denizen Version: 0.9.7
Script Version: 0.4
Description:

Create Item shops with NPCs.

Installation:
Drop in your scripts folder and reload scripts. Once you assign the script to an NPC click them to set the shop type.

More shop types can be added like so:

------NewShopType:
--------1:
----------name: 'Potion of Healing II' <------Displayed name
----------item: 'potion,8229' <---------------Item,Metadata
----------cost: 50 <--------------------------Price
----------qty: 10 <---------------------------Quantity


Note: Make sure indentation lines up if you add new shops. Additionally you must have an economy plugin that is compatible with Vault and Vault to use the cost or disable cost in the config.

UseCost: Either true or false

DestroyMaterial: 'flint' <--- This value needs to be an item.


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

###################
#\\\_^^NPC^^^_////#
#////ItemShop/////#
#\\\\||||||||\\\\\#
#||||by SeqSEE||||#
#/\/\/\/\/\/\/\/\/#
#------v0.4-------#
###################
ItemShop_Config:
  type: yaml data
  Shops:
  ###############################################################################################################
  #-Change this to what material you want to remove shops.   Default: 'flint'-----------------------------------#
  ###############################################################################################################
    DestroyMaterial'flint'
  ###############################################################################################################
  #-Set to false if you don't wan't to charge or if you do not have an economy plugin and Vault  Default: true--#
  ###############################################################################################################
    UseCost: true
    Types:
  ###############################################################################################################
  #---ShopName:-------------------------------------------------------------------------------------------------#
  #-----1:------------------------------------------------------------------------------------------------------#
  #-------name: 'Display Name' --(May vary with resource packs)-------------------------------------------------#
  #-------item: 'Item(,Metadata)'-------------------------------------------------------------------------------#
  #-------cost: 100---------------------------------------------------------------------------------------------#
  #-------qty: 1------------------------------------------------------------------------------------------------#
  ###############################################################################################################
      Health:
        1:
          name'Potion of Healing'
          item'potion,8197'
          cost: 50
          qty:  1
        2:
          name'Potion of Healing II'
          item'potion,8229'
          cost: 75
          qty:  1
        3:
          name'Splash Potion of Healing'
          item'potion,16389'
          cost: 75
          qty:  1
        4:
          name'Splash Potion of Healing II'
          item'potion,16421'
          cost: 125
          qty:  1
        5:
          name'Potion of Regeneration'
          item'potion,8193'
          cost: 150
          qty:  1
        6:
          name'Potion of Regeneration (extended)'
          item'potion,8257'
          cost: 200
          qty:  1
        7:
          name'Potion of Regeneration II'
          item'potion,8225'
          cost: 225
          qty:  1
        8:
          name'Splash Potion of Regeneration'
          item'potion,16385'
          cost: 175
          qty:  1
        9:
          name'Splash Potion of Regeneration (extended)'
          item'potion,16449'
          cost: 200
          qty:  1
        10:
          name'Splash Potion of Regeneration II'
          item'potion,16417'
          cost: 250
          qty:  1
      Weapons:
        1:
          name'Wooden Dagger'
          item'wooden_sword'
          cost: 25
          qty:  1
        2:
          name'Stone Whip'
          item'stone_sword'
          cost: 50
          qty:  1
        3:
          name'Crowbar'
          item'iron_sword'
          cost: 100
          qty:  1
        4:
          name'Golden Axeblade'
          item'golden_sword'
          cost: 150
          qty:  1
        5:
          name'Diamond Light Saber'
          item'diamond_sword'
          cost: 350
          qty:  1
        6:
          name'Bow'
          item'bow'
          cost: 100
          qty:  1
        7:
          name'Arrows (16)'
          item'arrow'
          cost: 50
          qty:  16
        8:
          name'Arrows (32)'
          item'arrow'
          cost: 100
          qty:  32
        9:
          name'Arrows (64)'
          item'arrow'
          cost: 150
          qty:  64
      Redstone:
        1:
          name'Red Matter (32)'
          item'redstone'
          cost: 100
          qty:  32
        2:
          name'Red Power Torch (16)'
          item'redstone_torch_on'
          cost: 100
          qty:  16
        3:
          name'Repeater (2)'
          item'diode'
          cost: 50
          qty:  2
        4:
          name'Comparator'
          item'redstone_comparator'
          cost: 50
          qty:  1
        5:
          name'Red Power Block'
          item'redstone_block'
          cost: 50
          qty:  1
        6:
          name'Piston'
          item'piston_base'
          cost: 50
          qty:  1
        7:
          name'Sticky Piston'
          item'piston_sticky_base'
          cost: 100
          qty:  1
      Armor:
        1:
          name'Blacksmith Boots'
          item'chainmail_boots'
          cost: 175
          qty:  1
        2:
          name'Blacksmith Leggings'
          item'chainmail_leggings'
          cost: 250
          qty:  1
        3:
          name'Blacksmith Chestplate'
          item'chainmail_chestplate'
          cost: 300
          qty:  1
        4:
          name'Blacksmith Goggles'
          item'chainmail_helmet'
          cost: 175
          qty:  1
        5:
          name'Iron Boots'
          item'iron_boots'
          cost: 100
          qty:  1
        6:
          name'Iron Leggings'
          item'iron_leggings'
          cost: 150
          qty:  1
        7:
          name'Iron Chestplate'
          item'iron_chestplate'
          cost: 175
          qty:  1
        8:
          name'Iron Helmet'
          item'iron_helmet'
          cost: 125
          qty:  1
        9:
          name'Gold Boots'
          item'gold_boots'
          cost: 150
          qty:  1
        10:
          name'Gold Leggings'
          item'gold_leggings'
          cost: 300
          qty:  1
        11:
          name'Gold Chestplate'
          item'gold_chestplate'
          cost: 350
          qty:  1
        12:
          name'Gold Helmet'
          item'gold_helmet'
          cost: 250
          qty:  1
        13:
          name'Diamond Boots'
          item'diamond_boots'
          cost: 300
          qty:  1
        14:
          name'Diamonds Leggings'
          item'diamond_leggings'
          cost: 450
          qty:  1
        15:
          name'Diamond Chestplate'
          item'diamond_chestplate'
          cost: 525
          qty:  1
        16:
          name'Diamond Helmet'
          item'diamond_helmet'
          cost: 375
          qty:  1
      Horse:
        1:
          name'Saddle'
          item'saddle'
          cost: 500
          qty: 1
        2:
          name'Iron Horse Armor'
          item'ironhorsearmor'
          cost: 800
          qty: 1
        3:
          name'Gold Horse Armor'
          item'goldenhorsearmor'
          cost: 1100
          qty: 1
        4:
          name'Diamond Horse Armor'
          item'diamondhorsearmor'
          cost: 1400
          qty: 1
        5:
          name'Rope'
          item'leash'
          cost: 20
          qty: 1
        6:
          name'Name Tag'
          item'name_tag'
          cost: 200
          qty: 1
ItemShop:
  type: assignment
  debug: true
  actions:
      on assignment:
      - trigger name:click state:true
      - trigger name:chat state:true
      - flag npc ItemShop.Creator:!
      - flag npc ItemShop.CurrentNumber:!
      - flag npc ItemShop.HasShop:!
      - flag npc ItemShop.Type:!
      - zap 1 s@Shop_Keeper
  interact scripts:
  - 1 Shop_Keeper
Shop_Remove:
  type: task
  debug: true
  script:
  - remove <npc>
Shop_Keeper:
    type: interact
    debug: true
    steps:
        1:
            click trigger:
                script:
                - if <npc.has_flag[ItemShop.HasShop]> {
                  - zap 2
                  - queue stop
                }
                - narrate "Please choose a shop type."
                - foreach <s@ItemShop_Config.list_keys[Shops.Types]> {
                  - narrate "<&7>%value%"
                  - wait 1t
                  }
                - narrate "<&e>(Shop Type/List)"
            chat trigger:
                1:
                    trigger: /List/
                    script:
                    - narrate "Please choose a shop type."
                    - foreach <s@ItemShop_Config.list_keys[Shops.Types]> {
                      - narrate "<&7>%value%"
                      - wait 1t
                      }
                    - narrate "<&e>(Shop Type/List)"
                2:
                    trigger/regex:([a-zA-Z])\w+/
                    script:
                    - if <s@ItemShop_Config.list_keys[Shops.Types].contains[<context.message>].not> {
                      - narrate "<npc.name><&co> <&c><context.message> is not a valid shop type!"
                      - queue stop
                      }
                    - flag npc ItemShop.Creator:<player.name>
                    - flag npc ItemShop.HasShop:1
                    - flag npc ItemShop.Type:<context.message>
                    - execute as_server "denizen save"
                    - narrate "Set shop as <npc.flag[ItemShop.Type]> shop type."
                    - narrate "Use <s@ItemShop_Config.yaml_key[Shops.DestroyMaterial]> to destroy this shop."
                    - zap 2
        2:
            click trigger:
                script:
                - if <player.item_in_hand.matches[<s@ItemShop_Config.yaml_key[Shops.DestroyMaterial].as_item>]> && <npc.flag[ItemShop.Creator].matches[<player.name>]>  {
                    - narrate "<npc.name><&co> Does this mean I'm fired?"
                    - narrate "<&e>(Yes/No)"
                    - zap 3
                    - queue stop
                  }
                - narrate "<npc.name><&co> Hello! What would you like to buy today?"
                - narrate "<&e>(Cancel/Item Number/List)"
            chat trigger:
                1:
                    trigger: /Cancel/
                    script:
                    - narrate "<npc.name><&co> Okay."
                    - wait 1
                    - narrate "<npc.name><&co> I'll be here still if you change your mind!"
                2:
                    trigger: /No/
                    script:
                    - narrate "<npc.name><&co> Okay."
                    - wait 1
                    - narrate "<npc.name><&co> I'll be here still if you change your mind!"
                3:
                    trigger: /List/
                    script:
                    - flag npc ItemShop.CurrentNumber:0
                    - narrate ""
                    - foreach <s@ItemShop_Config.list_keys[Shops.Types.<npc.flag[ItemShop.Type]>]> {
                      - flag npc ItemShop.CurrentNumber:++
                      - narrate "<&8><npc.flag[ItemShop.CurrentNumber].as_int> <&7><s@ItemShop_Config.yaml_key[Shops.Types.<npc.flag[ItemShop.Type]>.<npc.flag[ItemShop.CurrentNumber].as_int>.name]> <&a>$<s@ItemShop_Config.yaml_key[Shops.Types.<npc.flag[ItemShop.Type]>.<npc.flag[ItemShop.CurrentNumber].as_int>.cost]>"
                      - wait 1t
                      }
                    - wait 1t
                    - narrate ""
                    - narrate "<npc.name><&co> See anything you want?"
                    - wait 1t
                    - narrate "<&e>(No/Item Number)"
                4:
                    trigger/regex:([0-9])+/
                    script:
                    - if <s@ItemShop_Config.list_keys[Shops.Types.<npc.flag[ItemShop.Type]>].contains[<context.message>].not> {
                      - narrate "<npc.name><&co> <&c><context.message> is not a valid item number!"
                      - queue stop
                      }
                    - if <s@ItemShop_Config.yaml_key[Shops.UseCost].matches[true]> {
                      - if <player.money.is[LESS].than[<s@ItemShop_Config.yaml_key[Shops.Types.<npc.flag[ItemShop.Type]>.<context.message>.cost]>]||true> {
                        - narrate "<npc.name><&co><&c> Sorry, you don't have enough money."
                        - queue stop
                        }
                      - if <s@ItemShop_Config.yaml_key[Shops.Types.<npc.flag[ItemShop.Type]>.<context.message>.item].as_item||null> != null {
                        - take money quantity:<s@ItemShop_Config.yaml_key[Shops.Types.<npc.flag[ItemShop.Type]>.<context.message>.cost]>
                        - give <s@ItemShop_Config.yaml_key[Shops.Types.<npc.flag[ItemShop.Type]>.<context.message>.item].as_item> quantity:<s@ItemShop_Config.yaml_key[Shops.Types.<npc.flag[ItemShop.Type]>.<context.message>.qty]>
                        - narrate "<npc.name><&co> Thanks for doing business with me!"
                        - flag npc ItemShop.CurrentNumber:!
                        - queue stop
                        }
                      - narrate "<npc.name><&co> <&c>Sorry, that item is currently unavailable."
                      }
                    - if <s@ItemShop_Config.yaml_key[Shops.Types.<npc.flag[ItemShop.Type]>.<context.message>.item].as_item||null> != null {
                      - give <s@ItemShop_Config.yaml_key[Shops.Types.<npc.flag[ItemShop.Type]>.<context.message>.item].as_item> quantity:<s@ItemShop_Config.yaml_key[Shops.Types.<npc.flag[ItemShop.Type]>.<context.message>.qty]>
                      - narrate "<npc.name><&co> Thanks for doing business with me!"
                      - flag npc ItemShop.CurrentNumber:!
                      - queue stop
                        }
                    - if <player.name.matches[<npc.flag[ItemShop.Creator]>]||false> {
                      - narrate "<npc.name><&co> <&c>Hate to say it, but something is wrong with this item in the config!"
                      - queue stop
                      }
                    - narrate "<npc.name><&co> <&c>Sorry, that item is currently unavailable."
        3:
            click trigger:
                script:
                - narrate "<npc.name><&co> Does this mean I'm fired?"
                - narrate "<&e>(Yes/No)"
            chat trigger:
                1:
                    trigger: /Yes/
                    script:
                    - narrate "<npc.name><&co> Very well, it was a pleasure serving you!"
                    - inject s@Shop_Remove
                2:
                    trigger: /No/
                    script:
                    - zap 2







View History