大大您對我的幫助很大 非常謝謝您
我大概弄了一下 給您看看 是否是這樣 也跟您分享 也希望能糾正我
function Buff1() --- 施放BUFF
::Buff1:: ---***做一個標記 BUFF1***
while true do
if getColor(100, 100) ~= 0x000000 then --- 如果沒有BUFF
touchDown(0, 100, 100); --- 點BUFF熱鍵
touchUp(0);
end --- Buff1入口的END
mSleep(500);
coroutine.yield(); --- coroutine類似多線程 重新讓function在準備而不是DEAD
end --- while的END
end --- if的END
function healhp() --- 補血1 入口 (用於平常狀態監測血量)
::healhp1:: ---***做一個標記 healhp***
while true do
if getColor(600, 600) ~= 0x000000 then --- 如果血低於多少
touchDown(0, 1000, 1000); --- 點補血熱鍵
touchUp(0);
end
coroutine.yield(); --- coroutine類似多線程 重新讓function在準備而不是DEAD
end
end
function checkmp() --- 確認魔量 入口
::checkmp:: ---***做一個標記 checkmp***
while true do
if getColor(600, 600) ~= 0x000000 then --- 如果魔低於1/4
goto waitmp --- 去等魔 入口 那邊開始
else --- 否則
touchDown(0, 1000, 1000); --- 按攻擊熱鍵
touchUp(0);
goto buff1 --- 重頭 從buff1那邊開始
end
coroutine.yield(); --- coroutine類似多線程 重新讓function在準備而不是DEAD
end
end
function waitmp() --- 等魔 入口
::waitmp:: ---***做一個標記 waitmp***
while true do
if getColor(600, 600) ~= 0x000000 then --- 如果血低於多少 (等魔時的血量監測)
touchDown(0, 1000, 1000); --- 補血
touchUp(0);
goto waitmp --- 去等魔入口 那邊開始
else if getColor(600, 600) ~= 0x000000 then --- 又如果 魔高於多少
goto main --- 從主入口開始 然後重頭跑程式碼
else --- 否則
goto waitmp --- 去等魔入口 那邊開始 (也就是等到一定量的魔)
end
coroutine.yield(); --- coroutine類似多線程 重新讓function在準備而不是DEAD
end
end
function main() --- 主入口 創建變量 以及恢復
::main::
co1 = coroutine.create(Buff1);
co2 = coroutine.create(healhp);
co3 = coroutine.create(checkmp);
co3 = coroutine.create(waitmp);
while true do
coroutine.resume(co1);
coroutine.resume(co2);
coroutine.resume(co3);
coroutine.resume(co3);
end
end
|