|
Post by podahmad on Jul 11, 2017 1:40:29 GMT
Is pixel search in a region possible in ankulua
|
|
|
Post by Exilereven on Jul 11, 2017 19:14:29 GMT
|
|
|
Post by podahmad on Jul 12, 2017 23:51:28 GMT
thnkuu dear for reply... the tools is useful... and the code ive tought of it..something like this for i = 1, 100 do for j=1,100 do local r, g, b = getColor(Region(i, j, 1, 1)) end end but its lenghty and consume alot of time in autoit,a very powerful tool pixel, search in a region is like instant (specially with higher variation) and im looking for something like that... image search is great but for one it is slow...then its exact and cant detect slight changes in movable object
|
|
|
Post by Mercobots on Jul 13, 2017 2:23:26 GMT
luaLib = loadstring(httpGet("https://raw.githubusercontent.com/mercobots/luaLib/master/luaLib.min.lua"))() -- function colorExists(obj, time) local delay = 0.1 time = time or 1 local timer = Timer() local r, g, b obj.diff = obj.diff or { 0, 0, 0 }
-- error if not obj.color or not obj.location or not is_table(obj.color) or not is_table(obj.diff) then print_r(obj) scriptExit("colorExists: Obj bad format") end
-- while in time while not is_timeout(timer, time) do -- get location color r, g, b = getColor(obj.location)
if math.abs(obj.color[1] - r) <= obj.diff[1] then if math.abs(obj.color[2] - g) <= obj.diff[2] then if math.abs(obj.color[3] - b) <= obj.diff[3] then return true end end end -- r, g, b = nil, nil, nil --sleep(delay) end return false end
--
function colorExistsRegion(table_obj, time, range) local reg = get_values(table_obj.region) local obj = {} obj.color = table_obj.color range = range or 1
for x = reg.x, reg.x + reg.w, range do for y = reg.y, reg.y + reg.h, range do obj.location = Location(x, y) if colorExists(obj, time) then Region(x-4,y-4,8,8):highlight(3) return true end end end return false end
How to use -- create your OBJ
OBJ = {} OBJ.btn = { location = Location(300, 300),-- not required region = Region(300,300,300,300) color = { 230, 216, 203 }, }
--
print(colorExistsRegion(OBJ.btn, 0, 10))
Range is the only thing different here, this will check 10 by 10 pixels in a region i really don't recommend this method, now is up to you
|
|
|
Post by podahmad on Jul 13, 2017 17:38:11 GMT
luaLib = loadstring(httpGet("https://raw.githubusercontent.com/mercobots/luaLib/master/luaLib.min.lua"))() -- function colorExists(obj, time) local delay = 0.1 time = time or 1 local timer = Timer() local r, g, b obj.diff = obj.diff or { 0, 0, 0 }
-- error if not obj.color or not obj.location or not is_table(obj.color) or not is_table(obj.diff) then print_r(obj) scriptExit("colorExists: Obj bad format") end
-- while in time while not is_timeout(timer, time) do -- get location color r, g, b = getColor(obj.location)
if math.abs(obj.color[1] - r) <= obj.diff[1] then if math.abs(obj.color[2] - g) <= obj.diff[2] then if math.abs(obj.color[3] - b) <= obj.diff[3] then return true end end end -- r, g, b = nil, nil, nil --sleep(delay) end return false end
--
function colorExistsRegion(table_obj, time, range) local reg = get_values(table_obj.region) local obj = {} obj.color = table_obj.color range = range or 1
for x = reg.x, reg.x + reg.w, range do for y = reg.y, reg.y + reg.h, range do obj.location = Location(x, y) if colorExists(obj, time) then Region(x-4,y-4,8,8):highlight(3) return true end end end return false end
How to use -- create your OBJ
OBJ = {} OBJ.btn = { location = Location(300, 300),-- not required region = Region(300,300,300,300) color = { 230, 216, 203 }, }
--
print(colorExistsRegion(OBJ.btn, 0, 10))
Range is the only thing different here, this will check 10 by 10 pixels in a region i really don't recommend this method, now is up to you Thnks aloott for ur code..ill try it im working on visitor for hayday bot...to give them wheat image search is v slow and ineffective since visitor dont stay same
|
|