|
Post by AnkuLua on Jun 26, 2018 1:14:02 GMT
hi, sorry for this dumb question (since i'm only used to hexa color), how to convert hexa color to lua color ? Is this what you want? function hex2rgb(hex) b = hex % 0x100 hex = (hex - b ) / 0x100 g = hex %0x100 hex = (hex - g) / 0x100 return (hex % 0x100), g, b end
|
|
|
Post by joseltr on Jul 21, 2018 15:20:39 GMT
setHighlightTextStyle (0xddffff00, 0x00000000, 18)
this is not work to me, text background, color also text size looks as default, or i was wrong?
|
|
|
Post by AnkuLua on Jul 22, 2018 2:01:59 GMT
setHighlightTextStyle (0xddffff00, 0x00000000, 18) this is not work to me, text background, color also text size looks as default, or i was wrong? It should work. What's your script? Please also share the result screenshot.
|
|
|
Post by liusad on Jul 23, 2018 23:30:53 GMT
Hi,
I have some trouble with my script and I wonder if it is because I'm misunderstanding how touchDown is used.
I want to press a location on the screen until a pixel changes colour,release until it changes back and repeat until a button appears. I have a toast giving me feedback about the rgb values, so they are not the issue at hand. I'll post the script I have written so far:
Settings:setCompareDimension(true, 1280) Settings:setScriptDimension(true, 1280) Settings:set("MinSimilarity", 0.8) local loc = Location(630,155) local bar = Region(365,130,700,45) local bubble = Region(50,250,200,200) while true do wait(1) click(Location(1170,610)) if bar:exists("great.png", 10) then click(Location(1170,610)) end wait(1) if bubble:exists("bite.png", 15) then click(Location(1170,610)) end wait(2) hooked = 1 while hooked == 1 do r, g, b = getColor(loc) toast ("r:" .. r .. " g:" .. g .. " b:" .. b) touchDown(Location(1170,610)) while (r <= 13 and g <= 60 and b <= 160) do r, g, b = getColor(loc) toast ("r:" .. r .. " g:" .. g .. " b:" .. b) end touchUp(Location(1170,610)) --if exists ("jump.png", 1) then --wait(1) --swipe(Location(1170,610),Location (450,610)) if exists("continue.png", 1) then existsClick("continue.png", 10) hooked = 0 else end end end wait(5) end end
Thanks in advance!
EDIT:
So I've solved a par of it, it seems like you can't have a while loop based on RGB? Is there a way yo to that ?
|
|
|
Post by Exilereven on Jul 24, 2018 11:41:13 GMT
You need to setup your touchDown, up, wait all that, THEN fire everything you just asked it to do. It will shoot off anything in your table like this.
An example I use in my code all the time. Just a simple function to move the screen right for me.
function screenRight() local loc_left = Location(237, 600) local loc_right = Location(1644, 535) --setup your touch how you want it performed local move = { { action = "touchDown", target = loc_right }, { action = "wait", target = 0.2 }, { action = "touchMove", target = loc_left }, --{ action = "wait", target = 0.8 }, { action = "touchUp", target = loc_left }, }
setManualTouchParameter(5, 1) --this is where we actually fire off everything in the move {} table. manualTouch(move) end
Hope this helps.
|
|
|
Post by liusad on Jul 24, 2018 12:35:06 GMT
You need to setup your touchDown, up, wait all that, THEN fire everything you just asked it to do. It will shoot off anything in your table like this. An example I use in my code all the time. Just a simple function to move the screen right for me. function screenRight() local loc_left = Location(237, 600) local loc_right = Location(1644, 535) --setup your touch how you want it performed local move = { { action = "touchDown", target = loc_right }, { action = "wait", target = 0.2 }, { action = "touchMove", target = loc_left }, --{ action = "wait", target = 0.8 }, { action = "touchUp", target = loc_left }, } setManualTouchParameter(5, 1) --this is where we actually fire off everything in the move {} table. manualTouch(move) end Hope this helps. This seems interesting, but can I use other functions in there like getColor for example? Since I do not know the actual time it needs to wait before the pixel changes color to trigger touchUp I don't see how I can make it work otherwise.
|
|
|
Post by Exilereven on Jul 24, 2018 12:39:54 GMT
Try something like
While true do --get rgb color then If (r==bla, b==bla,g==bla) then --do something Else Break end End
Get it to loop
Better example later when I get a min
|
|
|
Post by liusad on Jul 24, 2018 13:31:37 GMT
Try something like While true do --get rgb color then If (r==bla, b==bla,g==bla) then --do something Else Break end End Get it to loop Better example later when I get a min Thanks, I made a post in the script skills forum if you want to reply there instead!
|
|
|
Post by yamada on Aug 23, 2018 14:51:25 GMT
Please introduce AutoTouch's findcolor function
By responding with AutoMAinPNG, Ankulua will make a leap
|
|
|
Post by AnkuLua on Sept 11, 2018 0:43:34 GMT
Please introduce AutoTouch's findcolor function By responding with AutoMAinPNG, Ankulua will make a leap
We strongly suggest to use image recognition in stead of color search. It's more intuitive and easy to maintain and debug. If you really want more complex color search functions, you can always use getColor() to build the functions. The below is what you want. function intToRGB(value) local b = value % 0x100 value = math.floor(value / 0x100) local g = value % 0x100 value = math.floor(value / 0x100) local r = value % 0x100 return r, g, b end
function findColors(colors, count, region) if (count == 0) then count = #colors end local x, y local minX = region:getX() local maxX = region:getX() + region:getW() - 1 local minY = region:getY() local maxY = region:getY() + region:getH() - 1
local minXOffset = 0 local maxXOffset = region:getW() - 1 local minYOffset = 0 local maxYOffset = region:getH() - 1 for i = 2, count do if (color[i][2] < minXOffset) then minXOffset = color[i][2] end if (color[i][2] > maxXOffset) then maxXOffset = color[i][2] end if (color[i][3] < minYOffset) then minYOffset = color[i][3] end if (color[i][3] > maxYOffset) then maxYOffset = color[i][3] end end
snapshotColor() local result = {} for x = minX - minXOffset, maxX - maxXOffset do for y = minY - minYOffset, maxY - maxYOffset do for i = 1, count do local tx = x + colors[count][2] local ty = y + colors[count][3] local r, g, b = intToRGB(colors[i][1]) local tr, tg, tb = getColor(Location(tx, ty)) if (tr ~= r or tg ~= g or tb ~= b) then break end if (i == count) then table.insert(result, {x, y}) end end end end
usePreviousSnap(false) return result end Note: The functions are not verified and may contain bugs.
|
|
|
Post by yamada on Oct 13, 2018 12:47:20 GMT
Thank you
I got to move Very very late!!! -- sub findColor function findColors(colors, count, region) if (count == 0) then count = #colors end local x, y local minX = region[1] local maxX = region[1] + region[3] -1 local minY = region[2] local maxY = region[2] + region[4] -1 local minXOffset = 0 local maxXOffset = 0 local minYOffset = 0 local maxYOffset = 0 for i = 2, count do if (colors[i][2] < minXOffset) then minXOffset = colors[i][2] end if (colors[i][2] > maxXOffset) then maxXOffset = colors[i][2] end if (colors[i][3] < minYOffset) then minYOffset = colors[i][3] end if (colors[i][3] > maxYOffset) then maxYOffset = colors[i][3] end end snapshotColor() usePreviousSnap(true) local result = {} local boolm = false for x = minX - minXOffset, maxX - maxXOffset do for y = minY - minYOffset, maxY - maxYOffset do for i = 1, count do local tx = x + colors[i][2] local ty = y + colors[i][3] local r, g, b = intToRgb(colors[i][1]) local tr, tg, tb = getColor(Location(tx, ty)) if (tr ~= r or tg ~= g or tb ~= b) then break end if (i == count) then table.insert(result, {x, y}) boolm = true break end end if boolm == true then break end end if boolm == true then break end end usePreviousSnap(false) return result end -- sub Color Check int to RGB 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 Waitset(tims) wait(tims / 1000) end function Tapf(tx , ty , waits) click(Location(tx , ty)) Waitset(waits) end for i = 1 , 5 do local res = 0 local result = findColors({{0xFFFF00,0,0},{0xFFFF00,0,6},{0xFFFF00,16,10}, {0xFFFF00,89,16},{0xFFFF00,89,-10}},0,{92,259,1000,830}) for i,v in pairs(result) do Tapf(v[1], v[2], 500) wait(0.5) res = 1 break end if res == 1 then break end end
|
|
|
Post by gslinux on Apr 4, 2019 23:19:12 GMT
I'm experimenting creating my own script so I wonder is there a limit to the number of seconds as to wait() still works? My script is meant to do missions but missions might take a while to complete, in the hours range most of the time, so I wonder if it can be made to wait 1-2 hours. Thanks in advance.
|
|
|
Post by AnkuLua on Apr 5, 2019 22:18:10 GMT
I'm experimenting creating my own script so I wonder is there a limit to the number of seconds as to wait() still works? My script is meant to do missions but missions might take a while to complete, in the hours range most of the time, so I wonder if it can be made to wait 1-2 hours. Thanks in advance. There is no limitation on wait()
|
|
|
Post by gslinux on Apr 6, 2019 0:28:57 GMT
I'm experimenting creating my own script so I wonder is there a limit to the number of seconds as to wait() still works? My script is meant to do missions but missions might take a while to complete, in the hours range most of the time, so I wonder if it can be made to wait 1-2 hours. Thanks in advance. There is no limitation on wait() Thanks. I'll try implementing in waits of 1-2 hours.
|
|
jumk
New Member
Posts: 4
|
Post by jumk on Oct 4, 2019 8:14:01 GMT
Hi, Really starting to enjoy Ankulua, exactly what I was looking for !
The documentation for exists / existsClick is not clear enough to me. The behavior with or without the 'seconds' parameter is not explicit. Typically what I want to control is that a single screenshot be taken, and then wait if it is unsucessful : while not myregion:existsClick("myimage.png", seconds) do sleep(10.0) end If I simply use
myregion:existsClick("myimage.png")
does the "seconds" parameter take a default value ? how much ? how many screenshots are then taken ?
I also tried something like this :
while not myregion:existsClick("myimage.png", 10.0) do toast("not found") end
and it seems it was causing my script to become unstable: my script simply stopped running after a while, without any error message
It is now much more stable with for example :
while not myregion:existsClick("myimage.png", 0.5) do sleep(10.0) end Please explain what's happening under the hood !
I'm running latest 8.5.5 Pro
Thanks
|
|