137 lines
6 KiB
Text
137 lines
6 KiB
Text
options:
|
|
X1: 103.5
|
|
Z1: -312.5
|
|
Yeau: 57.5 # water layer
|
|
X2: 99.5
|
|
Z2: -304.5
|
|
|
|
on load:
|
|
ScriptList("add", script)
|
|
on unload:
|
|
ScriptList("remove", script)
|
|
|
|
# allows you to send a message to a whole party
|
|
function annonceParty(message: text):
|
|
loop {party.list::*}:
|
|
send {_message} to loop-value
|
|
|
|
# starting a thimble game for a party
|
|
command deacoudre [<text>]:
|
|
executable by: players
|
|
description: Lance une partie de dé à coudre.
|
|
trigger:
|
|
if arg-1 is set:
|
|
if arg-1 is "spawn":
|
|
if player is op:
|
|
set {thimble.location} to location of player
|
|
send "&aLe dé à coudre téléportes désormais ici."
|
|
stop
|
|
else:
|
|
send option("errorMessage")
|
|
stop
|
|
if {thimble.location} is not set:
|
|
send "&4Tu n'as pas défini de point de téléportation : &r&l/deacoudre spawn"
|
|
stop
|
|
if {party.player.%uuid of player%} is set:
|
|
if {thimble} is true:
|
|
delete {thimble}
|
|
loop {party.list::*}:
|
|
resetThimble(loop-value)
|
|
send "&cPartie de dé à coudre terminée." to loop-value
|
|
set gamemode of loop-value to creative
|
|
else:
|
|
set {thimble} to true
|
|
loop {party.list::*}:
|
|
send "&aDémarrage de la partie de dé à coudre !" to loop-value
|
|
teleport loop-value to {thimble.location}
|
|
set gamemode of loop-value to adventure
|
|
feed loop-value
|
|
heal loop-value
|
|
cure loop-value
|
|
execute console command "fill 103 57 -313 99 57 -305 water"
|
|
# execute console command "fill %{@X1}% %{@Yeau}% %{@Z1}% %{@X2}% %{@Yeau}% %{@Z2}% water"
|
|
else:
|
|
send "&4Tu n'es pas dans une partie."
|
|
|
|
# returns the difference between the xyz-location of a block and a given number
|
|
function getDifference(arg: text, block: block, comparative: number) :: number:
|
|
if {_arg} is "x":
|
|
set {_res} to difference between X-location of {_block} and {_comparative}
|
|
if {_arg} is "y":
|
|
set {_res} to difference between Y-location of {_block} and {_comparative}
|
|
if {_arg} is "z":
|
|
set {_res} to difference between Z-location of {_block} and {_comparative}
|
|
return {_res}
|
|
|
|
# placing block and teleportation
|
|
every 0.5 second in "world":
|
|
if {thimble} is not true:
|
|
stop
|
|
loop {party.list::*}:
|
|
set action bar of loop-value to "&dEn partie de &lDé à coudre&r&d."
|
|
if block at loop-value is water: # si dans l'eau
|
|
# vérification que c'est l'eau du dé à coudre
|
|
set {_xLocationBlock1} to getDifference("x", block at loop-value, {@X1})
|
|
set {_xLocationBlock2} to getDifference("x", block at loop-value, {@X2})
|
|
set {_zLocationBlock1} to getDifference("z", block at loop-value, {@Z1})
|
|
set {_zLocationBlock2} to getDifference("z", block at loop-value, {@Z2})
|
|
set {_yLocationBlock} to getDifference("y", block at loop-value, {@Yeau})
|
|
if {_xLocationBlock1} and {_xLocationBlock2} and {_zLocationBlock1} and {_zLocationBlock2} <= 0:
|
|
continue
|
|
if {_xLocationBlock1} and {_xLocationBlock2} >= abs({@X1} - {@X2}):
|
|
continue
|
|
if {_yLocationBlock} != 0:
|
|
continue
|
|
if {_zLocationBlock1} and {_zLocationBlock2} >= abs({@Z1} - {@Z2}):
|
|
continue
|
|
|
|
# vérification si c'est un jump qui est dur à faire (entre 4 blocs pleins)
|
|
set {_niceJump} to true
|
|
set {_blockX} to X-location of block at loop-value
|
|
set {_blockY} to Y-location of block at loop-value
|
|
set {_blockZ} to Z-location of block at loop-value
|
|
if block at location ({_blockX} - 1), {_blockY}, {_blockZ} in world "world" is water:
|
|
set {_niceJump} to false
|
|
if block at location ({_blockX} + 1), {_blockY}, {_blockZ} in world "world" is water:
|
|
set {_niceJump} to false
|
|
if block at location {_blockX}, {_blockY}, ({_blockZ} - 1) in world "world" is water:
|
|
set {_niceJump} to false
|
|
if block at location {_blockX}, {_blockY}, ({_blockZ} + 1) in world "world" is water:
|
|
set {_niceJump} to false
|
|
|
|
# pose du bloc (or si jump difficile + message, laine si normal)
|
|
set block at loop-value to wool
|
|
if {thimble.dead.%uuid of loop-value%} is not set:
|
|
if {_niceJump} is true:
|
|
set block at loop-value to gold block
|
|
set {_player} to userOrNick(loop-value)
|
|
annonceParty("&a&l%{_player}%&r&e a réalisé un dé à coudre !")
|
|
else:
|
|
delete {thimble.dead.%uuid of loop-value%}
|
|
|
|
# téléportation et feed/heal
|
|
teleport loop-value to {thimble.location}
|
|
feed loop-value
|
|
heal loop-value
|
|
|
|
# triggered if player die during a thimble game
|
|
on death:
|
|
if {thimble} is true:
|
|
if {party.player.%uuid of player%} is set:
|
|
cancel event
|
|
set gamemode of player to spectator
|
|
set {thimble.dead.%uuid of player%} to true
|
|
set {_finPartie} to 0
|
|
loop {party.list::*}:
|
|
if {thimble.dead.%uuid of loop-value%} is true:
|
|
set {_player} to userOrNick(loop-value)
|
|
annonceParty("&c%{_player}%&b a été éliminé !")
|
|
else:
|
|
set {_gagnant} to userOrNick(loop-value)
|
|
add 1 to {_finPartie}
|
|
if {_finPartie} <= 1: # 1 ou 0
|
|
if {_gagnant} is set:
|
|
annonceParty("&a&l%{_gagnant}%&r&l a gagné la partie !!")
|
|
else:
|
|
send "&cTu étais tout seul à jouer... bravo quand même ?"
|
|
execute player command "deacoudre"
|