serg
New Member
Posts: 1
|
Post by serg on Aug 2, 2019 8:26:31 GMT
----------------------- while true do r, g, b = getColor(Location(1740, 260)) if r == 0 and g == 0 and b == 0 then click(Location(1640, 1090)) wait(0.2) else break end end ------------------
But how this code will look if i want to check 2 or more points before click? Thank you.
And if it isnt so complicated, how to check by using not only one color, but with range of colors, for example "if this dot darker then 90,90,90"
|
|
|
Post by Exilereven on Aug 2, 2019 19:13:41 GMT
----------------------- while true do r, g, b = getColor(Location(1740, 260)) if r == 0 and g == 0 and b == 0 then click(Location(1640, 1090)) wait(0.2) else break end end ------------------ But how this code will look if i want to check 2 or more points before click? Thank you. And if it isnt so complicated, how to check by using not only one color, but with range of colors, for example "if this dot darker then 90,90,90" OBJ = {} OBJ.color_loc_1 = { color = { 174, 83, 2 }, --put in your own rgb numbers here location = Location(634, 258), -- put in location of color diff = { 10, 10, 10 }, --this will click if it variates in color either way by 10, change to 15, 20 etc... or narrow down to like 5 to get more precise. or 0,0,0 for exact match which i dont recommend. } OBJ.color_loc_2 = { color = { 174, 83, 2 }, location = Location(634, 258), -- - 120 diff = { 10, 10, 10 }, } OBJ.color_loc_3 = { color = { 174, 83, 2 }, location = Location(634, 258), -- - 120 diff = { 10, 10, 10 }, } function colorExists(obj, time) time = time or 1 local timer = Timer() local r, g, b -- error if not obj.color or not obj.location or not is_table(obj.color) then print_r(obj) scriptExit("colorExists: Obj bad format") end usePreviousSnap(false) -- while in time while true do --if is_timeout(timer, time) then return false end -- get location color r, g, b = getColor(obj.location) if obj.diff then 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 else if r == obj.color[1] and g == obj.color[2] and b == obj.color[3] then return true end end -- r, g, b = nil, nil, nil if is_timeout(timer, time) then return false end end end function colorExistsClick(obj, time) if colorExists(obj, time) then click(obj.location) return true end return false end --==============-- Start of script while true do if colorExists(OBJ.color_loc_1, 0) and colorExists(OBJ.color_loc_2, 0) and colorExists(OBJ.color_loc_3, 0) then click( ??location) --put in your own location else break end end UNTESTED, but should get you started
|
|