|
Post by AnkuLua on Jun 30, 2018 0:25:08 GMT
Why did you say it doesn't work? You can add both wait(10) and setScanInterval(5) if you want action = 'click(matchResult); setBrightness(1);wait(10); setScanInterval(5)'
|
|
draly
New Member
Posts: 11
|
Post by draly on Jun 30, 2018 9:38:18 GMT
Why did you say it doesn't work? You can add both wait(10) and setScanInterval(5) if you want action = 'click(matchResult); setBrightness(1);wait(10); setScanInterval(5)' Because when i enable debug mode, i can see the red squares jump quickly from one to the another in less than a second. When it finds something and click on it, it waits for the desired time, but after the wait, it starts searching too quick and i would like to slow that down. Let's say it find the 1.png, it clicks, then wait 30 seconds, then look for 2.png, doesn't find it, then it will wait 5 seconds, then skip to 3.png, and so on. I don't know if i'm clear enough. The script works perfectly as it is, but it's useless in my case to look for the png that quick, and i think that would drain less battery on my phone to wait 5 seconds between each search (found or not). Here's my full script, maybe i missed something. It's for might and magic elemental guardians, it looks if the "auto" button is activated, if not, click on it, then wait for the victory screen and click on it, or click on the give up button if you loose, then check if quick battle is enabled, if not, clic on it, then retrieve glyphe or monster if you got one and then click on the replay (play again ?) button. insert code here----- 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 = {}
------ 1 ----- touchList[index] = {target = "Auto.png", region = Region(272, 879, 200, 200), id = "Auto", action = 'click(matchResult); wait(40); setScanInterval(5)'} index = index + 1
------ 2 ----- touchList[index] = {target = "Victoire.png", region = Region(914, 871, 200, 200), id = "Victoire", action = 'click(matchResult); setBrightness(1); wait(5); setScanInterval(5)'} index = index + 1
------ 3 ----- touchList[index] = {target = "Abandonner.png", region = Region(890, 384, 200, 200), id = "Abandonner", action = 'click(matchResult); wait(10); setScanInterval(5)'} index = index + 1
------ 4 ----- touchList[index] = {target = "Obtenir.png", region = Region(1051, 851, 200, 200), id = "Obtenir", action = 'click(matchResult); wait(5); setScanInterval(5)'} index = index + 1
------ 5 ----- touchList[index] = {target = "Dropmob.png", region = Region(873, 873, 200, 200), id = "Dropmob", action = 'click(matchResult); wait(10); setScanInterval(5)'} index = index + 1
------ 6 ----- touchList[index] = {target = "Battaillerapide.png", region = Region(622, 812, 200, 200), id = "Battaillerapide", action = 'click(matchResult); wait(3); setScanInterval(5)'} index = index + 1
------ 7 ----- touchList[index] = {target = "Rejouer.png", region = Region(820, 517, 200, 200), id = "Rejouer", action = 'click(matchResult); wait(50); setScanInterval(5)'} index = index + 1
|
|
|
Post by AnkuLua on Jun 30, 2018 11:42:13 GMT
If that's what you want, you could write your own script.
|
|
|
Post by akumaburn on Jul 12, 2018 5:12:48 GMT
In case you want to add a delay in between script runs, here something I just cooked up(feel free to add it to the main script):
Step 1
Add your delay string (can customize for your language in with the rest of your strings, or you can add it for all languages if you feel like it):
delayTimerString="Delay between script runs (s)"
Step 2
Find:
addEditNumber("runTime", 10)
newRow()
And insert below it
addCheckBox("delayTimer", delayTimerString, false)
addEditNumber("delayTime", 10)
newRow()
Step 3
Find:
if (timeLimit and timer:check() >= (runTime * 60)) then
scriptExit(string.format(timeReachString, runTime))
end
And insert below it
if (delayTimer and delayTime >= 1 and index == table.getn(touchList) + 1) then
wait(delayTime)
end
And simply stop the service, replace the script with the edited version and restart service and you should be good to go!
I'm fairly new to Lua, so do let me know if there are any bugs in this.
|
|
|
Post by newscripter on Jul 22, 2018 14:56:07 GMT
You can do that with this script. If you want the continuing click fast, you could modify the generated luar. Change the "click" to "while(existsClick("target.png",0)) begin end" hmm, this gave me an error: ------ 9 -----
touchList[index] = {target = "missionend1.png", region = Region(442, 1479, 200, 150), id = "missionend1", action = 'while(existsClick("missionend1.png",0)) begin end'}
index = index + 1 Have a few question also: 1.Does changing ,0 to 1 above changes the wait between trying to click the image again from 0 seconds to 1 second? 2. Is there a way to search a bigger region for an image(but not whole screen?) as for example image is always in bottom left. 3.Can I search in color for snap and play?
|
|
|
Post by AnkuLua on Jul 22, 2018 15:49:55 GMT
Sorry, it should be while(existsClick("target.png",0)) do end
1. No. The numbers 0 and 1 is the MAXIMUM search time. If the image is found on first screenshot, then the results are the same. 2. Yes. Just change the values in region = Region(...). 3. Image search is always in grey. Use getColor() to get the color of a location.
|
|
|
Post by newscripter on Jul 22, 2018 17:51:20 GMT
Sorry, it should be while(existsClick("target.png",0)) do end 1. No. The numbers 0 and 1 is the MAXIMUM search time. If the image is found on first screenshot, then the results are the same. 2. Yes. Just change the values in region = Region(...). 3. Image search is always in grey. Use getColor() to get the color of a location. Thanks for you help, managed to get them to work! ------ 1 ----- touchList[index] = {target = "quick_fight_1076_868_276_75.png", region = Region(1056, 848, 316, 115), id = "1", action = 'dofile(scriptPath() .. "luar/testx.luar")'} index = index + 1 For the dofile, is there any easy way to get the new lua to return the to originally launched one as it seems to stay on the new luar? or will I need to dofile to return. (trying to split error checks into a seperate file) line with dofile ------ 8 ----- touchList[index] = {target = "errormsg.png", region = Region(-3, 640, 1100, 600), id = "errormsg", action = 'dofile(scriptPath() .. "luar/errors.luar")'} index = index + 1 the errors file ----- created by AnkuLua snap and play script ------ immersive = true setImmersiveMode(immersive) scriptDimension = 1080 Settings:setScriptDimension(true, scriptDimension) Settings:setCompareDimension(true, scriptDimension) local index = 1 touchList = {} waitList = {}
------ 1 ----- touchList[index] = {target = "hostdc.png", region = Region(186, 798, 200, 150), id = "hostdc", action = 'click("errormsg.png")'} index = index + 1
------ 2 ----- touchList[index] = {target = "connectionerror.png", region = Region(461, 837, 200, 150), id = "connectionerror", action = 'click("errormsg.png")'} index = index + 1
after swapping to the errors.luar, it just loops within that luar
|
|
|
Post by AnkuLua on Jul 23, 2018 1:14:34 GMT
You can dofile the normal luar in errors.luar
|
|
|
Post by newscripter on Jul 23, 2018 8:34:37 GMT
You can dofile the normal luar in errors.luar thanks, that means i have to dofile back, and something like do return end will not work to go back to script that called new luar correct? is there any way to get the originally running scripts name? As otherwise for each script, would need a new errors.luar to call back the original script. example: script1 dofile to errors1 luar >dofile to script1 script2 dofile to errors2 luar >dofile to script2
|
|
|
Post by shalloban on Aug 2, 2018 6:18:58 GMT
is there a function to say if image is found at regionA, it will click regionB?
RegionB is just a specific area that i need to click without any fixed image.
|
|
|
Post by AnkuLua on Aug 2, 2018 6:47:35 GMT
is there a function to say if image is found at regionA, it will click regionB? RegionB is just a specific area that i need to click without any fixed image. In that case, you need to modify the generated luar. touchList[index] = {target = "1.png", region = Region(612, 493, 150, 150), id = "1", action = 'click(regionB)'}
|
|
|
Post by shalloban on Aug 2, 2018 7:36:42 GMT
Thank you, manage to do it (your reply on other thread)
For future reference for others,
Define "regionB" as location to click, manually add it to the top of the script when manually editing by: local regionB = Location( 971, 289, 261, 142 )
So to make the script complete this action of clicking regionB when image is detected", reference to the below: touchList[index] = {target = "1.png", region = Region(612, 493, 150, 150), id = "1", action = 'click(regionB)'}
|
|
|
Post by derricksrs on Aug 11, 2018 13:49:53 GMT
Hmm just suggestion to increase the longclick default limit not to only 2s. change it to as what user define is better that way.
|
|
|
Post by AnkuLua on Aug 11, 2018 15:33:16 GMT
Hmm just suggestion to increase the longclick default limit not to only 2s. change it to as what user define is better that way. You can longClick() as long as you want. longClick(Location(x, y)) wait(7) -- wait 7 seconds stopLongClick()
|
|
|
Post by derricksrs on Aug 13, 2018 2:43:59 GMT
Another question is could we randomize the timer example wait 2second + random milliseconds?
|
|