当我在手机上运行此代码时,它会运行每一步,然后当它发现故障时,它将返回到代码的开头,然后发出警报。我想要它做的是完全按照它的方式运行每个函数,但是,仅在最后一个函数运行时提醒我。在代码末尾记录打印。
--Step 1 Open Quests
questopen = function()
log("Opening Quests")
local step1 = getColor(64, 803)
log("Fetched Quest Icon")
if step1 == 9127481 then
tap(64, 803)
log("Matched Quest Icon")
else
log("Failed Quest Icon")
alert("Out of Sync - Check Logs for failure")
collectgarbage()
end
end
--Step 2 Accept Quest
questaccept = function()
log("Accepting Quest")
local step2 = getColor(426, 1004)
log("Fetched Accept Quest")
if step2 == 2300441 then
tap(426, 1004)
log("Matched Accept Quest")
else
log("Failed Accept Quest")
collectgarbage()
questopen()
end
end
--Step 3 Skip Dialogue
skip = function()
log("Skipping Dialogue")
local step3 = getColor(564, 1083)
log("Fetched Skip Dialogue")
if step3 == 2300441 then
tap(564, 1083)
log("Matched Skip Dialogue")
else
log("Failed Skip Dialogue")
collectgarbage()
questaccept()
end
end
--Step 4 Quest Confirm
confirm = function()
log("Confirming Quest")
local step4 = getColor(124, 578)
log("Fetched Confirm Quest")
if step4 == 15921906 then
tap(124, 578)
log("Matched Confrim Quest")
else
log("Failed Confirm Quest")
collectgarbage()
skip()
end
end
--Step 5 Quest Go
go = function()
log("Quest Go")
local step5 = getColor(424, 990)
log("Fetched Quest Go")
if step5 == 13750737 then
tap(424, 990)
log("Matched Quest Go")
else
log("Failed Quest Go")
collectgarbage()
confirm()
end
end
questopen()
usleep(3000000)
questaccept()
usleep(3000000)
skip()
usleep(3000000)
confirm()
usleep(3000000)
go()
usleep(3000000)
我专门设计了这个以测试检测方法,所以我希望它在Step 2 Accept Quests
失败。但目前我想要一种更好的错误检测方法,我想要提醒。但它会警告每一次失败。
我希望代码在第一次失败时倒退,但我不希望它在同一时间继续前进,错误报告将显示。