Date: 2018/10/23 16:34:11 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
ShopCreatorInv:
type: inventory
display name: Shop Editor
size: 54
slots:
- "[] [] [] [] [] [] [] [] []"
- "[] [] [] [] [] [] [] [] []"
- "[] [] [] [] [] [] [] [] []"
- "[] [] [] [] [] [] [] [] []"
- "[] [] [] [] [] [] [] [] [i@SaveShopIt]"
- "[i@ClearCostIt] [i@CostMinus1It] [i@CostMinus1It] [i@CostMinus1It] [i@CostMinus1It] [i@CostPlus1It] [i@CostPlus10It] [i@CostPlus100It] [i@CostPlus1000It]"
Procedural Items:
- if <player.has_flag[EditShop]> && <player.has_flag[AdjustedCost].not> {
- determine <yaml[<player.flag[EditShop].get[1]>].read[<player.flag[EditShop].get[2]>]>
- queue clear
}
- if <player.has_flag[AdjustedCost]> {
- determine <player.flag[AdjustedCost]>
}
ShopCreatorHandler:
type: world
debug: true
events:
on player drags in ShopCreatorInv:
- determine cancelled
on player clicks in ShopCreatorInv with item:
- if <context.cursor_item.material.name.contains[CostPlus]> || <context.cursor_item.material.name.contains[CostMinus]> || <context.cursor_item.material.name.contains[ClearCost]> {
- determine passively cancelled
- queue clear
}
- if <context.item.material.name.contains[CostPlus]> || <context.item.material.name.contains[ClearCost]> || <context.item.material.name.contains[CostMinus]> || <context.item.material.name.contains[SaveShop]> {
- determine passively cancelled
- queue clear
}
- if <context.item_on_cursor.lore.contains[Cost<&c>]> {
- queue clear
} else {
- adjust <context.item> "lore:<context.item.lore.insert[Click Here to Buy!|Cost: $0]>" save:adjustedcost
- flag player AdjustedCost:<player.open_inventory.list_contents.set[<entry[adjustedcost].result>].at[<context.slot>]>
- inventory open d:in@ShopCreatorInv
}
on player clicks item in ShopCreatorInv:
- if <context.item.material.name.contains[CostPlus]> || <context.item.material.name.contains[CostMinus]> {
- if <player.item_on_cursor.material.name> == <context.item.material.name> {
- if <player.item_on_cursor.quantity> == 64 {
- determine passively cancelled
- queue clear
} else {
- determine passively cancelled
- adjust <context.cursor_item> quantity:<context.cursor_item.quantity.add[1]> save:AdjustCost
- adjust <player> item_on_cursor:<entry[AdjustCost].result>
}
} else {
- determine passively cancelled
- adjust <player> item_on_cursor:<context.item>
}
}
- if <context.item.material.name.contains[SaveShop]> {
- determine passively cancelled
- queue clear
}
- if <context.item.material.name.contains[ClearCost]> {
- determine passively cancelled
- queue clear
}
on player clicks item with CostPlus1It in ShopCreatorInv:
- if <context.item.material.name.contains[CostPlus]> || <context.item.material.name.contains[ClearCost]> || <context.item.material.name.contains[CostMinus]> || <context.item.material.name.contains[SaveShop]> {
- determine passively cancelled
- queue clear
}
- adjust <context.item> "lore:<context.item.lore.insert[Click Here to Buy!|Cost: $<context.item.lore.after[$].add[<context.item_on_cursor.quantity>]>]>" save:adjustedcost
- flag player AdjustedCost:<player.open_inventory.list_contents.set[<entry[adjustedcost].result>].at[<context.slot>]>
- inventory close
- inventory open d:in@ShopCreatorInv
on player clicks item with CostPlus10It in ShopCreatorInv:
- if <context.item.material.name.contains[CostPlus]> || <context.item.material.name.contains[ClearCost]> || <context.item.material.name.contains[CostMinus]> || <context.item.material.name.contains[SaveShop]> {
- determine passively cancelled
- queue clear
}
- determine passively cancelled
- adjust <context.item> "lore:<context.item.lore.insert[Click Here to Buy!|Cost: $<context.item.lore.after[$].add[<context.item_on_cursor.quantity.mul[10]>]>]>" save:adjustedcost
- flag player AdjustedCost:<player.open_inventory.list_contents.set[<entry[adjustedcost].result>].at[<context.slot>]>
- inventory open d:in@ShopCreatorInv
on player clicks item with CostPlus100It in ShopCreatorInv:
- if <context.item.material.name.contains[CostPlus]> || <context.item.material.name.contains[ClearCost]> || <context.item.material.name.contains[CostMinus]> || <context.item.material.name.contains[SaveShop]> {
- determine passively cancelled
- queue clear
}
- determine passively cancelled
- adjust <context.item> "lore:<context.item.lore.insert[Click Here to Buy!|Cost: $<context.item.lore.after[$].add[<context.item_on_cursor.quantity.mul[100]>]>]>" save:adjustedcost
- flag player AdjustedCost:<player.open_inventory.list_contents.set[<entry[adjustedcost].result>].at[<context.slot>]>
- inventory open d:in@ShopCreatorInv
on player clicks item with CostPlus1000It in ShopCreatorInv:
- if <context.item.material.name.contains[CostPlus]> || <context.item.material.name.contains[ClearCost]> || <context.item.material.name.contains[CostMinus]> || <context.item.material.name.contains[SaveShop]> {
- determine passively cancelled
- queue clear
}
- determine passively cancelled
- adjust <context.item> "lore:<context.item.lore.insert[Click Here to Buy!|Cost: $<context.item.lore.after[$].add[<context.item_on_cursor.quantity.mul[1000]>]>]>" save:adjustedcost
- flag player AdjustedCost:<player.open_inventory.list_contents.set[<entry[adjustedcost].result>].at[<context.slot>]>
- inventory open d:in@ShopCreatorInv
on player clicks item with CostMinus1It in ShopCreatorInv:
- if <context.item.material.name.contains[CostPlus]> || <context.item.material.name.contains[ClearCost]> || <context.item.material.name.contains[CostMinus]> || <context.item.material.name.contains[SaveShop]> {
- determine passively cancelled
- queue clear
}
- if <context.item.lore.after[$].sub[<context.item_on_cursor.quantity>]> < 0 {
- determine passively cancelled
- narrate "You cannot have a cost below $0!"
- queue clear
}
- adjust <context.item> "lore:<context.item.lore.insert[Click Here to Buy!|Cost: $<context.item.lore.after[$].sub[<context.item_on_cursor.quantity>]>]>" save:adjustedcost
- flag player AdjustedCost:<player.open_inventory.list_contents.set[<entry[adjustedcost].result>].at[<context.slot>]>
- inventory close
- inventory open d:in@ShopCreatorInv
on player clicks item with CostMinus10It in ShopCreatorInv:
- if <context.item.material.name.contains[CostPlus]> || <context.item.material.name.contains[ClearCost]> || <context.item.material.name.contains[CostMinus]> || <context.item.material.name.contains[SaveShop]> {
- determine passively cancelled
- queue clear
}
- if <context.item.lore.after[$].sub[<context.item_on_cursor.quantity.mul[10]>]> < 0 {
- determine passively cancelled
- narrate "You cannot have a cost below $0!"
- queue clear
}
- determine passively cancelled
- adjust <context.item> "lore:<context.item.lore.insert[Click Here to Buy!|Cost: $<context.item.lore.after[$].sub[<context.item_on_cursor.quantity.mul[10]>]>]>" save:adjustedcost
- flag player AdjustedCost:<player.open_inventory.list_contents.set[<entry[adjustedcost].result>].at[<context.slot>]>
- inventory open d:in@ShopCreatorInv
on player clicks item with CostMinus100It in ShopCreatorInv:
- if <context.item.material.name.contains[CostPlus]> || <context.item.material.name.contains[ClearCost]> || <context.item.material.name.contains[CostMinus]> || <context.item.material.name.contains[SaveShop]> {
- determine passively cancelled
- queue clear
}
- if <context.item.lore.after[$].sub[<context.item_on_cursor.quantity.mul[100]>]> < 0 {
- determine passively cancelled
- narrate "You cannot have a cost below $0!"
- queue clear
}
- determine passively cancelled
- adjust <context.item> "lore:<context.item.lore.insert[Click Here to Buy!|Cost: $<context.item.lore.after[$].sub[<context.item_on_cursor.quantity.mul[100]>]>]>" save:adjustedcost
- flag player AdjustedCost:<player.open_inventory.list_contents.set[<entry[adjustedcost].result>].at[<context.slot>]>
- inventory open d:in@ShopCreatorInv
on player clicks item with CostMinus1000It in ShopCreatorInv:
- if <context.item.material.name.contains[CostPlus]> || <context.item.material.name.contains[ClearCost]> || <context.item.material.name.contains[CostMinus]> || <context.item.material.name.contains[SaveShop]> {
- determine passively cancelled
- queue clear
}
- if <context.item.lore.after[$].sub[<context.item_on_cursor.quantity.mul[1000]>]> < 0 {
- determine passively cancelled
- narrate "You cannot have a cost below $0!"
- queue clear
}
- determine passively cancelled
- adjust <context.item> "lore:<context.item.lore.insert[Click Here to Buy!|Cost: $<context.item.lore.after[$].sub[<context.item_on_cursor.quantity.mul[1000]>]>]>" save:adjustedcost
- flag player AdjustedCost:<player.open_inventory.list_contents.set[<entry[adjustedcost].result>].at[<context.slot>]>
- inventory open d:in@ShopCreatorInv
on player left clicks ClearCostIt in ShopCreatorInv:
- determine passively cancelled
- adjust <player> item_on_cursor:i@air
on player right clicks ClearCostIt in ShopCreatorInv:
- determine passively cancelled
- adjust <player> item_on_cursor:i@ClearCostIt
on player clicks item with ClearCostIt in ShopCreatorInv:
- if <context.item.material.name.contains[CostPlus]> || <context.item.material.name.contains[ClearCost]> || <context.item.material.name.contains[CostMinus]> || <context.item.material.name.contains[SaveShop]> {
- determine passively cancelled
- queue clear
}
- adjust <context.item> "lore:<context.item.lore.insert[Click Here to Buy!|Cost: $0]>" save:adjustedcost
- flag player AdjustedCost:<player.open_inventory.list_contents.set[<entry[adjustedcost].result>].at[<context.slot>]>
- inventory open d:in@ShopCreatorInv
on player clicks SaveShopIt in ShopCreatorInv:
- narrate "Shop Inventory:<player.flag[ShopCreator].get[2]> has been saved to File:<player.flag[ShopCreator].get[1]>.yml!"
- foreach <player.open_inventory.list_contents> {
- yaml id:<player.flag[ShopCreator].get[1]> set <player.flag[ShopCreator].get[2]>:->:<def[value]>
}
- yaml savefile:/Shops/<player.flag[ShopCreator].get[1]>.yml id:<player.flag[ShopCreator].get[1]>
- yaml unload id:<player.flag[ShopCreator].get[1]>
- flag player AdjustedCost:!
- flag player EditShop:!
- flag player ShopCreator:!
- inventory close
ShopCreatorCmd:
type: command
name: createshop
usage: /createshop
description: "Use to create a list for a Denizen shop script. /createshop File:{FileName} Shop:{ShopName} | add Delete to delete a shop | add Edit to edit an existing shop."
permission: denizen.shopcreator
script:
##Delete Shop##
- if <context.args.contains[Delete]> {
- if <server.has_file[/Shops/<context.args.map_get[File].split_by[<&co>]>.yml].not> {
- narrate "The File: <context.args.map_get[File].split_by[<&co>]>.yml does not exist! Did you type it in correctly?"
- queue clear
}
- yaml load:/Shops/<context.args.map_get[File].split_by[<&co>]>.yml id:<context.args.map_get[File].split_by[<&co>]>
- if <yaml[<context.args.map_get[File].split_by[<&co>]>].contains[<context.args.map_get[Shop].split_by[<&co>]>].not> {
- narrate "The Shop: <context.args.map_get[Shop].split_by[<&co>]> does not exist in File: <context.args.map_get[File].split_by[<&co>]>! Did you type it in correctly?"
- queue clear
}
- yaml id:<context.args.map_get[File].split_by[<&co>]> set: <context.args.map_get[Shop].split_by[<&co>]>:!
- yaml savefile:/Shops/<context.args.map_get[File].split_by[<&co>]>.yml id:<context.args.map_get[File].split_by[<&co>]>
- narrate "The Shop: <context.args.map_get[Shop].split_by[<&co>]> in File: <context.args.map_get[File].split_by[<&co>]> has been deleted!"
- queue clear
}
##Edit Shop##
- if <context.args.contains[Edit]> {
- if <server.has_file[/Shops/<context.args.map_get[File].split_by[<&co>]>.yml].not> {
- narrate "The File: <context.args.map_get[File].split_by[<&co>]>.yml does not exist! Did you type it in correctly?"
- queue clear
}
- yaml load:/Shops/<context.args.map_get[File].split_by[<&co>]>.yml id:<context.args.map_get[File].split_by[<&co>]>
- if <yaml[<context.args.map_get[File].split_by[<&co>]>].contains[<context.args.map_get[Shop].split_by[<&co>]>].not> {
- narrate "The Shop: <context.args.map_get[Shop].split_by[<&co>]> does not exist in File: <context.args.map_get[File].split_by[<&co>]>! Did you type it in correctly?"
- queue clear
}
- flag player EditShop:<context.args.map_get[File].split_by[<&co>]>|<context.args.map_get[Shop].split_by[<&co>]>
- inventory open d:in@ShopCreatorInv
- queue clear
}
##Create Shop##
- if <server.has_file[/Shops/<context.args.map_get[File].split_by[<&co>]>.yml].not> {
- yaml create id:<context.args.map_get[File].split_by[<&co>]>
- yaml savefile:/Shops/<context.args.map_get[File].split_by[<&co>]>.yml id:<context.args.map_get[File].split_by[<&co>]>
}
- yaml load:/Shops/<context.args.map_get[File].split_by[<&co>]>.yml id:<context.args.map_get[File].split_by[<&co>]>
- flag player ShopCreator:<context.args.map_get[File].split_by[<&co>]>|<context.args.map_get[File].split_by[<&co>]>
- inventory open d:in@ShopCreatorInv
##Shop Creator Items##
SaveShopIt:
type: item
display name: Save Shop
material: i@writable_book
lore:
- "Click here to save this shop inventory."
ClearCostIt:
type: item
display name: Clear Cursor
material: i@barrier
lore:
- "Click here to clear cost items from your cursor."
CostPlus1It:
type: item
display name: Add $1
material: i@stone
lore:
- "Click here to add $1 to the price"
- "of an item. With this item in hand"
- "click on an item. It will add $1"
- "for each item in the held stack."
CostPlus10It:
type: item
display name: Add $10
material: i@iron_block
lore:
- "Click here to add $10 to the price"
- "of an item. With this item in hand"
- "click on an item. It will add $10"
- "for each item in the held stack."
CostPlus100It:
type: item
display name: Add $100
material: i@gold_block
lore:
- "Click here to add $100 to the price"
- "of an item. With this item in hand"
- "click on an item. It will add $100"
- "for each item in the held stack."
CostPlus1000It:
type: item
display name: Add $1000
material: i@stone
lore:
- "Click here to add $1000 to the price"
- "of an item. With this item in hand"
- "click on an item. It will add $1000"
- "for each item in the held stack."
CostMinus1It:
type: item
display name: Subtract $1
material: i@stone
lore:
- "Click here to subtract $1 to the price"
- "of an item. With this item in hand"
- "click on an item. It will subtract $1"
- "for each item in the held stack."
CostMinus10It:
type: item
display name: Subtract $10
material: i@iron_block
lore:
- "Click here to subtract $10 to the price"
- "of an item. With this item in hand"
- "click on an item. It will subtract $10"
- "for each item in the held stack."
CostMinus100It:
type: item
display name: Subtract $100
material: i@gold_block
lore:
- "Click here to subtract $100 to the price"
- "of an item. With this item in hand"
- "click on an item. It will subtract $100"
- "for each item in the held stack."
CostMinus1000It:
type: item
display name: Subtract $1000
material: i@stone
lore:
- "Click here to subtract $1000 to the price"
- "of an item. With this item in hand"
- "click on an item. It will subtract $1000"
- "for each item in the held stack."