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
くr
くr8mo ago
ホログラムのテキストとブロックの壊れ具合を取得する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より小さい数になっても 反応しなかった
くr
くr8mo ago
ここでとまります
No description
Want results from more Discord servers?
Add your server
More Posts
【解決済み】chat eventが反応してない``` [00:18:43 INFO]: [Skript] Line 12: (menu.sk) [00:18:43 INFO]: Starting a variable's name witアイテム欄がいっぱいでskriptのgiveが動作しない時の対策この鯖で2回訪ねて以下の4種類のコマンドを作ったのですが、 ``` on break: event-block is deepslate_diamond_ore chance of 2while構文の想定外の動き(条件にあってなくてもとまらない)``` function spawnGunnerMob(loc: location) :: entity: spawn zombie at {_loc} set {_entity} 採掘時の確率scriptsのキル時確率版の作成以下のscriptsのキルした時版が作りたいです!! 『on break: event-block is diamond_ore chance of 20%: giveset lore of tool of player to "あああ" with ・・・この文で繋げていくとis not an nbt compoundとエラーが発生し、アイテムにloreを複数行つけられません。set the lineなどでラインを絞ってloreをsetしようとしたのでエンダーパールのようなクールダウンエフェクト?を特定のアイテムに付けたいServer 1.20.1 Skript 2.7.0OneBlockの用にランダムなブロックを置きたいがリセットコマンドの方だけうまくいく!?``` on break: set {_loc} to location(0.5,64.5,0.5,world "oneblock") if event-block's locatioskript Ver.2.7.0の「give」で与えるアイテムをエンチャント付与だけではなく名前と説明文も変えたいexecute console command "ゲーム内コマンド"で出来るとの情報を得たのでしてみたところ名前等の変更コマンドに対応してなく、giveコマンドを調べたのですが、エンチャント付与以外見銃のサンプルコードが欲しいこれまで矢の射撃速度を上げて疑似的な銃として使用していましたが、エフェクトを射線につけることができなくて他の方法で弾丸を射撃できるようにしたいです。どなたかサンプルコードをください Skript 2.リスト変数にテキストを入れたい```command /setname [<text>]: permission: op permission message: &cあなたは運営ではありません aliases