Lua
獲取隨機值
--獲取隨機值,指定上限和下限 function getRandom(min,max) -- 接收一個整數n作為隨即序列的種子 math.randomseed(os.time()) ----然后不斷產生隨機數 --[[ for i=1, 5 do print(math.random(100)) end]]-- return math.random(min,max) end
獲取當前時間
function getNow() local nowTime = os.date("%Y-%m-%d %H:%M:%S", os.time()) -- print(nowTime) return nowTime end print(os.time())
觸動精靈常用封裝方法
根據坐標點擊
function click(x,y) if(x~= -1 and y~= -1) -- 根據多點顏色區域模糊查色返回的結果 then touchDown(x, y) -- 點擊事件 mSleep(20) touchUp(x, y) end mSleep(1000) end
改良
-- 根據坐標點擊 function click(x,y) if(x~= -1 and y~= -1) -- 根據多點顏色區域模糊查色返回的結果 then touchDown(x, y) -- 點擊事件 mSleep(getRandom(15,30)) touchUp(x, y) end mSleep(getRandom(1000,3000)) -- 點擊后等待一秒到三秒 end