|
Post by stygianumbra on Apr 13, 2018 8:20:35 GMT
How do I acheive this, I have tried multiple ways and everything fails. I have no experience and started this attempt 2 hours ago but it seems like it should be simple. Wait for image overnight and after I get afk pkilled run my character back to farming.
----- created by AnkuLua snap and play script ------ immersive = true setImmersiveMode(immersive) scriptDimension = 1920 Settings:setScriptDimension(true, scriptDimension) Settings:setCompareDimension(true, scriptDimension) local index = 1 touchList = {} waitList = {}
function checking() if exists("1.png") then reposition()
end
function reposition()
touchList[index] = {target = "2.png", region = Region(1801, 351, 58, 58), id = "2", action = 'click'} index = index + 1
touchList[index] = {target = "3.png", region = Region(1683, 172, 58, 58), id = "3", action = 'click'} index = index + 1
touchList[index] = {target = "4.png", region = Region(716, 596, 58, 58), id = "4", action = 'click'} index = index + 1
touchList[index] = {target = "5.png", region = Region(1822, 37, 58, 58), id = "5", action = 'click'} index = index + 1
touchList[index] = {target = "6.png", region = Region(1385, 886, 58, 58), id = "6", action = 'click'} index = index + 1
end end checking() -------
|
|
|
Post by Acera Dryd on Apr 13, 2018 16:07:19 GMT
I think, you want to use a while-loop. while-loop:
while CONDITION do INSTRUCTIONS ... end or for your example:
...
while true do if exists("1.png") then reposition() end end
... The loop will do the instructions "forever", cause the condition is everytime true.
|
|
|
Post by stygianumbra on Apr 13, 2018 19:44:10 GMT
I think, you want to use a while-loop. while-loop:
while CONDITION do INSTRUCTIONS ... end or for your example:
...
while true do if exists("1.png") then reposition() end end
... The loop will do the instructions "forever", cause the condition is everytime true.
Thanks this got me further but now it won't click on anything. After the while loop detects the image it doesn't do anything. I added a toast message after the loop to debug and it doesn't display the toast till the image appears so it is detecting the image but it never executes the function. I tried with a snap and play script and this record and play script, neither execute. ----- created by AnkuLua record script ------ immersive = true setImmersiveMode(immersive) scriptDimension = 1920 Settings:setScriptDimension(true, scriptDimension) local index = 1 touchList = {} waitList = {} function reposition() ------ 1 ----- touchList[index] = {"click", Location(1732, 656)} waitList[index] = 2.974000 index = index + 1 ------ 2 ----- touchList[index] = {"click", Location(1846, 374)} waitList[index] = 1.206000 index = index + 1 ------ 3 ----- touchList[index] = {"click", Location(1710, 144)} waitList[index] = 2.049000 index = index + 1 ------ 4 ----- touchList[index] = {"click", Location(792, 619)} waitList[index] = 1.463000 index = index + 1 ------ 5 ----- touchList[index] = {"click", Location(1866, 62)} waitList[index] = 14.863000 index = index + 1 ------ 6 ----- touchList[index] = {"click", Location(1399, 931)} waitList[index] = 3.583000 index = index + 1 end while true do if exists("dead.png") then toast("repositioning") reposition() end end I added more toasts between each click action and it just cycles through all of the toasts after detecting the first image never actually clicking anything, why is this so difficult I have used macros on PC over a decade ago using image recognition to execute clicks and it was easy.
|
|
|
Post by Acera Dryd on Apr 13, 2018 21:34:08 GMT
Oh sry, i havent looked at this function. I think you use ankuluas library wrong. To click on a location use: loc = Location(x,y) click(loc)
For regions use: reg = Region(x,y,w,h) reg:click() --Clicks random in the region
Or
reg:existsClick(Pattern("filename.png")) --Clicks if the Pattern were found You will find further examples at: ankulua.boards.net/thread/6/basic-objects-methods-introduction
|
|
|
Post by stygianumbra on Apr 13, 2018 22:06:42 GMT
Oh sry, i havent looked at this function. I think you use ankuluas library wrong. To click on a location use: loc = Location(x,y) click(loc)
For regions use: reg = Region(x,y,w,h) reg:click() --Clicks random in the region
Or
reg:existsClick(Pattern("filename.png")) --Clicks if the Pattern were found You will find further examples at: ankulua.boards.net/thread/6/basic-objects-methods-introductionI have added in lines like click(1710, 144) and it does not click the coordinates. I managed to get existsClick to get through the two dialogues but I can't get it to actually click anything manually. function reposition() existsClick("dead2.png") toast("executed dead2") click(1710, 144) toast("1") wait(2) click(792, 619) toast("2") wait(1.5) click(1866, 62) toast("3") wait(15) click(1399, 931) toast("4") end while true do if existsClick("dead.png") then toast("repositioning") reposition() end end If I use snap and play or record to play it clicks but my own scripts won't click.
|
|
|
Post by Acera Dryd on Apr 13, 2018 22:19:49 GMT
No, click(x,y) doesnt work.
click(Location(x,y)) or click(Region(x,y,w,h)) works instead. The function "click" needs pattern, match, region, string(for pattern) or location as argument.
|
|
|
Post by stygianumbra on Apr 13, 2018 22:31:06 GMT
No, click(x,y) doesnt work. click(Location(x,y)) or click(Region(x,y,w,h)) works instead. The function "click" needs pattern, match, region, string(for pattern) or location as argument. I got you now, thank you for all the help. My final dirty product: function reposition() existsClick("dead2.png") toast("executed dead2") starT = Location(1710, 144) click(starT) toast("1") wait(2) locatE = Location(792, 619) click(locatE) toast("2") wait(1.5) closE = Location(1866, 62) click(closE) toast("3") wait(15) autO = Location(1399, 931) click(autO) toast("4") end while true do if existsClick("dead.png") then toast("repositioning") reposition() end end With basics set now working on making it better.
|
|
|
Post by Acera Dryd on Apr 13, 2018 22:39:35 GMT
Okay, nice Good luck with your script.
|
|
|
Post by Exilereven on May 3, 2018 19:10:24 GMT
No, click(x,y) doesnt work. click(Location(x,y)) or click(Region(x,y,w,h)) works instead. The function "click" needs pattern, match, region, string(for pattern) or location as argument. I got you now, thank you for all the help. My final dirty product: function reposition() existsClick("dead2.png") toast("executed dead2") starT = Location(1710, 144) click(starT) toast("1") wait(2) locatE = Location(792, 619) click(locatE) toast("2") wait(1.5) closE = Location(1866, 62) click(closE) toast("3") wait(15) autO = Location(1399, 931) click(autO) toast("4") end while true do if existsClick("dead.png") then toast("repositioning") reposition() end end With basics set now working on making it better. You were wanting to clean it up. Just incase you haven't tried tables yet. This is just one way to help keep things tidy. LOC = {} LOC.reposition = { starT = Location(1710, 144), locatE = Location(792, 619), closE = Location(1866, 62), autO = Location(1399, 931), } function reposition() existsClick("dead2.png") toast("executed dead2") -- click(LOC.reposition.starT) toast("1") wait(2) -- click(LOC.reposition.locatE) toast("2") wait(1.5) -- click(LOC.reposition.closE) toast("3") wait(15) -- click(LOC.reposition.autO) toast("4") end while true do if existsClick("dead.png") then toast("repositioning") reposition() end end
|
|