Mudlet 喚醒其他 Profile
- Davy Lam
- Oct 3, 2021
- 1 min read
這篇文章會講解一下我是如何一鍵喚醒隊伍,如果大家有好的方法可以提我一下哦~
前置
1. Profile已經打開 (Offline mode)
*記得要儲存密碼

2. 登記事件處理器
Script每次開profile都會跑一遍,所以你只要放以下code入script,他每次就會自動跑
通常我會登記一下Event Handler ID,防止重覆登記
if startmohandlerID then killAnonymousEventHandler(startmohandlerID) end
然後就是登記事件,很簡單是吧
系統見到事件: startmo 就會呼叫函式: startmo
startmohandlerID = registerAnonymousEventHandler("startmo", "startmo")
3. 登記了Startmo就要建立相應的函式
function startmo()
先檢查一下角色有沒有登入,沒有的話就用reconnect登入
local host, port, connected = getConnectionInfo()
if not connected then
reconnect()
end
end
4. 最後就是建立Alias呼叫事件
raiseGlobalEvent("startmo")
cecho("<yellow>召喚戰隊\n")
raiseGlobalEvent的話全部打開的profile都會收到的
也可以傳輸參數的,下面例子就是呼叫skymo去幫忙減福緣或教學
raiseGlobalEvent("callskymo","-luck")
function callskymo(event, incoming_action)
if cur_char == "skymo" then
local host, port, connected = getConnectionInfo()
if not connected then
reconnect()
action = incoming_action
elseif connected and incoming_action == "teach" then
send("say teach")
end
end
end
Comments