if {変数::%block%} <= 0が効かない
クリックしたときのイベント
on right click:
set {_loc} to event-block
if y-coordinate of {_loc} is not 4.5:
stop
if cooldown of player's tool of player is not 0:
stop
if event-block is coarse dirt:
if {block.health::%event-block%} is not set:
SetBlockHealth(event-block,5,15)
if {block.health::%event-block%} is set:
DestroyProcess(event-block,player)
on right click:
set {_loc} to event-block
if y-coordinate of {_loc} is not 4.5:
stop
if cooldown of player's tool of player is not 0:
stop
if event-block is coarse dirt:
if {block.health::%event-block%} is not set:
SetBlockHealth(event-block,5,15)
if {block.health::%event-block%} is set:
DestroyProcess(event-block,player)
クリックしたときの処理
function SetBlockHealth(block: block,a: number, b: number):
set {_block.health} to random number between {_a} and {_b}
set {block.health::%{_block}%} to {_block.health}
set {max.block.health::%{_block}%} to {_block.health}
set {_loc} to location of {_block}
add 1.15 to y-coordinate of {_loc}
set {_string} to getBlockHolo({_block})
create holo object "%{_string}%" with id "%{_block}%" at {_loc}
function DestroyProcess(block: block,p: player):
set {_block.loc} to location of {_block}
set {_u} to uuid of {_p}
remove {Power::%{_u}%} from {block.health::%{_block}%}
set destroy stage with id "%{_block}%" of {_block} to getDestroyStage({_block})
set cooldown of {_p}'s tool of {_p} to 20
set {_string} to getBlockHolo({_block})
edit holo object "%{_block}%" to "%{_string}%"
play sound "block.gravel.break" with pitch 2 to {_p}
send "%{block.health::%{_block}%}%" to {_p}
if {block.health::%{_block}%} <= 0:
delete {block.health::%{_block}%}
delete holo object "%{_block}%"
break {_block}
execute console command "/particle cloud %x-coordinate of {_block.loc}% %y-coordinate of {_block.loc}% %z-coordinate of {_block.loc}% 0.2 0.2 0.2 0.05 4 normal @a"
function SetBlockHealth(block: block,a: number, b: number):
set {_block.health} to random number between {_a} and {_b}
set {block.health::%{_block}%} to {_block.health}
set {max.block.health::%{_block}%} to {_block.health}
set {_loc} to location of {_block}
add 1.15 to y-coordinate of {_loc}
set {_string} to getBlockHolo({_block})
create holo object "%{_string}%" with id "%{_block}%" at {_loc}
function DestroyProcess(block: block,p: player):
set {_block.loc} to location of {_block}
set {_u} to uuid of {_p}
remove {Power::%{_u}%} from {block.health::%{_block}%}
set destroy stage with id "%{_block}%" of {_block} to getDestroyStage({_block})
set cooldown of {_p}'s tool of {_p} to 20
set {_string} to getBlockHolo({_block})
edit holo object "%{_block}%" to "%{_string}%"
play sound "block.gravel.break" with pitch 2 to {_p}
send "%{block.health::%{_block}%}%" to {_p}
if {block.health::%{_block}%} <= 0:
delete {block.health::%{_block}%}
delete holo object "%{_block}%"
break {_block}
execute console command "/particle cloud %x-coordinate of {_block.loc}% %y-coordinate of {_block.loc}% %z-coordinate of {_block.loc}% 0.2 0.2 0.2 0.05 4 normal @a"
2 Replies
ホログラムのテキストとブロックの壊れ具合を取得するFunction
function getDestroyStage(block: block) :: integer:
set {_destroy.stage} to ({block.health::%{_block}%} / {max.block.health::%{_block}%})
if {_destroy.stage} is between 0 and 0.1:
set {_destroy.stage} to 9
if {_destroy.stage} is between 0.11 and 0.2:
set {_destroy.stage} to 8
if {_destroy.stage} is between 0.21 and 0.3:
set {_destroy.stage} to 7
if {_destroy.stage} is between 0.31 and 0.4:
set {_destroy.stage} to 6
if {_destroy.stage} is between 0.41 and 0.5:
set {_destroy.stage} to 5
if {_destroy.stage} is between 0.51 and 0.6:
set {_destroy.stage} to 4
if {_destroy.stage} is between 0.61 and 0.7:
set {_destroy.stage} to 3
if {_destroy.stage} is between 0.71 and 0.8:
set {_destroy.stage} to 2
if {_destroy.stage} is between 0.81 and 0.9:
set {_destroy.stage} to 1
if {_destroy.stage} is between 0.91 and 1:
set {_destroy.stage} to 0
return {_destroy.stage}
function getDestroyStage(block: block) :: integer:
set {_destroy.stage} to ({block.health::%{_block}%} / {max.block.health::%{_block}%})
if {_destroy.stage} is between 0 and 0.1:
set {_destroy.stage} to 9
if {_destroy.stage} is between 0.11 and 0.2:
set {_destroy.stage} to 8
if {_destroy.stage} is between 0.21 and 0.3:
set {_destroy.stage} to 7
if {_destroy.stage} is between 0.31 and 0.4:
set {_destroy.stage} to 6
if {_destroy.stage} is between 0.41 and 0.5:
set {_destroy.stage} to 5
if {_destroy.stage} is between 0.51 and 0.6:
set {_destroy.stage} to 4
if {_destroy.stage} is between 0.61 and 0.7:
set {_destroy.stage} to 3
if {_destroy.stage} is between 0.71 and 0.8:
set {_destroy.stage} to 2
if {_destroy.stage} is between 0.81 and 0.9:
set {_destroy.stage} to 1
if {_destroy.stage} is between 0.91 and 1:
set {_destroy.stage} to 0
return {_destroy.stage}
function getBlockHolo(block: block) :: string:
set {_health.n} to {block.health::%{_block}%} / {max.block.health::%{_block}%}
if {_health.n} is between 0 and 0.1:
set {_string} to "&7[ &7||||%{block.health::%{_block}%}%|||| &7]"
if {_health.n} is between 0.11 and 0.2:
set {_string} to "&7[ &a|&7|||%{block.health::%{_block}%}%|||| &7]"
if {_health.n} is between 0.21 and 0.3:
set {_string} to "&7[ &a||&7||%{block.health::%{_block}%}%|||| &7]"
if {_health.n} is between 0.31 and 0.4:
set {_string} to "&7[ &a|||&7|%{block.health::%{_block}%}%|||| &7]"
if {_health.n} is between 0.41 and 0.6:
set {_string} to "&7[ &a||||&7%{block.health::%{_block}%}%|||| &7]"
if {_health.n} is between 0.61 and 0.7:
set {_string} to "&7[ &a||||%{block.health::%{_block}%}%&7|||| &7]"
if {_health.n} is between 0.71 and 0.8:
set {_string} to "&7[ &a||||%{block.health::%{_block}%}%|&7||| &7]"
if {_health.n} is between 0.81 and 0.9:
set {_string} to "&7[ &a||||%{block.health::%{_block}%}%||&7|| &7]"
if {_health.n} is between 0.91 and 1:
set {_string} to "&7[ &a||||%{block.health::%{_block}%}%|||&7| &7]"
if {_health.n} is more than 1:
stop
return {_string}
function getBlockHolo(block: block) :: string:
set {_health.n} to {block.health::%{_block}%} / {max.block.health::%{_block}%}
if {_health.n} is between 0 and 0.1:
set {_string} to "&7[ &7||||%{block.health::%{_block}%}%|||| &7]"
if {_health.n} is between 0.11 and 0.2:
set {_string} to "&7[ &a|&7|||%{block.health::%{_block}%}%|||| &7]"
if {_health.n} is between 0.21 and 0.3:
set {_string} to "&7[ &a||&7||%{block.health::%{_block}%}%|||| &7]"
if {_health.n} is between 0.31 and 0.4:
set {_string} to "&7[ &a|||&7|%{block.health::%{_block}%}%|||| &7]"
if {_health.n} is between 0.41 and 0.6:
set {_string} to "&7[ &a||||&7%{block.health::%{_block}%}%|||| &7]"
if {_health.n} is between 0.61 and 0.7:
set {_string} to "&7[ &a||||%{block.health::%{_block}%}%&7|||| &7]"
if {_health.n} is between 0.71 and 0.8:
set {_string} to "&7[ &a||||%{block.health::%{_block}%}%|&7||| &7]"
if {_health.n} is between 0.81 and 0.9:
set {_string} to "&7[ &a||||%{block.health::%{_block}%}%||&7|| &7]"
if {_health.n} is between 0.91 and 1:
set {_string} to "&7[ &a||||%{block.health::%{_block}%}%|||&7| &7]"
if {_health.n} is more than 1:
stop
return {_string}
うまくいかなかったとこfunctionのDestroyProcessの中にある{block.health::%{_block}%}が0より小さい数になっても 反応しなかった
ここでとまります