|
Post by AutoBOT on Jun 20, 2017 6:21:34 GMT
after checking yamada's thread I got interested, because getColor is so fast. I know as you said it destroy the easiness. but for advance/expert dev, faster mean better.
so I have this suggestion to add to the commonLib colorWaitMulti(target, clickLocation, similarity, second, debug)
target = (color1, coordinate1, color2, coordinate2) **could add more color and coordinate for more accurate**
for i t in pair(target) do if(target match and clickLocation)then click(clickLocation) end elseif(target match) return i, t.id end end
if timer > second return -1
something like that. and then for the similarity it will be like the code from yamada
r1,g1,b1 = color1 ra1,ga1,ba1 = getColor(coordinate1) if math.abs(ra1-r1) <= similarity then if math.abs(ga1-g1) <= similarity then if math.abs(ba1-b1) <= similarity then return 1 end end end
I'm not really good for optimization code, so I only give the rough explanation. I'm sure you understand more than me. for checking RGB from image, we can just use simple MsPaint and use the colorpicker and the coordinate also available in MsPaint.
|
|
|
Post by AutoBOT on Jun 20, 2017 13:59:08 GMT
i copy and edit some of yamada's code and here what i make, its not the best, simple and optimize. but its kinda work
lib.lua
function getColors(x, y)
local r, g, b = getColor(Location(x, y))
local colors = r * 256 * 256 + g * 256 + b
return colors
end
function RGBcheck(a,b, diff)
local r1,g1,b1 = intToRgb(a)
local ra1,ga1,ba1 = intToRgb(b)
if math.abs(ra1-r1) <= diff then
if math.abs(ga1-g1) <= diff then
if math.abs(ba1-b1) <= diff then
return 1
end
end
end
return 0
end
function intToRgb(val)
local GetRed = val % 256
val= ( val - GetRed ) / 256
local GetGreen = val % 256
val= ( val - GetGreen ) / 256
local GetBlue = val % 256
return GetBlue,GetGreen,GetRed
end
function colorWaitMulti(target, seconds, diff, skipLocation)
local timer = Timer()
while (true) do
for i, t in ipairs(target) do
local rgb = getColors(t[2], t[3])
local match = RGBcheck(t[1], rgb, diff)
local rgb2 = getColors(t[5], t[6])
local match2 = RGBcheck(t[4], rgb2, diff)
if(match + match2) == 2 then
return i
end
end
if (skipLocation ~= nil) then click(skipLocation) end
if (timer:check() > seconds) then
usePreviousSnap(false)
return -1, "__none__"
end
end
end main.lua
dungeonEyes = {
{0xFAEDC7, 326, 525, 0xDDA546, 416, 512},
{0xFAEDC7, 126, 525, 0xDDD846, 116, 512},
}
local iSpy = colorWaitMulti(dungeonEyes, 10, 20)
|
|
|
Post by AutoBOT on Jun 21, 2017 15:17:41 GMT
it seems my code has memory leak or something like that. my BlueStack storage become so full after a dozen runs.
I'm not sure at which part. if only someone can help develop this D:
|
|