2017-04-08 90 views
0

嗨我有點新在這個腳本即時試圖使自動化腳本從宏應用程序的iOS/Android使用稱爲自動觸摸的Lua語言https://autotouch.net/server/doc/en.html#autotouch-document 我很笨從哪裏開始從頭開始有這樣的Lua功能? 搜索在整個畫面色彩然後點擊它 腳本與此類似lua基本如何循環?

loop 
color = PixelSearch(x coord, y coord, #somergbColor codes) 
If (color) is found in screen then 
    tap it 

else 
    tap teleport skill/walk to search for target button 

endif 
endloop 

end 

回答

0

的循環不是太具體。您可以使用AutoTouch提供的findColor(color, count, region)getColor(x, y)(在我看來,由於返回的價值,實質上字節大小快於getColors(locations))以兩種方式執行內部操作;但問題來自開發人員,如果他們沒有當然是一個字節數組API,用於處理低位和無符號整數)。

findColor()正在僅限於找到最大1個像素..

local target = 0x447111; 
local location = findColor(target, 1); 
local first = location[1]; 

if location and first then 
    touchDown(1, first[1], first[2]); 
else 
    -- I don't understand this action? 
end 

所以,如果你想找到你的顏色手動您可以使用getColor()

local target = 0x447111; 
local w, h = getScreenResolution(); 

local broken = false; 

for y = 1, h do 
    for x = 1, w do 
     local cur = getColor(x, y); 
     if cur == target then 
      broken = true; 
      break; 
     end 
    end 
    if broken then 
     break; 
    end 
end 

if broken then 
    touchDown(1, 1, 1); 
end