Forward:Although having
record and play script for simple "click and wait" parts, there are some weaknesses for this script:
- It's not efficient because conservative and buffer of time
- For different (harder) level, the recorded script fails because not enough time buffer.
We already have the methodology for
brute force script development. Why can't we make it automation?
Yes, we can. Here is it --"snap And Play".
Note: This script needs version 7.5.0 or above.
If you never use AnkuLua before, please first refer to
the example.
Revision history:2.6.0:
* added "If A found, click B location"
* added "click target offset"
www.dropbox.com/s/vclpn7qkkt5vibf/snapAndPlay.v2.6.0.lua?dl=12.3.0:
* added supporting devices with cutout (notch)
www.dropbox.com/s/h9ommib1dfwdt80/snapAndPlay.v2.3.0.lua?dl=12.0.0:
* added Portuguese support
www.dropbox.com/s/jjqrz008hqxy879/snapAndPlay.v2.0.0.lua?dl=11.9.0:
* added "Always search from first image." option
* added "If A found, click B"
www.dropbox.com/s/jfocxip27thf1i9/snapAndPlay.v1.9.0.lua?dl=11.8.1:
* added playback minimum similarity settings
1.8.0:
* Support expanding existing luar
1.7.0:
* Support detecting duplication(same images will not be recorded again), reduce the luar size.
* Support smart order(If previous snaps found in background, new snap will arrange in front). Make the replay result as expected.
1.6.0:
* support modified action
1.5.0:
* added wait option. Enable this feature if the game pauses when the screen is light yellow.
1.3.2:
* supports random click
1.2:
* supports drag and drop
* adds option to append scripts
1.1:
* adds option to assign image file names
1.0: First release
The script is open source. Welcome to modify and distribute.
Record usage:1. Choose recordAndPlay.lua, then enter the the screen to record.
2. Press the lower left AnkuLua Play button, then choose record.
Choose the game is immersive or not.
Input the file name to save
When running, please only touch the screen when there is light yellow on screen. Or the touch will not be recorded.
When running, please only touch the screen when there is light yellow on screen. Or the touch will not be recorded.
When running, please only touch the screen when there is light yellow on screen. Or the touch will not be recorded.
Don't touch the screen like below.
Only touch screen when there is light yellow on screen.
3. To stop recording, press the red "Stop!" area or AnkuLua stop button.
Playback usage:1. Choose recordAndPlay.lua and enter the screen to playback.
2. Choose playback
3. Choose the file to playback
The first two settings are clear. Need no more explanation.
Some snaps don't always occur on a fixed area. In this case, cancel the click on "All searchings with regions".
Then following setting page will show. And you can choose which snap to search on fixed area and which to search on whole screen.
Hint: You can find the images in directory luar/fileNameImage under snapAndPlay script.
Demo video
Advanced skills:Simply generated script can't meet your requirements. You can modify the generated luar to do more.
Want to do more when some image found, rewrite the action.
The variable matchResult is the match result. Here are some example.
------ 1 -----
touchList[index] = {target = "1.png", region = Region(612, 493, 150, 150), id = "1", action = 'click("realTarget.png")'}
index = index + 1
------ 2 -----
touchList[index] = {target = "2.png", region = Region(774, 493, 150, 150), id = "2", action = 'click(matchResult); wait(2)'}
index = index + 1
------ 3 -----
touchList[index] = {target = "3.png", region = Region(174, 293, 150, 150), id = "3", action = 'dofile("3.lua")'}
index = index + 1