Date: 2017/10/27 14:54:27 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
ShopPrisonShop1_Data:
type: yaml data
config:
materials:
Melon: 10
STONE_PICKAXE : 25
COAL: 8
IRON_INGOT: 25
LEATHER: 8
## <s@Shop_Data.yaml_key[config.price.stone]> returns invalid
ShopPrisonShop1_Events:
type: world
events:
on server start:
- inject ShopPrisonShop1_Reload
on reload scripts:
- inject ShopPrisonShop1_Reload
on player clicks in ShopPrisonShop1_Menu:
- determine cancelled passively
- define item <context.item.material.after[m@]>
- if <def[item]> == air {
- queue clear
}
- if <s@ShopPrisonShop1_Data.list_keys[config.materials].contains[<def[item]>].not> {
- narrate format:util_ff "<&c>Det item er har ikke noget værdi."
- queue clear
}
- if <player.inventory.is_full> {
- narrate format:util_ff "<&c>Din inventory er fuld!"
- queue clear
}
- define brought <s@ShopPrisonShop1_Data.yaml_key[config.materials.<def[item]>]>
- if <player.money> < <def[brought]> {
- narrate format:util_ff "<&c>Du har ikke penge nok!"
- queue clear
}
- give <def[item]> qty:1
- take money quantity:<def[brought]>
- narrate format:util_ff "<&a>Købte <&b>1 <def[item]> <&a>for <&6>$<def[brought]>"
- inventory open d:in@ShopPrisonShop1_Menu
on player drags in ShopPrisonShop1_Menu:
- determine cancelled
ShopPrisonShop1_Main:
type: assignment
actions:
on assignment:
- trigger name:click state:true
interact scripts:
- 10 ShopPrisonShop1_Assign
ShopPrisonShop1_Reload:
type: task
script:
- flag server ShopPrisonShop1_Items:!
- foreach <s@ShopPrisonShop1_Data.list_keys[config.materials].sort[ShopPrisonShop1_Sort].reverse> {
- flag server ShopPrisonShop1_Items:->:<def[value]>[lore=<proc[ShopPrisonShop1_Proc].context[2|<def[value]>]>]
}
ShopPrisonShop1_Sort:
type: procedure
definitions: p1|p2
script:
- if <s@ShopPrisonShop1_Data.yaml_key[config.materials.<def[p2]>]> > <s@ShopPrisonShop1_Data.yaml_key[config.materials.<def[p1]>]> {
- determine 1
}
else if <s@ShopPrisonShop1_Data.yaml_key[config.materials.<def[p1]>]> > <s@ShopPrisonShop1_Data.yaml_key[config.materials.<def[p2]>]> {
- determine -1
}
else {
- determine 0
}
ShopPrisonShop1_Assign:
type: interact
steps:
1:
click trigger:
script:
- run ShopPrisonShop1_Task player:<player> npc:<npc> instantly
ShopPrisonShop1_Task:
type: task
script:
- inventory open d:in@ShopPrisonShop1_Menu
- random {
- narrate "<&8>[<&a><npc.name><&8>] <&6>Kig lidt rundt."
- narrate "<&8>[<&a><npc.name><&8>] <&6>Noget du vil have?"
- narrate "<&8>[<&a><npc.name><&8>] <&6>Ting sælges for en rimelig pris."
- narrate "<&8>[<&a><npc.name><&8>] <&6>Tag et kig på hvad jeg har."
- narrate "<&8>[<&a><npc.name><&8>] <&6>Kan jeg hjælpe dig med noget?"
- narrate "<&8>[<&a><npc.name><&8>] <&6>Er der noget du vil have?"
}
ShopPrisonShop1_Menu:
type: inventory
inventory: CHEST
title: <&3>Shop <&8>- <&3>Køb
size: 18
definitions:
Close: i@stone
slots:
- "[] [] [] [] [] [] [] [] []"
- "[] [] [] [] [] [] [] [] []"
procedural items:
- determine <server.flag[ShopPrisonShop1_Items].as_list>
# - flag player CTF_Config_SameClass_kits:!
# - foreach <yaml[ctf_maps].list_keys[ctf.maps]> {
# - flag player CTF_Config_SameClass_kits:->:<proc[CTF_LobbyMenu_Menu_MapSelection_Proc].context[1|<def[value]>]>[display_name=<proc[CTF_LobbyMenu_Menu_MapSelection_Proc].context[2|<def[value]>]>;lore=<proc[CTF_LobbyMenu_Menu_MapSelection_Proc].context[3|<def[value]>]>|<proc[CTF_LobbyMenu_Menu_MapSelection_Proc].context[4|<def[value]>]>]
# }
ShopPrisonShop1_Proc:
type: procedure
debug: false
definitions: line|item
script:
- choose "<def[line]>":
- case "2":
- determine "<&3>Koster<&co> <&b>$<s@ShopPrisonShop1_Data.yaml_key[config.materials.<def[item]>]>"
- default:
- determine "Chosen default in <def[item]>"