許瑜翔(清風)

每當玩家點擊背包、移動物品時進行攔截

on inventory click: if cursor item of player is a diamond sword: if name of cursor item of player is "&e神聖之劍": set cursor item of player to air execute console command "mm items give %player% 你的Mythic物品ID 1" send "&a&l【系統】&7偵測到特殊道具,已為您自動轉換為 Crucible 物品!" to player

每當玩家從地上撿起該物品時攔截

on pick up: if event-item is a diamond sword: if name of event-item is "&e神聖之劍": cancel event delete event-entity execute console command "mm items give %player% 你的Mythic物品ID 1"

用法是讓玩家把神聖之劍替換成mythiccrucible物品,檢查用法和效能

Kodari AI
KodariSep 25 at 3:55 pm 1
ItemConverterSkript
This Skript plugin intercepts player inventory clicks and item pickups to detect specific diamond swords with custom names. When detected, the original item is removed and replaced with a Mythic/Crucible item via console command. The plugin provides automatic conversion feedback messages to players, ensuring seamless item transformation without manual intervention.

已將攔截流程整理成可直接放入 Skript 的版本。原本的 delete event-entity 不安全:拾取事件中的實體不一定是地上的物品;新版本改為確認物品確實進入玩家背包後,再移除原物品並發放 MythicCrucible 物品。

把 REPLACE_WITH_MYTHIC_ITEM_ID 換成 MythicCrucible 的物品 ID。背包點擊部分會在玩家把劍拿到游標上後攔截;拾取部分則延後一 tick 確認背包數量有增加,避免背包已滿時仍發放替代物。將檔案放入 plugins/Skript/scripts/,再執行 /sk reload convert_holy_sword。

許瑜翔(清風)

若使用ConditionalEvent這個插件來呈現呢?

Kodari AI
KodariSep 25 at 4:04 pm 1

可以用 ConditionalEvents 的 YAML 事件處理背包內移動;它不是 Skript 語法,設定放在 plugins/ConditionalEvents/config.yml 的 Events: 區段,或放進 plugins/ConditionalEvents/events/ 下的事件檔案。

YAML
Events:
  convert_holy_sword:
    type: item_move
    conditions:
    - "%item% == DIAMOND_SWORD"
    - "%item_name% contains 神聖之劍"
    actions:
      default:
      - "cancel_event: true"
      - "remove_item: DIAMOND_SWORD;1;name: 神聖之劍"
      - "console_command: mm items give %player% 你的Mythic物品ID 1"
      - "message: &a&l【系統】&7偵測到特殊道具,已為您自動轉換為 Crucible 物品!"

這會攔截玩家在背包中移動符合名稱的鑽石劍、取消移動、移除一把舊劍,再執行指令發放 MythicCrucible 物品。remove_item 的名稱不要加 &e 色碼;條件用 contains 神聖之劍,可避開顏色格式差異。記得把 你的Mythic物品ID 換成實際 ID。

地上拾取不建議直接照搬。 ConditionalEvents 的 item_pickup 可以取消拾取,但沒有安全地刪除「這一次拾取事件中的那個地上物品」的通用動作;若用延遲後移除背包物品的方式,背包滿時可能移除玩家原本就有的神聖之劍,造成錯誤轉換。若也要可靠攔截地上拾取,建議保留 Skript 的拾取處理,或使用能直接操作拾取物品實體的方案。

設定後執行 /ce reload 重新載入 ConditionalEvents。

Kodari can make mistakes. Review important code before using.
Files
convert_holy_sword.sk
Code
1 58
convert_holy_sword.sk
options:
    mythic-item-id: REPLACE_WITH_MYTHIC_ITEM_ID

on inventory click:
    set {_p} to player
    set {_key} to uuid of {_p}

    if {holy-sword-convert::%{_key}%} is set:
        cancel event
        stop

    if cursor item of {_p} is a diamond sword:
        if name of cursor item of {_p} is "&e神聖之劍":
            cancel event
            set {holy-sword-convert::%{_key}%} to true
            wait 1 tick
            if {_p} is online:
                if cursor item of {_p} is a diamond sword:
                    if name of cursor item of {_p} is "&e神聖之劍":
                        set cursor item of {_p} to air
                        execute console command "mm items give %{_p}% {@mythic-item-id} 1"
            delete {holy-sword-convert::%{_key}%}

on inventory drag:
    set {_key} to uuid of player
    if {holy-sword-convert::%{_key}%} is set:
        cancel event

on drop:
    set {_key} to uuid of player
    if {holy-sword-convert::%{_key}%} is set:
        cancel event

on pickup:
    if event-item is a diamond sword:
        if name of event-item is "&e神聖之劍":
            set {_p} to player
            set {_before} to 0

            loop {_p}'s inventory:
                if loop-item is a diamond sword:
                    if name of loop-item is "&e神聖之劍":
                        add amount of loop-item to {_before}

            wait 1 tick

            if {_p} is online:
                set {_after} to 0

                loop {_p}'s inventory:
                    if loop-item is a diamond sword:
                        if name of loop-item is "&e神聖之劍":
                            add amount of loop-item to {_after}

                set {_converted} to {_after} - {_before}
                if {_converted} > 0:
                    remove {_converted} of diamond swords named "&e神聖之劍" from {_p}
                    execute console command "mm items give %{_p}% {@mythic-item-id} %{_converted}%"