· 8 years ago · Nov 25, 2017, 12:40 PM
1on load:
2 execute "CREATE TABLE IF NOT EXISTS Coordonnees (id VARCHAR(13) NOT NULL ,region SMALLINT UNSIGNED NOT NULL ,PRIMARY KEY (id))" in {sql}
3 execute "CREATE TABLE IF NOT EXISTS Regions (id SMALLINT UNSIGNED NOT NULL ,nom VARCHAR(30) NOT NULL ,couleur VARCHAR(2),origine VARCHAR(13) NOT NULL ,PRIMARY KEY (id))" in {sql}
4
5on right click with air:
6 if player is op:
7 cancel event
8 set {_x} to floor(x-coordinate of event-location)
9 set {_z} to floor(z-coordinate of event-location)
10 set {_loc} to location at {_x}, 0, {_z} in "WarShovel"
11 set {_biome} to biome at {_loc}
12 if {_biome} is beach or cold beach or stone beach or deep ocean:
13 set {_biome} to ocean
14
15 if {coord::%{_x}%.%{_z}%} is not set:
16 set {_id} to "%{_x}%.%{_z}%"
17 execute "SELECT region FROM Coordonnees WHERE id = %{_id}%" in {sql} and store the result in {_coord::*}
18 set {coord::%{_x}%.%{_z}%} to {_coord::region::1}
19
20 message "%{_x}%.%{_z}%: %{coord::%{_x}%.%{_z}%}% %{_biome}%"
21
22command /regionlist:
23 trigger:
24 message "%size of {regions::*}% régions:"
25 loop {regions::*}:
26 message "* %loop-index%"
27
28command /bb:
29 trigger:
30 message "%size of {regions.chunks.traite::*}%"
31 loop {regions.chunks.traite::*}:
32 message "%loop-index%"
33
34command /regiondeleteall:
35 trigger:
36 message "Suppression des régions."
37 wait 1 tick
38 set {regions::<none>} to true
39 set {regions::0} to true
40 loop {regions::*}:
41 regiondelete(loop-index)
42 loop 1000 times:
43 regiondelete("%loop-value%")
44 delete {regions::*}
45 delete {coord::*}
46 delete {regions.chunks.traite::*}
47 delete {chunks.attente::*}
48 delete {chunks.attente.idrecherche::*}
49 delete {bords.attente::*}
50
51 execute "TRUNCATE TABLE Regions" in {sql}
52 execute "TRUNCATE TABLE Coordonnees" in {sql}
53 message "Suppression des régions effectuée."
54
55command /regiondelete <number>:
56 trigger:
57 message "Suppression de la région %number-arg%."
58 regiondelete("%number-arg%")
59 message "Suppression de la région %number-arg% effectuée."
60
61function regiondelete(n: text):
62 delete {regions::%{_n}%}
63 loop {regions.%{_n}%.coord::*}:
64 delete {coord::%loop-index%}
65 delete {regions.%{_n}%.coord::*}
66 delete {regions.%{_n}%.tracer::*}
67 delete {regions.%{_n}%.info::*}
68 loop {chunks.attente::*}:
69 if {chunks.attente.idrecherche::%loop-index%} is {_n}:
70 delete {chunks.attente::%loop-index%}
71 delete {chunks.attente.idrecherche::%loop-index%}
72 make console execute "dmarker deletearea set:regions id:region%{_n}%"
73 execute "DELETE FROM Coordonnees WHERE region = '%{_n}%" in {sql}
74 execute "DELETE FROM Regions WHERE id = '%{_n}%" in {sql}
75
76function regioncheck(loc: location) :: number:
77 if world of {_loc} is "WarShovel":
78 set {_x} to floor(x-coordinate of {_loc})
79 set {_z} to floor(z-coordinate of {_loc})
80
81 set {_bdd} to bddlecture("SELECT region FROM Coordonnees WHERE ID = %{_x}%.%{_z}%")
82 loop 60 times:
83 if {bdd.lecture::%{_bdd}%} is "attente":
84 wait 1 tick
85 else:
86 exit loop
87 set {_coord} to bddsortie("%{_bdd}%")
88 if {_coord} is not set:
89 chunktraitement("%chunk at {_loc}%", "-1")
90
91function chunkcheck(chunkname: text, idregion: text):
92 if {regions.chunks.traite::%{_chunkname}%} is not set:
93
94 loop {chunks.attente::*}:
95 set {_num} to loop-index parsed as number
96 add 1 to {_num}
97 if {chunks.attente::%{_num}%} is not set:
98 set {chunks.attente::%{_num}%} to {_chunkname}
99 set {chunks.attente.idrecherche::%{_num}%} to {_idregion}
100on load:
101 delete {chunks.traitement}
102
103every 60 tick:
104 if size of {chunks.attente::*} is not 0:
105 if {chunks.traitement} is not set:
106 loop {chunks.attente::*}:
107 chunktraitement("%loop-value%", "%{chunks.attente.idrecherche::%loop-index%}%")
108 delete {chunks.attente::%loop-index%}
109 delete {chunks.attente.idrecherche::%loop-index%}
110 stop
111command /yy:
112 trigger:
113 set {coord.lecture} to 16
114function chunktraitement(chunkname: text, n: text):
115 broadcast "CHUNK TRAITEMENT"
116 if {regions.chunks.traite::%{_chunkname}%} is not set:
117 replace all "chunk (" with "" in {_chunkname}
118 replace all ") of WarShovel" with "" in {_chunkname}
119 set {_xz::*} to {_chunkname} split at ","
120
121 set {_xchunk} to {_xz::1} parsed as number
122 set {_zchunk} to {_xz::2} parsed as number
123
124 set {_xplage} to {_xchunk}*16
125 set {_zplage} to {_zchunk}*16
126
127 set {_debut} to now
128
129 set {_xchunkbis} to {_xchunk}-1
130 set {_zchunkbis} to {_zchunk}-1
131 if {regions.chunks.traite::%{_xchunkbis}%,%{_zchunkbis}%} is set:
132 set {_x} to {_xplage}-1
133 set {_z} to {_zplage}-1
134 if {coord::%{_x}%.%{_z}%} is not set:
135 set {_chargement::%{_x}%.%{_z}%} to true
136 set {_xchunkbis} to {_xchunk}-1
137 set {_zchunkbis} to {_zchunk}+1
138 if {regions.chunks.traite::%{_xchunkbis}%,%{_zchunkbis}%} is set:
139 set {_x} to {_xplage}-1
140 set {_z} to {_zplage}+16
141 if {coord::%{_x}%.%{_z}%} is not set:
142 set {_chargement::%{_x}%.%{_z}%} to true
143 set {_xchunkbis} to {_xchunk}+1
144 set {_zchunkbis} to {_zchunk}-1
145 if {regions.chunks.traite::%{_xchunkbis}%,%{_zchunkbis}%} is set:
146 set {_x} to {_xplage}+16
147 set {_z} to {_zplage}-1
148 if {coord::%{_x}%.%{_z}%} is not set:
149 set {_chargement::%{_x}%.%{_z}%} to true
150 set {_xchunkbis} to {_xchunk}+1
151 set {_zchunkbis} to {_zchunk}+1
152 if {regions.chunks.traite::%{_xchunkbis}%,%{_zchunkbis}%} is set:
153 set {_x} to {_xplage}+16
154 set {_z} to {_zplage}+16
155 if {coord::%{_x}%.%{_z}%} is not set:
156 set {_chargement::%{_x}%.%{_z}%} to true
157 set {_xchunkbis} to {_xchunk}-1
158 set {_zchunkbis} to {_zchunk}
159 if {regions.chunks.traite::%{_xchunkbis}%,%{_zchunkbis}%} is set:
160 set {_x} to {_xplage}-1
161 set {_z} to {_zplage}
162 loop 16 times:
163 set {_chargement::%{_x}%.%{_z}%} to true
164 add 1 to {_z}
165 set {_xchunkbis} to {_xchunk}+1
166 set {_zchunkbis} to {_zchunk}
167 if {regions.chunks.traite::%{_xchunkbis}%,%{_zchunkbis}%} is set:
168 set {_x} to {_xplage}+16
169 set {_z} to {_zplage}
170 loop 16 times:
171 set {_chargement::%{_x}%.%{_z}%} to true
172 add 1 to {_z}
173 set {_xchunkbis} to {_xchunk}
174 set {_zchunkbis} to {_zchunk}-1
175 if {regions.chunks.traite::%{_xchunkbis}%,%{_zchunkbis}%} is set:
176 set {_x} to {_xplage}
177 set {_z} to {_zplage}-1
178 loop 16 times:
179 set {_chargement::%{_x}%.%{_z}%} to true
180 add 1 to {_x}
181 set {_xchunkbis} to {_xchunk}
182 set {_zchunkbis} to {_zchunk}+1
183 if {regions.chunks.traite::%{_xchunkbis}%,%{_zchunkbis}%} is set:
184 set {_x} to {_xplage}
185 set {_z} to {_zplage}+16
186 loop 16 times:
187 set {_chargement::%{_x}%.%{_z}%} to true
188 add 1 to {_x}
189
190 loop {_chargement::*}:
191 coordlecture(loop-index)
192
193 set {coord.lecture} to 0
194 while {coord.lecture} is not size of {_chargement::*}:
195 wait 1 tick
196
197 delete {coord.lecture::*}
198
199
200 set {_x} to {_xplage}
201 loop 16 times:
202
203 set {_z} to {_zplage}
204 loop 16 times:
205
206 delete {_riviere}
207 set {_loc} to location at {_x}, 0, {_z} in "WarShovel"
208 if {_x} is greater than 10000:
209 set {_riviere} to true
210 else if {_x} is less than -10000:
211 set {_riviere} to true
212 if {_z} is greater than 10000:
213 set {_riviere} to true
214 else if {_z} is less than -10000:
215 set {_riviere} to true
216 set {_biome} to biome at {_loc}
217 if {_biome} is river or frozen river:
218 set {_riviere} to true
219 if {_biome} is beach or cold beach or stone beach or deep ocean:
220 set {_biome} to ocean
221
222 if {_riviere} is not set:
223 set {_l} to 0
224 loop 8 times:
225 add 1 to {_l}
226 if {_l} is 1:
227 set {_xbis} to {_x}
228 set {_zbis} to {_z}-1
229 else if {_l} is 2:
230 set {_xbis} to {_x}-1
231 set {_zbis} to {_z}-1
232 else if {_l} is 3:
233 set {_xbis} to {_x}-1
234 set {_zbis} to {_z}
235 else if {_l} is 4:
236 set {_xbis} to {_x}-1
237 set {_zbis} to {_z}+1
238 else if {_l} is 5:
239 set {_xbis} to {_x}
240 set {_zbis} to {_z}+1
241 else if {_l} is 6:
242 set {_xbis} to {_x}+1
243 set {_zbis} to {_z}+1
244 else if {_l} is 7:
245 set {_xbis} to {_x}+1
246 set {_zbis} to {_z}
247 else if {_l} is 8:
248 set {_xbis} to {_x}+1
249 set {_zbis} to {_z}-1
250
251 if {coord::%{_xbis}%.%{_zbis}%} is set:
252 set {_loc} to location at {_xbis}, 0, {_zbis} in "WarShovel"
253 set {_biomebis} to biome at {_loc}
254 if {_biomebis} is beach or cold beach or stone beach or deep ocean:
255 set {_biomebis} to ocean
256
257 if {_biomebis} is {_biome}:
258 if {coord::%{_x}%.%{_z}%} is not set:
259 regionadd({_x},{_z},{coord::%{_xbis}%.%{_zbis}%})
260 else if {coord::%{_x}%.%{_z}%} is not {coord::%{_xbis}%.%{_zbis}%}:
261 set {_i} to {coord::%{_x}%.%{_z}%}
262 set {_j} to {coord::%{_xbis}%.%{_zbis}%}
263 execute "SELECT id FROM Coordonnees WHERE region = %{_i}%" in {sql} and store the result in {_size::*}
264 execute "SELECT id FROM Coordonnees WHERE region = %{_j}%" in {sql} and store the result in {_sizebis::*}
265 if size of {_size::id::*} is greater than size of {_sizebis::id::*}:
266 execute "UPDATE Coordonnees SET region = %{_i}% WHERE region = %{_j}%" in {sql}
267 loop {coord::*}:
268 if loop-value-4 is {_j}:
269 set {coord::%loop-index%} to {_i}
270 regiondelete("%{_j}%")
271 else:
272 execute "UPDATE Coordonnees SET region = %{_j}% WHERE region = %{_i}%" in {sql}
273 loop {coord::*}:
274 if loop-value-4 is {_i}:
275 set {coord::%loop-index%} to {_j}
276
277 regiondelete("%{_i}%")
278
279 if {coord::%{_x}%.%{_z}%} is not set:
280 broadcast "CALCUL %{_x}%.%{_z}%"
281 set {_num} to 1
282 broadcast "Size: %size of {regions::*}%"
283 loop {regions::*} times:
284
285 broadcast "looping: %loop-value-3% || %loop-index%"
286 if {regions::%{_num}%} is not set:
287 exit loop
288 add 1 to {_num}
289
290 if {regions::%{_num}%} is set:
291 broadcast "ERREUR %{_x}%.%{_z}%"
292 make console execute "regiondeleteall"
293 wait 10 tick
294 make console execute "regiondeleteall"
295 wait 10 tick
296 make console execute "regiondeleteall"
297
298 set {_loc} to location at {_x}, 0, {_z} in "WarShovel"
299 set {_biome} to biome at {_loc}
300 broadcast "NOUVEAU %{_num}% %{_biome}%"
301 set {regions::%{_num}%} to true
302
303 regioncreation({_num},"%{_x}%.%{_z}%")
304 regionadd({_x},{_z},{_num})
305
306 set {_traitement::%{coord::%{_x}%.%{_z}%}%} to true
307
308 add 1 to {_z}
309 add 1 to {_x}
310
311
312 broadcast "CHUNK TRAITEE EN %difference between {_debut} and now%"
313
314 delete {coord::*}
315
316 loop {_traitement::*}:
317 if loop-index is {_n}:
318 set {bords.attente::%loop-index%} to true
319
320 set {regions.chunks.traite::%{_chunkname}%} to true
321
322 if {_n} is "-1":
323 if size of {_traitement::*} is 1:
324 loop {_traitement::*}:
325 set {_id} to loop-index
326 set {_xchunkbis} to {_xchunk}
327 set {_zchunkbis} to {_zchunk}-1
328 chunkcheck("%{_xchunkbis}%,%{_zchunkbis}%","-1")
329 set {_xchunkbis} to {_xchunk}
330 set {_zchunkbis} to {_zchunk}+1
331 chunkcheck("%{_xchunkbis}%,%{_zchunkbis}%","-1")
332 set {_xchunkbis} to {_xchunk}-1
333 set {_zchunkbis} to {_zchunk}
334 chunkcheck("%{_xchunkbis}%,%{_zchunkbis}%","-1")
335 set {_xchunkbis} to {_xchunk}+1
336 set {_zchunkbis} to {_zchunk}
337 chunkcheck("%{_xchunkbis}%,%{_zchunkbis}%","-1")
338 else:
339 loop {_traitement::*}:
340 if {_id} is not set:
341 set {_id} to loop-index
342 set {_max} to size of {regions.%loop-index%.coord::*}
343 else:
344 if size of {regions.%loop-index%.coord::*} is greater than {_max}:
345 set {_id} to loop-index
346 set {_max} to size of {regions.%loop-index%.coord::*}
347
348 set {_xchunkbis} to {_xchunk}
349 set {_zchunkbis} to {_zchunk}-1
350 chunkcheck("%{_xchunkbis}%,%{_zchunkbis}%",{_id})
351 set {_xchunkbis} to {_xchunk}
352 set {_zchunkbis} to {_zchunk}+1
353 chunkcheck("%{_xchunkbis}%,%{_zchunkbis}%",{_id})
354 set {_xchunkbis} to {_xchunk}-1
355 set {_zchunkbis} to {_zchunk}
356 chunkcheck("%{_xchunkbis}%,%{_zchunkbis}%",{_id})
357 set {_xchunkbis} to {_xchunk}+1
358 set {_zchunkbis} to {_zchunk}
359 chunkcheck("%{_xchunkbis}%,%{_zchunkbis}%",{_id})
360 else:
361 if {_traitement::%{_n}%} is set:
362 set {_xchunkbis} to {_xchunk}
363 set {_zchunkbis} to {_zchunk}-1
364 chunkcheck("%{_xchunkbis}%,%{_zchunkbis}%",{_n})
365 set {_xchunkbis} to {_xchunk}
366 set {_zchunkbis} to {_zchunk}+1
367 chunkcheck("%{_xchunkbis}%,%{_zchunkbis}%",{_n})
368 set {_xchunkbis} to {_xchunk}-1
369 set {_zchunkbis} to {_zchunk}
370 chunkcheck("%{_xchunkbis}%,%{_zchunkbis}%",{_n})
371 set {_xchunkbis} to {_xchunk}+1
372 set {_zchunkbis} to {_zchunk}
373 chunkcheck("%{_xchunkbis}%,%{_zchunkbis}%",{_n})
374
375 delete {chunks.traitement}
376
377function coordlecture(id: text):
378 execute "SELECT region FROM Coordonnees WHERE id = %{_id}%" in {sql} and store the result in {_query::*}
379 set {coord::%{_id}%} to {_query::region::1}
380 add 1 to {coord.lecture}
381
382command /xx:
383 trigger:
384 regioncheck(player's location)
385
386function regionadd(x: number, z: number , n: number):
387 set {coord::%{_x}%.%{_z}%} to {_n}
388 set {_id} to "%{_x}%.%{_z}%"
389 execute "INSERT INTO Coordonnees (`id`,`region`) VALUES (%{_id}%, %{_n}%)" in {sql}
390
391function regioncreation(n: number, origine: text):
392 set {regions::%{_n}%} to true
393 execute "INSERT INTO Regions (`id`,`nom`,`couleur`,`origine`) VALUES (%{_n}%, 'Inconnue', '&7', %{_origine}%)" in {sql}
394
395on load:
396 delete {bord.encour}
397
398every 1 minutes:
399 if {bord.encour} is not set:
400 if size of {bords.attente::*} is not 0:
401 loop {bords.attente::*}:
402 set {bord.encour} to true
403 regionbordcalcul(loop-index)
404 delete {bords.attente::%loop-index%}
405 delete {bord.encour}
406 stop
407
408command /regionforcerbord <text>:
409 trigger:
410 regionbordcalcul(text-arg)
411
412function regionbordcalcul(n: text):
413
414 if {_n} is "0":
415 stop
416
417 execute "SELECT id FROM Coordonnees WHERE region = %{_n}%" in {sql} and store the result in {_coord::*}
418 if size of {_coord::id::*} is less than 256:
419 make console execute "dmarker deletearea set:regions id:region%{_n}%"
420 stop
421
422 loop {_coord::id::*}:
423 set {_coord::%loop-value%} to true
424
425
426 delete {regions.%{_n}%.tracer::*}
427
428 execute "SELECT origine FROM Regions WHERE id = %{_n}%" in {sql} and store the result in {_origine::*}
429 set {_xz::*} to {_origine::origine::*} split at "."
430
431 set {_x} to {_xz::1} parsed as number
432 set {_z} to {_xz::2} parsed as number
433
434 loop {_coord::*}:
435 set {_xbis} to {_x}+1
436 set {_zbis} to {_z}
437 if {_coord::%{_xbis}%.%{_zbis}%} is not set:
438 set {regions.%{_n}%.tracer::1} to "%{_x}%.%{_z}%"
439 set {_traite::%loop-index%} to true
440 exit loop
441 add 1 to {_x}
442
443 set {_origine} to {regions.%{_n}%.tracer::1}
444 execute "UPDATE Regions SET origine = %{_origine}% WHERE region = %{_n}%" in {sql}
445 set {_traite::%{_origine}%} to true
446
447 set {_direction} to 1
448 set {_id} to 1
449 loop 100000 times:
450 set {_xz::*} to {regions.%{_n}%.tracer::%{_id}%} split at "."
451 set {_x} to {_xz::1} parsed as number
452 set {_z} to {_xz::2} parsed as number
453
454 add 1 to {_id}
455 delete {_libre}
456 delete {_occupe}
457
458 if {_direction} is equal to 1:
459 set {_xbis} to {_x}
460 set {_zbis} to {_z}-1
461 if {_coord::%{_xbis}%.%{_zbis}%} is not set:
462 set {_libre} to 1
463 else:
464 if {_coord::%{_xbis}%.%{_zbis}%} is not {_coord::%{_x}%.%{_z}%}:
465 set {_libre} to 1
466 else:
467 set {_occupe} to 1
468 set {_occupe.coord} to "%{_xbis}%.%{_zbis}%"
469
470 if {_direction} is less or equal to 2:
471 set {_xbis} to {_x}+1
472 set {_zbis} to {_z}-1
473 if {_coord::%{_xbis}%.%{_zbis}%} is not set:
474 set {_libre} to 2
475 else:
476 if {_coord::%{_xbis}%.%{_zbis}%} is not {_coord::%{_x}%.%{_z}%}:
477 set {_libre} to 2
478 else:
479 set {_occupe} to 2
480 set {_occupe.coord} to "%{_xbis}%.%{_zbis}%"
481
482 if {_libre}+1 is {_occupe}:
483 set {_id.1} to {_id}-1
484 if {_traite::%{_occupe.coord}%} is {regions.%{_n}%.tracer::%{_id.1}%}:
485 exit loop
486 set {regions.%{_n}%.tracer::%{_id}%} to {_occupe.coord}
487 set {_traite::%{_occupe.coord}%} to {regions.%{_n}%.tracer::%{_id.1}%}
488 set {_direction} to 8
489
490 if {regions.%{_n}%.tracer::%{_id}%} is not set:
491 if {_direction} is less or equal to 3:
492 set {_xbis} to {_x}+1
493 set {_zbis} to {_z}
494 if {_coord::%{_xbis}%.%{_zbis}%} is not set:
495 set {_libre} to 3
496 else:
497 if {_coord::%{_xbis}%.%{_zbis}%} is not {_coord::%{_x}%.%{_z}%}:
498 set {_libre} to 3
499 else:
500 set {_occupe} to 3
501 set {_occupe.coord} to "%{_xbis}%.%{_zbis}%"
502
503 if {_libre}+1 is {_occupe}:
504 set {_id.1} to {_id}-1
505 if {_traite::%{_occupe.coord}%} is {regions.%{_n}%.tracer::%{_id.1}%}:
506 exit loop
507 set {regions.%{_n}%.tracer::%{_id}%} to {_occupe.coord}
508 set {_traite::%{_occupe.coord}%} to {regions.%{_n}%.tracer::%{_id.1}%}
509 set {_direction} to 1
510
511 if {regions.%{_n}%.tracer::%{_id}%} is not set:
512 if {_direction} is less or equal to 4:
513 set {_xbis} to {_x}+1
514 set {_zbis} to {_z}+1
515 if {_coord::%{_xbis}%.%{_zbis}%} is not set:
516 set {_libre} to 4
517 else:
518 if {_coord::%{_xbis}%.%{_zbis}%} is not {_coord::%{_x}%.%{_z}%}:
519 set {_libre} to 4
520 else:
521 set {_occupe} to 4
522 set {_occupe.coord} to "%{_xbis}%.%{_zbis}%"
523
524 if {_libre}+1 is {_occupe}:
525 set {_id.1} to {_id}-1
526 if {_traite::%{_occupe.coord}%} is {regions.%{_n}%.tracer::%{_id.1}%}:
527 exit loop
528 set {regions.%{_n}%.tracer::%{_id}%} to {_occupe.coord}
529 set {_traite::%{_occupe.coord}%} to {regions.%{_n}%.tracer::%{_id.1}%}
530 set {_direction} to 2
531
532 if {regions.%{_n}%.tracer::%{_id}%} is not set:
533 if {_direction} is less or equal to 5:
534 set {_xbis} to {_x}
535 set {_zbis} to {_z}+1
536 if {_coord::%{_xbis}%.%{_zbis}%} is not set:
537 set {_libre} to 5
538 else:
539 if {_coord::%{_xbis}%.%{_zbis}%} is not {_coord::%{_x}%.%{_z}%}:
540 set {_libre} to 5
541 else:
542 set {_occupe} to 5
543 set {_occupe.coord} to "%{_xbis}%.%{_zbis}%"
544
545 if {_libre}+1 is {_occupe}:
546 set {_id.1} to {_id}-1
547 if {_traite::%{_occupe.coord}%} is {regions.%{_n}%.tracer::%{_id.1}%}:
548 exit loop
549 set {regions.%{_n}%.tracer::%{_id}%} to {_occupe.coord}
550 set {_traite::%{_occupe.coord}%} to {regions.%{_n}%.tracer::%{_id.1}%}
551 set {_direction} to 3
552
553 if {regions.%{_n}%.tracer::%{_id}%} is not set:
554 if {_direction} is less or equal to 6:
555 set {_xbis} to {_x}-1
556 set {_zbis} to {_z}+1
557 if {_coord::%{_xbis}%.%{_zbis}%} is not set:
558 set {_libre} to 6
559 else:
560 if {_coord::%{_xbis}%.%{_zbis}%} is not {_coord::%{_x}%.%{_z}%}:
561 set {_libre} to 6
562 else:
563 set {_occupe} to 6
564 set {_occupe.coord} to "%{_xbis}%.%{_zbis}%"
565
566 if {_libre}+1 is {_occupe}:
567 set {_id.1} to {_id}-1
568 if {_traite::%{_occupe.coord}%} is {regions.%{_n}%.tracer::%{_id.1}%}:
569 exit loop
570 set {regions.%{_n}%.tracer::%{_id}%} to {_occupe.coord}
571 set {_traite::%{_occupe.coord}%} to {regions.%{_n}%.tracer::%{_id.1}%}
572 set {_direction} to 4
573
574 if {regions.%{_n}%.tracer::%{_id}%} is not set:
575 if {_direction} is less or equal to 7:
576 set {_xbis} to {_x}-1
577 set {_zbis} to {_z}
578 if {_coord::%{_xbis}%.%{_zbis}%} is not set:
579 set {_libre} to 7
580 else:
581 if {_coord::%{_xbis}%.%{_zbis}%} is not {_coord::%{_x}%.%{_z}%}:
582 set {_libre} to 7
583 else:
584 set {_occupe} to 7
585 set {_occupe.coord} to "%{_xbis}%.%{_zbis}%"
586
587 if {_libre}+1 is {_occupe}:
588 set {_id.1} to {_id}-1
589 if {_traite::%{_occupe.coord}%} is {regions.%{_n}%.tracer::%{_id.1}%}:
590 exit loop
591 set {regions.%{_n}%.tracer::%{_id}%} to {_occupe.coord}
592 set {_traite::%{_occupe.coord}%} to {regions.%{_n}%.tracer::%{_id.1}%}
593 set {_direction} to 5
594
595 if {regions.%{_n}%.tracer::%{_id}%} is not set:
596 if {_direction} is less or equal to 8:
597 set {_xbis} to {_x}-1
598 set {_zbis} to {_z}-1
599 if {_coord::%{_xbis}%.%{_zbis}%} is not set:
600 set {_libre} to 8
601 else:
602 if {_coord::%{_xbis}%.%{_zbis}%} is not {_coord::%{_x}%.%{_z}%}:
603 set {_libre} to 8
604 else:
605 set {_occupe} to 8
606 set {_occupe.coord} to "%{_xbis}%.%{_zbis}%"
607
608 if {_libre}+1 is {_occupe}:
609 set {_id.1} to {_id}-1
610 if {_traite::%{_occupe.coord}%} is {regions.%{_n}%.tracer::%{_id.1}%}:
611 exit loop
612 set {regions.%{_n}%.tracer::%{_id}%} to {_occupe.coord}
613 set {_traite::%{_occupe.coord}%} to {regions.%{_n}%.tracer::%{_id.1}%}
614 set {_direction} to 6
615
616 if {regions.%{_n}%.tracer::%{_id}%} is not set:
617 set {_xbis} to {_x}
618 set {_zbis} to {_z}-1
619 if {_coord::%{_xbis}%.%{_zbis}%} is not set:
620 set {_libre} to 9
621 else:
622 if {_coord::%{_xbis}%.%{_zbis}%} is not {_coord::%{_x}%.%{_z}%}:
623 set {_libre} to 9
624 else:
625 set {_occupe} to 9
626 set {_occupe.coord} to "%{_xbis}%.%{_zbis}%"
627
628 if {_libre}+1 is {_occupe}:
629 set {_id.1} to {_id}-1
630 if {_traite::%{_occupe.coord}%} is {regions.%{_n}%.tracer::%{_id.1}%}:
631 exit loop
632 set {regions.%{_n}%.tracer::%{_id}%} to {_occupe.coord}
633 set {_traite::%{_occupe.coord}%} to {regions.%{_n}%.tracer::%{_id.1}%}
634 set {_direction} to 7
635
636 if {regions.%{_n}%.tracer::%{_id}%} is not set:
637 if {_direction} is greater than 1:
638 set {_xbis} to {_x}+1
639 set {_zbis} to {_z}-1
640 if {_coord::%{_xbis}%.%{_zbis}%} is not set:
641 set {_libre} to 10
642 else:
643 if {_coord::%{_xbis}%.%{_zbis}%} is not {_coord::%{_x}%.%{_z}%}:
644 set {_libre} to 10
645 else:
646 set {_occupe} to 10
647 set {_occupe.coord} to "%{_xbis}%.%{_zbis}%"
648
649 if {_libre}+1 is {_occupe}:
650 set {_id.1} to {_id}-1
651 if {_traite::%{_occupe.coord}%} is {regions.%{_n}%.tracer::%{_id.1}%}:
652 exit loop
653 set {regions.%{_n}%.tracer::%{_id}%} to {_occupe.coord}
654 set {_traite::%{_occupe.coord}%} to {regions.%{_n}%.tracer::%{_id.1}%}
655 set {_direction} to 8
656
657 if {regions.%{_n}%.tracer::%{_id}%} is not set:
658 if {_direction} is greater than 2:
659 set {_xbis} to {_x}+1
660 set {_zbis} to {_z}
661 if {_coord::%{_xbis}%.%{_zbis}%} is not set:
662 set {_libre} to 1
663 else:
664 if {_coord::%{_xbis}%.%{_zbis}%} is not {_coord::%{_x}%.%{_z}%}:
665 set {_libre} to 11
666 else:
667 set {_occupe} to 11
668 set {_occupe.coord} to "%{_xbis}%.%{_zbis}%"
669
670 if {_libre}+1 is {_occupe}:
671 set {_id.1} to {_id}-1
672 if {_traite::%{_occupe.coord}%} is {regions.%{_n}%.tracer::%{_id.1}%}:
673 exit loop
674 set {regions.%{_n}%.tracer::%{_id}%} to {_occupe.coord}
675 set {_traite::%{_occupe.coord}%} to {regions.%{_n}%.tracer::%{_id.1}%}
676 set {_direction} to 1
677
678 if {regions.%{_n}%.tracer::%{_id}%} is not set:
679 if {_direction} is greater than 3:
680 set {_xbis} to {_x}+1
681 set {_zbis} to {_z}+1
682 if {_coord::%{_xbis}%.%{_zbis}%} is not set:
683 set {_libre} to 12
684 else:
685 if {_coord::%{_xbis}%.%{_zbis}%} is not {_coord::%{_x}%.%{_z}%}:
686 set {_libre} to 12
687 else:
688 set {_occupe} to 12
689 set {_occupe.coord} to "%{_xbis}%.%{_zbis}%"
690
691 if {_libre}+1 is {_occupe}:
692 set {_id.1} to {_id}-1
693 if {_traite::%{_occupe.coord}%} is {regions.%{_n}%.tracer::%{_id.1}%}:
694 exit loop
695 set {regions.%{_n}%.tracer::%{_id}%} to {_occupe.coord}
696 set {_traite::%{_occupe.coord}%} to {regions.%{_n}%.tracer::%{_id.1}%}
697 set {_direction} to 2
698
699 if {regions.%{_n}%.tracer::%{_id}%} is not set:
700 if {_direction} is greater than 4:
701 set {_xbis} to {_x}
702 set {_zbis} to {_z}+1
703 if {_coord::%{_xbis}%.%{_zbis}%} is not set:
704 set {_libre} to 13
705 else:
706 if {_coord::%{_xbis}%.%{_zbis}%} is not {_coord::%{_x}%.%{_z}%}:
707 set {_libre} to 13
708 else:
709 set {_occupe} to 13
710 set {_occupe.coord} to "%{_xbis}%.%{_zbis}%"
711
712 if {_libre}+1 is {_occupe}:
713 set {_id.1} to {_id}-1
714 if {_traite::%{_occupe.coord}%} is {regions.%{_n}%.tracer::%{_id.1}%}:
715 exit loop
716 set {regions.%{_n}%.tracer::%{_id}%} to {_occupe.coord}
717 set {_traite::%{_occupe.coord}%} to {regions.%{_n}%.tracer::%{_id.1}%}
718 set {_direction} to 3
719
720 if {regions.%{_n}%.tracer::%{_id}%} is not set:
721 if {_direction} is greater than 5:
722 set {_xbis} to {_x}-1
723 set {_zbis} to {_z}+1
724 if {_coord::%{_xbis}%.%{_zbis}%} is not set:
725 set {_libre} to 14
726 else:
727 if {_coord::%{_xbis}%.%{_zbis}%} is not {_coord::%{_x}%.%{_z}%}:
728 set {_libre} to 14
729 else:
730 set {_occupe} to 14
731 set {_occupe.coord} to "%{_xbis}%.%{_zbis}%"
732
733 if {_libre}+1 is {_occupe}:
734 set {_id.1} to {_id}-1
735 if {_traite::%{_occupe.coord}%} is {regions.%{_n}%.tracer::%{_id.1}%}:
736 exit loop
737 set {regions.%{_n}%.tracer::%{_id}%} to {_occupe.coord}
738 set {_traite::%{_occupe.coord}%} to {regions.%{_n}%.tracer::%{_id.1}%}
739 set {_direction} to 4
740
741 if {regions.%{_n}%.tracer::%{_id}%} is not set:
742 if {_direction} is greater than 6:
743 set {_xbis} to {_x}-1
744 set {_zbis} to {_z}
745 if {_coord::%{_xbis}%.%{_zbis}%} is not set:
746 set {_libre} to 15
747 else:
748 if {_coord::%{_xbis}%.%{_zbis}%} is not {_coord::%{_x}%.%{_z}%}:
749 set {_libre} to 15
750 else:
751 set {_occupe} to 15
752 set {_occupe.coord} to "%{_xbis}%.%{_zbis}%"
753
754 if {_libre}+1 is {_occupe}:
755 set {_id.1} to {_id}-1
756 if {_traite::%{_occupe.coord}%} is {regions.%{_n}%.tracer::%{_id.1}%}:
757 exit loop
758 set {regions.%{_n}%.tracer::%{_id}%} to {_occupe.coord}
759 set {_traite::%{_occupe.coord}%} to {regions.%{_n}%.tracer::%{_id.1}%}
760 set {_direction} to 5
761
762 if {regions.%{_n}%.tracer::%{_id}%} is not set:
763 if {_direction} is greater than 7:
764 set {_xbis} to {_x}-1
765 set {_zbis} to {_z}-1
766 if {_coord::%{_xbis}%.%{_zbis}%} is not set:
767 set {_libre} to 16
768 else:
769 if {_coord::%{_xbis}%.%{_zbis}%} is not {coord::%{_x}%.%{_z}%}:
770 set {_libre} to 16
771 else:
772 set {_occupe} to 16
773 set {_occupe.coord} to "%{_xbis}%.%{_zbis}%"
774
775 if {_libre}+1 is {_occupe}:
776 set {_id.1} to {_id}-1
777 if {_traite::%{_occupe.coord}%} is {regions.%{_n}%.tracer::%{_id.1}%}:
778 exit loop
779 set {regions.%{_n}%.tracer::%{_id}%} to {_occupe.coord}
780 set {_traite::%{_occupe.coord}%} to {regions.%{_n}%.tracer::%{_id.1}%}
781 set {_direction} to 6
782
783 if {regions.%{_n}%.tracer::%{_id}%} is not set:
784 broadcast "CONDITIONS NON VERIF"
785 exit loop
786
787 set {_id.1} to {_id}-1
788 if {regions.%{_n}%.tracer::%{_id}%} is {regions.%{_n}%.tracer::%{_id.1}%}:
789 broadcast "ERREUR IDENTIQUE"
790 exit loop
791
792
793 broadcast "REGION %{_n}% %size of {regions.%{_n}%.tracer::*}%/%size of {_traite::*}%"
794 regiontracer({_n})
795
796function regiontracer(n: text):
797 set {_num} to 0
798 loop size of {regions::*} times:
799 if {regions.dynmap.tracer.liste::%{_num}%} is not set:
800 exit loop
801 add 1 to {_num}
802 set {regions.dynmap.tracer.liste::%{_num}%} to true
803 set {regions.dynmap.tracer.liste.%{_num}%::*} to {regions.%{_n}%.tracer::*}
804 set {regions.dynmap.tracer.liste.%{_num}%.id} to {_n}
805
806
807 execute "SELECT nom FROM Regions WHERE id = %{_n}%" in {sql} and store the result in {_nom::*}
808 set {regions.dynmap.tracer.liste.%{_num}%.nom} to {_nom::nom::1}
809
810 execute "SELECT couleur FROM Regions WHERE id = %{_n}%" in {sql} and store the result in {_couleur::*}
811 set {_couleur} to {_couleur::couleur::1}
812
813 if {_couleur} is "&4":
814 set {regions.dynmap.tracer.liste.%{_num}%.couleur} to "AA0000"
815 else if {_couleur} is "&c":
816 set {regions.dynmap.tracer.liste.%{_num}%.couleur} to "FF5555"
817 else if {_couleur} is "&6":
818 set {regions.dynmap.tracer.liste.%{_num}%.couleur} to "FFAA00"
819 else if {_couleur} is "&e":
820 set {regions.dynmap.tracer.liste.%{_num}%.couleur} to "FFFF55"
821 else if {_couleur} is "&a":
822 set {regions.dynmap.tracer.liste.%{_num}%.couleur} to "55FF55"
823 else if {_couleur} is "&2":
824 set {regions.dynmap.tracer.liste.%{_num}%.couleur} to "00AA00"
825 else if {_couleur} is "&b":
826 set {regions.dynmap.tracer.liste.%{_num}%.couleur} to "55FFFF"
827 else if {_couleur} is "&3":
828 set {regions.dynmap.tracer.liste.%{_num}%.couleur} to "00AAAA"
829 else if {_couleur} is "&9":
830 set {regions.dynmap.tracer.liste.%{_num}%.couleur} to "5555FF"
831 else if {_couleur} is "&1":
832 set {regions.dynmap.tracer.liste.%{_num}%.couleur} to "0000AA"
833 else if {_couleur} is "&5":
834 set {regions.dynmap.tracer.liste.%{_num}%.couleur} to "AA00AA"
835 else if {_couleur} is "&d":
836 set {regions.dynmap.tracer.liste.%{_num}%.couleur} to "FF55FF"
837 else if {_couleur} is "&f":
838 set {regions.dynmap.tracer.liste.%{_num}%.couleur} to "FFFFFF"
839 else if {_couleur} is "&7":
840 set {regions.dynmap.tracer.liste.%{_num}%.couleur} to "AAAAAA"
841 else if {_couleur} is "&8":
842 set {regions.dynmap.tracer.liste.%{_num}%.couleur} to "555555"
843 else if {_couleur} is "&0":
844 set {regions.dynmap.tracer.liste.%{_num}%.couleur} to "000000"
845
846command /regionsetnom <number> <text>:
847 trigger:
848 set {regions.%number-arg%.info::nom} to text-arg
849 regiontracer("%number-arg%")
850
851command /regionsetcouleur <number> <text>:
852 trigger:
853 set {regions.%number-arg%.info::couleur} to text-arg
854 regiontracer("%number-arg%")
855
856command /regionsetcouleurmenu <player>:
857 trigger:
858 wait 3 ticks
859 set {_region} to regioncheck(player-arg's location)
860 open chest with 2 rows named "Couleur de %{regions.%{_region}%.info::nom}% ?" to player-arg
861
862 set slot 1 of player-arg to unbreakable diamond hoe named " "
863 add "{Unbreakable:1}" to nbt of slot 1 of player-arg
864 add "{HideFlags:6}" to nbt of slot 1 of player-arg
865 set durability of slot 1 of player-arg to 1
866 set {_plein} to slot 1 of player-arg
867 set slot 1 of player-arg to air
868
869 format slot 0 of player-arg with rouge wool named "&4Rouge" to close then run "regionsetcouleur %{_region}% &4"
870 format slot 1 of player-arg with rouge wool named "&cRouge clair" to close then run "regionsetcouleur %{_region}% &c"
871 format slot 2 of player-arg with orange wool named "&6Orange" to close then run "regionsetcouleur %{_region}% &6"
872 format slot 3 of player-arg with yellow wool named "&eJaune" to close then run "regionsetcouleur %{_region}% &e"
873 format slot 4 of player-arg with vert clair wool named "&aVert clair" to close then run "regionsetcouleur %{_region}% &a"
874 format slot 5 of player-arg with vert wool named "&2Vert" to close then run "regionsetcouleur %{_region}% &2"
875 format slot 6 of player-arg with cyan wool named "&bCyan clair" to close then run "regionsetcouleur %{_region}% &b"
876 format slot 7 of player-arg with cyan wool named "&3Cyan" to close then run "regionsetcouleur %{_region}% &3"
877 format slot 8 of player-arg with bleu clair wool named "&9Bleu clair" to close then run "regionsetcouleur %{_region}% &9"
878 format slot 9 of player-arg with bleu wool named "&1Bleu" to close then run "regionsetcouleur %{_region}% &1"
879 format slot 10 of player-arg with violet wool named "&5Violet" to close then run "regionsetcouleur %{_region}% &5"
880 format slot 11 of player-arg with rose wool named "&dRose" to close then run "regionsetcouleur %{_region}% &d"
881 format slot 12 of player-arg with blanc wool named "&fBlanc" to close then run "regionsetcouleur %{_region}% &f"
882 format slot 13 of player-arg with argent wool named "&7Argent" to close then run "regionsetcouleur %{_region}% &7"
883 format slot 14 of player-arg with gris wool named "&8Gris" to close then run "regionsetcouleur %{_region}% &8"
884 format slot 15 of player-arg with noir wool named "&0Noir" to close then run "regionsetcouleur %{_region}% &0"
885 format slot 16 of player-arg with {_plein} to be unstealable
886 format slot 17 of player-arg with {_plein} to be unstealable