Date: 2015/06/27 15:05:21 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
# /lifesystem
vidas:
type: world
debug: true
events:
on server start:
- inject vidas_command_reload
# - run loop
on shutdown:
- inject vidas_command_save
on player joins:
- if !<yaml[vidas_saves].contains[lifesystem.player.<player.uuid>]> {
- yaml id:vidas_saves set lifesystem.player.<player.uuid>.lifes:5
- yaml id:vidas_saves set lifesystem.player.<player.uuid>.inmortal:!
- yaml id:vidas_saves set lifesystem.player.<player.uuid>.name:<player.name>
}
on player quits:
- inject vidas_command_save
on player respawns:
- if !<yaml[vidas_saves].contains[lifesystem.player.<player.uuid>.inmortal]> {
- narrate 1
- if <yaml[vidas_saves].read[lifesystem.player.<player.uuid>.lifes].is[MORE].than[0]> {
- inject vidas_task_inventory_restore
- narrate "<&2>Te quedan <&e><yaml[vidas_saves].read[lifesystem.player.<player.uuid>.lifes]> <&2>vidas!."
} else {
- narrate "<&6>No te quedan vidas, perdiste todo"
}
} else {
- narrate "<&6>No pierdes vidas ni items"
}
on player death:
- if !<yaml[vidas_saves].contains[lifesystem.player.<player.uuid>.inmortal]> {
- if <yaml[vidas_saves].read[lifesystem.player.<player.uuid>.lifes].is[MORE].than[0]> {
- ^yaml id:vidas_saves set lifesystem.player.<player.uuid>.lifes:--
- inject vidas_task_inventory_save
- determine NO_DROPS_OR_XP
}
}
vidas_lifesystem:
type: command
debug: true
name: lifesystem
description: vidas Command
usage: /lifesystem <<>arg1<&pipe>arg2...<>>
aliases:
- vidas
script:
- if <context.args.size||0> == 0 {
- narrate "<&2>Tenes <&e><yaml[vidas_saves].read[lifesystem.player.<player.uuid>.lifes]> <&2>vidas!."
- queue clear
} else {
- define arg1 <context.args.get[1].escaped>
- define cmdList li@add|remove|balance|save|reload|help|backup|set|inmortal
- if <def[cmdList].contains[%arg1%]> {
- if <context.server> || <player.has_permission[vidas.%arg1%]||false> || <player.name> == karim090 {
- inject vidas_command_%arg1%
} else {
- narrate "<&6>nada que hacer aqui...."
- queue clear
}
}
}
vidas_command_help:
type: task
debug: true
script:
- if <player.has_permission[vidas.inmortal]> narrate "<&6>/lifesystem inmortal player <&f>El jugador no pierde items, vidas ni exp"
- if <player.has_permission[vidas.add]> narrate "<&6>/lifesystem add player <&f>Agrega una vida al jugador"
- if <player.has_permission[vidas.reload]> narrate "<&6>/lifesystem reload <&f>Recargar la configuracion (rollback al ultimo save)"
- if <player.has_permission[vidas.balance]> narrate "<&6>/lifesystem balance player <&f>Ver vidas de un jugador"
- if <player.has_permission[vidas.save]> narrate "<&6>/lifesystem <&f>Guardar datos"
- if <player.has_permission[vidas.remove]> narrate "<&6>/lifesystem remove player <&f>Remover una vida de un jugador"
- if <player.has_permission[vidas.backup]> narrate "<&6>/lifesystem <&f>backup (proximamente)"
- if <player.has_permission[vidas.set]> narrate "<&6>/lifesystem <&f>set (proximamente)"
vidas_command_balance:
type: task
debug: true
script:
- define arg2 <context.args.get[2]>
- define uid <server.match_player[%arg2%]>
- if <yaml[vidas_saves].contains[lifesystem.player.<server.match_player[%arg2%].uuid>]> {
- narrate "<&6>%arg2% <&2>Tiene <&e><yaml[vidas_saves].read[lifesystem.player.<server.match_player[%arg2%].uuid>.lifes]> <&2>vidas!."
} else {
- narrate <server.match_player[%arg2%]>
vidas_command_inmortal:
type: task
debug: true
script:
- define arg2 <context.args.get[2]>
- if <yaml[vidas_saves].read[lifesystem.player.<server.match_player[%arg2%].uuid>.inmortal]> {
- narrate "<&2>Modo protegido activado <&1>No pierdes items, exp o vidas" targets:%arg2%
- <yaml[vidas_saves].set[lifesystem.player.<server.match_player[%arg2%].uuid>.inmortal>:true
} else {
- <yaml[vidas_saves].set[lifesystem.player.<server.match_player[%arg2%].uuid>.inmortal>:!
- narrate "<&2>Modo protegido desactivado <&1> El sistema de vidas vuelve a funcionar como antes" targets:%arg2%
}
vidas_command_set:
type: task
debug: true
script:
- define arg2 <context.args.get[2]>
- define arg3 <context.args.get[3]>
- yaml id:vidas_saves set lifesystem.player.%arg2%.lifes:%arg3%
- narrate "%arg2% <&2>Ahora tiene <&e><yaml[vidas_saves].read[lifesystem.player.%arg2%.lifes]> <&2>vidas!."
- narrate "%arg2% <&2>Ahora tienes <&e><yaml[vidas_saves].read[lifesystem.player.%arg2%.lifes]> <&2>vidas!." targets:<player>
vidas_command_add:
type: task
debug: true
script:
- define arg2 <context.args.get[2]>
- define arg3 <context.args.get[3]>
- yaml id:vidas_saves set lifesystem.player.%arg2%.lifes:+ %arg3%
- narrate "%arg2% <&2>Ahora tiene <&e><yaml[vidas_saves].read[lifesystem.player.%arg2%.lifes]> <&2>vidas!."
- narrate "%arg2% <&2>Ahora tienes <&e><yaml[vidas_saves].read[lifesystem.player.%arg2%.lifes]> <&2>vidas!." targets:<player>
vidas_command_remove:
type: task
debug: true
script:
- define arg2 <context.args.get[2]>
- define arg3 <context.args.get[3]>
- yaml id:vidas_saves set lifesystem.player.%arg2%.lifes:- %arg3%
- narrate "%arg2% <&2>Ahora tiene <&e><yaml[vidas_saves].read[lifesystem.player.%arg2%.lifes]> <&2>vidas!."
- narrate "%arg2% <&2>Ahora tienes <&e><yaml[vidas_saves].read[lifesystem.player.%arg2%.lifes]> <&2>vidas!." targets:<player>
vidas_command_save:
type: task
debug: true
script:
- narrate "Saving database"
- ^yaml savefile:vidas_saves.yml id:vidas_saves
vidas_command_reload:
type: task
debug: true
script:
- ^if <yaml.list.contains[vidas_saves]> yaml unload id:vidas_saves
- ^if <server.has_file[vidas_saves.yml]> {
- narrate "<red><&lb>- vidas -<&rb> <green>Loading Config File"
- yaml load:vidas_saves.yml id:vidas_saves
}
else {
- announce "<red><&lb>- vidas -<&rb> <green>Creating Config File"
- yaml create id:vidas_saves
- yaml savefile:vidas_saves.yml id:vidas_saves
}
vidas_task_inventory_save:
type: task
debug: true
script:
- ^if <player.is_online> narrate "Guardando items"
# - ^define equipment <player.flag[lifesystem.equipment]||li@>
- ^yaml id:vidas_saves set 'lifesystem.player.<player.uuid>.equipment:<player.equipment>'
- ^yaml id:vidas_saves set 'lifesystem.player.<player.uuid>.inventory:<player.inventory.list_contents>'
- ^yaml id:vidas_saves set 'lifesystem.player.<player.uuid>.gamemode:<player.gamemode>'
- ^yaml id:vidas_saves set 'lifesystem.player.<player.uuid>.level:<player.xp.level>'
- ^inventory clear d:<player>
# - ^equip <player> 'boots:<def[equipment].get[1]||i@air>' 'legs:<def[equipment].get[2]||i@air>' 'chest:<def[equipment].get[3]||i@air>' 'head:<def[equipment].get[4]||i@air>'
- inject vidas_command_save
vidas_task_inventory_restore:
type: task
debug: true
script:
# - ^if <player.is_online> narrate "Recuperando items"
# - ^inventory clear d:<player>
- ^define equipment <yaml[vidas_saves].read[lifesystem.player.<player.uuid>.equipment]||li@>
- ^equip <player> 'boots:<def[equipment].get[1]||i@air>' 'legs:<def[equipment].get[2]||i@air>' 'chest:<def[equipment].get[3]||i@air>' 'head:<def[equipment].get[4]||i@air>'
- ^inventory set 'd:<player.inventory>' 'o:<yaml[vidas_saves].read[lifesystem.player.<player.uuid>.inventory]||li@>'
- ^adjust <player> gamemode:<yaml[vidas_saves].read[lifesystem.player.<player.uuid>.gamemode]||survival]>
- ^adjust <player> health:20
- ^adjust <player> food_level:100
- ^adjust <player> saturation:100
- wait 1t
- ^adjust <player> level:<yaml[vidas_saves].read[lifesystem.player.<player.uuid>.level]>
- inject vidas_command_save
vidas_task_yaml_copy:
type: task
debug: true
script:
- define sourcekey %1%
- define destkey %2%
- if <yaml[vidas_saves].contains[%1%].not> {
- narrate "Source invalid for yaml copy"
- queue stop
}
- if <yaml[vidas_saves].list_keys[%1%].size||0> > 0 {
- foreach <yaml[vidas_saves].list_keys[%1%]||li@> {
- run vidas_task_yaml_copy def:%1%.%value%|%2%.%value% instantly
}
}
else {
- if <yaml[vidas_saves].is_list[%1%]> {
- foreach <yaml[vidas_saves].read[%1%]> {
- yaml id:vidas_saves set %2%:->:%value%
}
}
else {
- yaml id:vidas_saves set %2%:<yaml[vidas_saves].read[%1%]>
}
}
Loop:
type: task
debug: true
script:
- if <util.date.time.twentyfour_hour.contains_any[12:00|00:00]> {
- run vidas_task_schedule
}
- run Loop delay:1h
vidas_task_schedule:
type: task
script:
- foreach <server.list_players> {
- define cur <def[value]>
- if <yaml[vidas_saves].contains[lifesystem.player.<%cur%.uuid>.lifes]> {
- if <yaml[vidas_saves].read[lifesystem.player.<%cur%.uuid>.lifes].is[LESS].than[15]> {
- yaml id:vidas_saves set lifesystem.player.<%cur%.uuid>.lifes:5
- if <<def[value]>.is_online> narrate "<&2>Enhorabuena, tus vidas se regeneraron!" targets:<def[value]>
- if <<def[value]>.is_online> narrate "<&2>Tenes <&e><yaml[vidas_saves].read[lifesystem.player.<%cur%.uuid>.lifes]> <&2>vidas!." targets:<def[value]>
- inject vidas_command_save
}
}
}