Skip to content

Commit

Permalink
🧑‍💻 トリガーの呼び出し処理の共通部分を作成
Browse files Browse the repository at this point in the history
  • Loading branch information
haiiro2gou committed Nov 15, 2024
1 parent 3a48649 commit 1a6b791
Show file tree
Hide file tree
Showing 14 changed files with 150 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,52 +5,53 @@
# @within function asset_manager:artifact/create/trigger/

# スロット
execute if data storage asset:artifact {Slot:"auto"} run data modify storage asset:artifact Temp.Trigger.A set value "どちらかの手に所持"
execute if data storage asset:artifact {Slot:"mainhand"} run data modify storage asset:artifact Temp.Trigger.A set value "メインハンドに所持"
execute if data storage asset:artifact {Slot:"offhand"} run data modify storage asset:artifact Temp.Trigger.A set value "オフハンドに所持"
execute if data storage asset:artifact {Slot:"head"} run data modify storage asset:artifact Temp.Trigger.A set value "装備"
execute if data storage asset:artifact {Slot:"chest"} run data modify storage asset:artifact Temp.Trigger.A set value "装備"
execute if data storage asset:artifact {Slot:"legs"} run data modify storage asset:artifact Temp.Trigger.A set value "装備"
execute if data storage asset:artifact {Slot:"feet"} run data modify storage asset:artifact Temp.Trigger.A set value "装備"
execute if data storage asset:artifact {Slot: "auto"} run data modify storage asset:artifact Temp.Trigger.A set value "どちらかの手に所持"
execute if data storage asset:artifact {Slot: "mainhand"} run data modify storage asset:artifact Temp.Trigger.A set value "メインハンドに所持"
execute if data storage asset:artifact {Slot: "offhand"} run data modify storage asset:artifact Temp.Trigger.A set value "オフハンドに所持"
execute if data storage asset:artifact {Slot: "head"} run data modify storage asset:artifact Temp.Trigger.A set value "装備"
execute if data storage asset:artifact {Slot: "chest"} run data modify storage asset:artifact Temp.Trigger.A set value "装備"
execute if data storage asset:artifact {Slot: "legs"} run data modify storage asset:artifact Temp.Trigger.A set value "装備"
execute if data storage asset:artifact {Slot: "feet"} run data modify storage asset:artifact Temp.Trigger.A set value "装備"
execute if data storage asset:artifact {Slot:"inventory"} run data modify storage asset:artifact Temp.Trigger.A set value "インベントリ内に保持"
execute if data storage asset:artifact {Slot:"hotbar"} run data modify storage asset:artifact Temp.Trigger.A set value "ホットバーに保持"
execute if data storage asset:artifact {Slot: "hotbar"} run data modify storage asset:artifact Temp.Trigger.A set value "ホットバーに保持"
# 接続詞
data modify storage asset:artifact Temp.Trigger.AB set value ""
# トリガー
execute if data storage asset:artifact {Trigger:"click"} run data modify storage asset:artifact Temp.Trigger.B set value "右クリック"
execute if data storage asset:artifact {Trigger:"keep_click"} run data modify storage asset:artifact Temp.Trigger.B set value "右クリック"
execute if data storage asset:artifact {Trigger:"shot"} run data modify storage asset:artifact Temp.Trigger.B set value "発射"
execute if data storage asset:artifact {Trigger:"use"} run data modify storage asset:artifact Temp.Trigger.B set value "使用"
execute if data storage asset:artifact {Trigger:"tick"} run data modify storage asset:artifact Temp.Trigger.B set value "ている限り"
execute if data storage asset:artifact {Trigger:"attack"} run data modify storage asset:artifact Temp.Trigger.B set value "攻撃"
execute if data storage asset:artifact {Trigger:"attack_melee"} run data modify storage asset:artifact Temp.Trigger.B set value "近接攻撃"
execute if data storage asset:artifact {Trigger: "tick"} run data modify storage asset:artifact Temp.Trigger.B set value "ている限り"
execute if data storage asset:artifact {Trigger: "click"} run data modify storage asset:artifact Temp.Trigger.B set value "右クリック"
execute if data storage asset:artifact {Trigger: "keep_click"} run data modify storage asset:artifact Temp.Trigger.B set value "右クリック"
execute if data storage asset:artifact {Trigger: "shot"} run data modify storage asset:artifact Temp.Trigger.B set value "発射"
execute if data storage asset:artifact {Trigger: "use_item"} run data modify storage asset:artifact Temp.Trigger.B set value "使用"
execute if data storage asset:artifact {Trigger: "attack"} run data modify storage asset:artifact Temp.Trigger.B set value "攻撃"
execute if data storage asset:artifact {Trigger: "attack_melee"} run data modify storage asset:artifact Temp.Trigger.B set value "近接攻撃"
execute if data storage asset:artifact {Trigger:"attack_projectile"} run data modify storage asset:artifact Temp.Trigger.B set value "遠距離攻撃"
execute if data storage asset:artifact {Trigger:"damage"} run data modify storage asset:artifact Temp.Trigger.B set value "被ダメージ"
execute if data storage asset:artifact {Trigger:"damage_explosion"} run data modify storage asset:artifact Temp.Trigger.B set value "被爆発ダメージ"
execute if data storage asset:artifact {Trigger:"damage_burn"} run data modify storage asset:artifact Temp.Trigger.B set value "被延焼ダメージ"
execute if data storage asset:artifact {Trigger:"damage_entity"} run data modify storage asset:artifact Temp.Trigger.B set value "被攻撃ダメージ"
execute if data storage asset:artifact {Trigger:"damage_melee"} run data modify storage asset:artifact Temp.Trigger.B set value "被近接ダメージ"
execute if data storage asset:artifact {Trigger: "damage"} run data modify storage asset:artifact Temp.Trigger.B set value "被ダメージ"
execute if data storage asset:artifact {Trigger: "damage_explosion"} run data modify storage asset:artifact Temp.Trigger.B set value "被爆発ダメージ"
execute if data storage asset:artifact {Trigger: "damage_burn"} run data modify storage asset:artifact Temp.Trigger.B set value "被延焼ダメージ"
execute if data storage asset:artifact {Trigger: "damage_entity"} run data modify storage asset:artifact Temp.Trigger.B set value "被攻撃ダメージ"
execute if data storage asset:artifact {Trigger: "damage_melee"} run data modify storage asset:artifact Temp.Trigger.B set value "被近接ダメージ"
execute if data storage asset:artifact {Trigger:"damage_projectile"} run data modify storage asset:artifact Temp.Trigger.B set value "被遠距離ダメージ"
execute if data storage asset:artifact {Trigger:"kill"} run data modify storage asset:artifact Temp.Trigger.B set value "撃破"
execute if data storage asset:artifact {Trigger:"kill_melee"} run data modify storage asset:artifact Temp.Trigger.B set value "近接攻撃で撃破"
execute if data storage asset:artifact {Trigger:"kill_projectile"} run data modify storage asset:artifact Temp.Trigger.B set value "遠距離攻撃で撃破"
execute if data storage asset:artifact {Trigger:"sneak"} run data modify storage asset:artifact Temp.Trigger.B set value "スニーク"
execute if data storage asset:artifact {Trigger:"sneak_1s"} run data modify storage asset:artifact Temp.Trigger.B set value "1秒間スニーク"
execute if data storage asset:artifact {Trigger:"sneak_2s"} run data modify storage asset:artifact Temp.Trigger.B set value "2秒間スニーク"
execute if data storage asset:artifact {Trigger:"sneak_3s"} run data modify storage asset:artifact Temp.Trigger.B set value "3秒間スニーク"
execute if data storage asset:artifact {Trigger:"sneak_4s"} run data modify storage asset:artifact Temp.Trigger.B set value "4秒間スニーク"
execute if data storage asset:artifact {Trigger:"sneak_5s"} run data modify storage asset:artifact Temp.Trigger.B set value "5秒間スニーク"
execute if data storage asset:artifact {Trigger:"sneak_10s"} run data modify storage asset:artifact Temp.Trigger.B set value "10秒間スニーク"
execute if data storage asset:artifact {Trigger:"keep_sneak"} run data modify storage asset:artifact Temp.Trigger.B set value "0秒以上スニーク"
execute if data storage asset:artifact {Trigger:"keep_sneak_1s"} run data modify storage asset:artifact Temp.Trigger.B set value "1秒間以上スニーク"
execute if data storage asset:artifact {Trigger:"keep_sneak_2s"} run data modify storage asset:artifact Temp.Trigger.B set value "2秒間以上スニーク"
execute if data storage asset:artifact {Trigger:"keep_sneak_3s"} run data modify storage asset:artifact Temp.Trigger.B set value "3秒間以上スニーク"
execute if data storage asset:artifact {Trigger:"keep_sneak_4s"} run data modify storage asset:artifact Temp.Trigger.B set value "4秒間以上スニーク"
execute if data storage asset:artifact {Trigger:"keep_sneak_5s"} run data modify storage asset:artifact Temp.Trigger.B set value "5秒間以上スニーク"
execute if data storage asset:artifact {Trigger:"keep_sneak_10s"} run data modify storage asset:artifact Temp.Trigger.B set value "10秒間以上スニーク"
execute if data storage asset:artifact {Trigger:"equip"} run data modify storage asset:artifact Temp.Trigger.AB set value ""
execute if data storage asset:artifact {Trigger:"equip"} run data modify storage asset:artifact Temp.Trigger.B set value ""
execute if data storage asset:artifact {Trigger:"heal"} run data modify storage asset:artifact Temp.Trigger.B set value "回復"
execute if data storage asset:artifact {Trigger: "kill"} run data modify storage asset:artifact Temp.Trigger.B set value "撃破"
execute if data storage asset:artifact {Trigger: "kill_melee"} run data modify storage asset:artifact Temp.Trigger.B set value "近接攻撃で撃破"
execute if data storage asset:artifact {Trigger: "kill_projectile"} run data modify storage asset:artifact Temp.Trigger.B set value "遠距離攻撃で撃破"
execute if data storage asset:artifact {Trigger: "sneak"} run data modify storage asset:artifact Temp.Trigger.B set value "スニーク"
execute if data storage asset:artifact {Trigger: "sneak_1s"} run data modify storage asset:artifact Temp.Trigger.B set value "1秒間スニーク"
execute if data storage asset:artifact {Trigger: "sneak_2s"} run data modify storage asset:artifact Temp.Trigger.B set value "2秒間スニーク"
execute if data storage asset:artifact {Trigger: "sneak_3s"} run data modify storage asset:artifact Temp.Trigger.B set value "3秒間スニーク"
execute if data storage asset:artifact {Trigger: "sneak_4s"} run data modify storage asset:artifact Temp.Trigger.B set value "4秒間スニーク"
execute if data storage asset:artifact {Trigger: "sneak_5s"} run data modify storage asset:artifact Temp.Trigger.B set value "5秒間スニーク"
execute if data storage asset:artifact {Trigger: "sneak_10s"} run data modify storage asset:artifact Temp.Trigger.B set value "10秒間スニーク"
execute if data storage asset:artifact {Trigger: "keep_sneak"} run data modify storage asset:artifact Temp.Trigger.B set value "0秒以上スニーク"
execute if data storage asset:artifact {Trigger: "keep_sneak_1s"} run data modify storage asset:artifact Temp.Trigger.B set value "1秒間以上スニーク"
execute if data storage asset:artifact {Trigger: "keep_sneak_2s"} run data modify storage asset:artifact Temp.Trigger.B set value "2秒間以上スニーク"
execute if data storage asset:artifact {Trigger: "keep_sneak_3s"} run data modify storage asset:artifact Temp.Trigger.B set value "3秒間以上スニーク"
execute if data storage asset:artifact {Trigger: "keep_sneak_4s"} run data modify storage asset:artifact Temp.Trigger.B set value "4秒間以上スニーク"
execute if data storage asset:artifact {Trigger: "keep_sneak_5s"} run data modify storage asset:artifact Temp.Trigger.B set value "5秒間以上スニーク"
execute if data storage asset:artifact {Trigger: "keep_sneak_10s"} run data modify storage asset:artifact Temp.Trigger.B set value "10秒間以上スニーク"
execute if data storage asset:artifact {Trigger: "equip"} run data modify storage asset:artifact Temp.Trigger.AB set value ""
execute if data storage asset:artifact {Trigger: "equip"} run data modify storage asset:artifact Temp.Trigger.B set value ""
execute if data storage asset:artifact {Trigger: "heal"} run data modify storage asset:artifact Temp.Trigger.B set value "回復を与える"
execute if data storage asset:artifact {Trigger: "receive_heal"} run data modify storage asset:artifact Temp.Trigger.B set value "回復を受ける"
# 設定されてなかったらエラーメッセージ
execute unless data storage asset:artifact Temp.Trigger.A run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"登録されていないSlotが指定されています","color":"white"}]
execute unless data storage asset:artifact Temp.Trigger.B run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"登録されていないTriggerが指定されています","color":"white"}]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# @within function asset_manager:artifact/give/

execute if data storage asset:artifact {Trigger:"equip"} run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"equipは主トリガーとしては利用できません"}]
# execute unless data storage asset:artifact Condition run
# execute unless data storage asset:artifact AttackInfo run
# execute unless data storage asset:artifact CostText run
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#> asset_manager:artifact/triggers/
#
# 各トリガーに処理受け渡し
# トリガー処理を行う
#
# @within function asset_manager:artifact/tick/player

Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

# dis_equip
data modify storage lib: Array set from storage asset:artifact Old.CopiedItemData[-1].SubTriggers
data modify storage lib: CompareTarget set value "dis_equip"
data modify storage lib: CompareTarget set value "equip"
function lib:array/compare_single
execute if data storage lib: CompareResult[{_:{_:true}}] run function asset_manager:artifact/triggers/dis_equip/

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#> asset_manager:artifact/triggers/trigger/
#
# 各神器ごとにトリガー処理を行う
#
# @within function asset_manager:artifact/triggers/

# 神器の整形済みデータを取得する
data modify storage asset:artifact New.CopiedItemData set from storage asset:artifact New.ItemData
# 処理用にid一覧を取得しておく
# 不正なidの値 (神器でない || スロットが正しくない) の場合、処理が呼び出されないのでそのまま入れておいていい
data modify storage asset:artifact New.IDList set from storage asset:artifact New.CopiedItemData[].ID
# 各神器ごとに処理を実行する
scoreboard players set $SlotIndex Temporary 17
function asset_manager:artifact/triggers/trigger/foreach/
# リセット
scoreboard players reset $SlotIndex Temporary
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#> asset_manager:artifact/triggers/trigger/foreach/
#
#
#
# @within function
# asset_manager:artifact/triggers/trigger/
# asset_manager:artifact/triggers/trigger/foreach/

#> private
# @private
#declare score_holder $ID

# 神器のデータを取り出す
data modify storage asset:artifact TargetItemData set from storage asset:artifact New.CopiedItemData[-1]
# idが正しい値なら処理に移行する
execute store result score $ID Temporary run data get storage asset:artifact TargetItemData.ID
execute if score $ID Temporary matches 1.. run function asset_manager:artifact/triggers/trigger/foreach/exec
# リセット
scoreboard players reset $ID Temporary
data remove storage asset:artifact TargetItemData
data remove storage asset:artifact New.CopiedItemData[-1]
# 要素が残っているならば再帰
execute if data storage asset:artifact New.CopiedItemData[0] run function asset_manager:artifact/triggers/trigger/foreach/
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#> asset_manager:artifact/triggers/trigger/foreach/call.m
#
#
#
# @input args Trigger : Trigger
# @within function asset_manager:artifact/triggers/trigger/foreach/exec

$function asset_manager:artifact/triggers/$(Trigger)/
Loading

0 comments on commit 1a6b791

Please sign in to comment.