|
Post by learningtoscript on Nov 10, 2019 18:47:30 GMT
Hello everyone, I am trying to learn scripting and I have few questions:
1) How to make the script simultaneously look for two images and execute different lines of code in case one or other image has been found? 2) How to stop the execution of next lines of code if certain image has been found? 3) How to make the script look for image only in certain region of the screen? 4)I am using this code to make the script tap into random location within the image. How do i assign the custom similarity for it?
example= exists("example.png") if (example~= nil) then click(Location(example:getX() + math.random(0, example:getW()), example:getY() + math.random(0, example:getH()))) end Thanks
|
|
|
Post by Exilereven on Nov 10, 2019 22:23:06 GMT
example= exists("example.png")
Can be
exists('example'):similar(0.90) --or whatever percentage you pefer
|
|
|
Post by AnkuLua on Nov 11, 2019 3:16:16 GMT
exists(Pattern('example'):similar(0.90))
|
|
|
Post by learningtoscript on Nov 11, 2019 17:04:58 GMT
exists(Pattern('example'):similar(0.90)) So how should the final code look like? I get error for this.
example= exists("example.png", 200) exists(Pattern('example'):similar(0.40)) if (example~= nil) then click(Location(Region:getX() + math.random(0, Region:getW()), Region:getY() + math.random(0, Region:getH()))) end
|
|
|
Post by Exilereven on Nov 11, 2019 17:27:12 GMT
exists(Pattern('example'):similar(0.90)) So how should the final code look like? I get error for this.
example= exists("example.png", 200) exists(Pattern('example'):similar(0.40)) if (example~= nil) then click(Location(Region:getX() + math.random(0, Region:getW()), Region:getY() + math.random(0, Region:getH()))) end
exists(Pattern('example'):similar(0.40)) Needs to be exists(Pattern('example.png'):similar(0.40))
|
|
|
Post by learningtoscript on Nov 11, 2019 21:04:42 GMT
So how should the final code look like? I get error for this.
example= exists("example.png", 200) exists(Pattern('example'):similar(0.40)) if (example~= nil) then click(Location(Region:getX() + math.random(0, Region:getW()), Region:getY() + math.random(0, Region:getH()))) end
exists(Pattern('example'):similar(0.40)) Needs to be exists(Pattern('example.png'):similar(0.40)) Thank you, that worked! I am also trying to insert if-scenario within another if-scenario so essentially something like this
if (stageclear ~= nil) then ----- here first if-scenario starts wait(math.random(2, 3)) click(Location(SelectTeam:getX() + math.random(0, SelectTeam:getW()), SelectTeam:getY() + math.random(0, SelectTeam:getH()))) wait(math.random(1, 3)) click(Location(CharacterSel:getX() + math.random(0, CharacterSel:getW()), CharacterSel:getY() + math.random(0, CharacterSel:getH()))) wait(math.random(2, 5)) if (friendaccept ~= nil) then exists(Pattern('friend.png'):similar(0.40)) click(Location(friendaccept:getX() + math.random(0, friendaccept:getW()), friendaccept:getY() + math.random(0, friendaccept:getH()))) end click(Location(EndConfirm:getX() + math.random(0, EndConfirm:getW()), EndConfirm:getY() + math.random(0, EndConfirm:getH()))) wait(math.random(1, 3)) ---- here first if -scenario ends elseif (stagefail ~= nil) ---- second if-scenario, if stageclear condition is not satisfied this if-scenario begins
click(Location(Retry:getX() + math.random(0, Retry:getW()), Retry:getY() + math.random(0, Retry:getH()))) wait(math.random(1, 3)) click(Location(FirstHelper:getX() + math.random(0, FirstHelper:getW()), FirstHelper:getY() + math.random(0, FirstHelper:getH()))) wait(math.random(1, 3))
end
But I don't know the correct Syntax to achieve my goal.
Also, how do I waitClick or existClick within a random area in the picture?
|
|
|
Post by learningtoscript on Nov 13, 2019 0:55:35 GMT
Ok, So I figured out how nested ifs work, but it seems that I found a bug with wait command. Essentially it looks for an image only for 80 seconds after the activation of command, even though I have wait-period set to 250 seconds. Can I somehow send a video showcasing this bug?
|
|
|
Post by gslinux on Dec 16, 2019 0:32:39 GMT
Ok, So I figured out how nested ifs work, but it seems that I found a bug with wait command. Essentially it looks for an image only for 80 seconds after the activation of command, even though I have wait-period set to 250 seconds. Can I somehow send a video showcasing this bug? From the code you posted: exists(Pattern('friend.png'):similar(0.40)) you can make this part search for the image for, let's say, 250 seconds like so:
exists(Pattern('friend.png'):similar(0.40), 250)
I also suggest increasing similar a bit as it might pick up something completely unrelated.
|
|