wangxiaoqi7 于 2016.01.26 18:25 提问

lua红包脚本，在《触动精灵》平台运行不稳定，求解答。

function isColor(x,y,c,s)
local fl,abs = math.floor,math.abs
s = fl(0xff*(100-s)*0.01)
local r,g,b = fl(c/0x10000),fl(c%0x10000/0x100),fl(c%0x100)
local rr,gg,bb = getColorRGB(x,y)
if abs(r-rr)<s and abs(g-gg)<s and abs(b-bb)<s then
return true
end
end
function click(x,y,time)
time=time or 30
touchDown(1, x, y)
mSleep(time)
touchUp(1, x, y)
end
-------begin---------------
w,h=getScreenSize()
init(0)
mSleep(2000)
synrecord={
["formpoint"]={0,0}
}

function waitredpackage(...)
while (true) do

``````local x,y = findMultiColorInRegionFuzzy( 0xa4a4a4, "5|0|0x9b9b9b,9|0|0x9c9c9c,12|0|0xacacac,16|8|0x9b9b9b,20|7|0xa9a9a9", 90, 1, 1,w-1, h-1)
``````

if x~=-1 and y~=-1 then
click(x,y)
return findredpackage()

end
end
end
function findredpackage(...)

while (true) do

x,y = findMultiColorInRegionFuzzy( 0xf7d757, "209|15|0xfa9d3b,127|92|0xffffff,42|97|0x999999,-8|87|0x999999", 90, 2, 14, 638, 1110)
if x~=-1 and y~=-1 and x~=synrecord ["formpoint"][1] and y~=synrecord ["formpoint"][2] then
synrecord ["formpoint"][1] =x
synrecord ["formpoint"][2]=y
click(x,y)
mSleep(3000)
if (isColor( 300, 683, 0xffaa3b, 85) and
isColor( 376, 705, 0xffaa3b, 85) and
isColor( 331, 773, 0xffaa3b, 85) and
isColor( 257, 734, 0xffaa3b, 85) and
isColor( 313, 730, 0xffffff, 85) and
isColor( 313, 740, 0xffffff, 85)) then
click(300, 683)
end
end
end
click( 65, 77)
return waitredpackage()
end
waitredpackage()

1个回答

qq_33859708   2016.01.26 22:38

wangxiaoqi7 你可以加QQ群348959530 里面有大神不断的免费教学，也可以去触动精灵官方论坛找找，里面有一些开源的代码。