|
Post by illunic on Oct 12, 2020 0:03:42 GMT
Excellent, thank you for the help!
|
|
|
Post by illunic on Oct 16, 2020 21:12:56 GMT
Okay I'm back again. So in my script I've got 2 'random' selections using
t = findAll("target.png") click(t[math.random(#t)]) or something similar to it. What I've noticed is when I run multiple instances of the script they all start the same. Is there a way to prevent this from happening? I am running the script in LDPlayer which supports a 'shared' folder between the PC and the emulator, is the fact that im running all instances of the script from that folder causing the issue? If I force it to pick its choices again itll pick something else but Im just wondering if there is a way to make it not follow the same 'random' path on start
|
|
|
Post by Mercobots on Oct 16, 2020 21:48:38 GMT
|
|
|
Post by illunic on Oct 16, 2020 22:11:52 GMT
Thanks ill try it right away!
|
|
|
Post by illunic on Oct 19, 2020 19:41:24 GMT
Okay so I've been us Mercobots' snapYourScript to get my images and regions and it has been immensely helpful in getting me off the ground (Thank you Merco!). Lately my script has gotten to a point where I am starting to get held up on false positives / missing checks if I put the similarity higher. I've decided to try to utilize the transparency features in the .png format and after some forum searching it seems AnKuLua supports this aswell, I am at work so I don't have access to my script but I have a few questions about how it works / what I need to do.
1) If I save the stripped image in color will it work? I could have sworn i read somewhere that AnKuLua will automatically convert it but I could be wrong. I have no trouble converting it to greyscale.
2) I was reading some of the Sikuli documentation that came up when searching about this, it says that images with transparency will be masked automatically, I am just double checking if this is carried over to AnKuLua and working properly. I did read where it is recommended to use Pattern().mask() instead of relying on transparency. If this is no longer the case just ignore question 3 and 4
3) If using Pattern().mask() is still the preferred method and mask() uses black is there a way to set a mask globally so it treats all black in any image called as a mask? So I don't have to apply it individually with Pattern().mask(), maybe something like Settings.setMask().
4) If I have to do it individually is it setting the Pattern to a variable better or should i just do it each time i call that an image, ex:
tgt = Pattern("target.png"):similar(0.85):mask() existsClick(tgt) or
existsClick(Pattern("target.png"):similar(0.85):mask()) For images used multiple times I would say that the top method is the obvious choice, but for images that are only called once in the script would it be easier to use the bottom method instead of making a variable just for that one call.
|
|
|
Post by AnkuLua on Oct 19, 2020 23:20:04 GMT
Okay so I've been us Mercobots' snapYourScript to get my images and regions and it has been immensely helpful in getting me off the ground (Thank you Merco!). Lately my script has gotten to a point where I am starting to get held up on false positives / missing checks if I put the similarity higher. I've decided to try to utilize the transparency features in the .png format and after some forum searching it seems AnKuLua supports this aswell, I am at work so I don't have access to my script but I have a few questions about how it works / what I need to do. 1) If I save the stripped image in color will it work? I could have sworn i read somewhere that AnKuLua will automatically convert it but I could be wrong. I have no trouble converting it to greyscale. 2) I was reading some of the Sikuli documentation that came up when searching about this, it says that images with transparency will be masked automatically, I am just double checking if this is carried over to AnKuLua and working properly. I did read where it is recommended to use Pattern().mask() instead of relying on transparency. If this is no longer the case just ignore question 3 and 4 3) If using Pattern().mask() is still the preferred method and mask() uses black is there a way to set a mask globally so it treats all black in any image called as a mask? So I don't have to apply it individually with Pattern().mask(), maybe something like Settings.setMask(). 4) If I have to do it individually is it setting the Pattern to a variable better or should i just do it each time i call that an image, ex: tgt = Pattern("target.png"):similar(0.85):mask() existsClick(tgt) or existsClick(Pattern("target.png"):similar(0.85):mask()) For images used multiple times I would say that the top method is the obvious choice, but for images that are only called once in the script would it be easier to use the bottom method instead of making a variable just for that one call. 1) Yes. AnkuLua will convert color images to greyscale ones automatically. 2) No. You always needs to assign mask() even if the image is with transparency. 3) You need to set mask() for each image. 4) Both works. And the comments are correct.
|
|
|
Post by illunic on Oct 20, 2020 2:00:05 GMT
Awesome thanks, so a bit of a follow up to the mask() stuff. Since I am using mask, do i need to turn the transparent part of my pngs black or will AnKuLua just treat it as black? So Ive been looking at OCRnum and wondering if im doing this right ocr = 0 dialogInit() addTextView("Input number:") addEditNumber(num, 0) dialogShowFullScreen("Test")
whole ocr != num do ocr = numberOCR(numregion, "number") Would that work as waiting for a number to appear in the region that matches the number input by the user?
|
|
|
Post by AnkuLua on Oct 20, 2020 3:12:24 GMT
Awesome thanks, so a bit of a follow up to the mask() stuff. Since I am using mask, do i need to turn the transparent part of my pngs black or will AnKuLua just treat it as black? So Ive been looking at OCRnum and wondering if im doing this right ocr = 0 dialogInit() addTextView("Input number:") addEditNumber(num, 0) dialogShowFullScreen("Test")
whole ocr != num do ocr = numberOCR(numregion, "number") Would that work as waiting for a number to appear in the region that matches the number input by the user? AnkuLua use the transparent part. Yes. It would wait for the number to appear.
|
|
|
Post by illunic on Oct 20, 2020 18:22:47 GMT
Thanks for the info, last question for now. For the numberOCR(numreg, "number") how do I get it to mask() the png's its accessing? I can think of these two ways but Im unsure if it works like that or if I am missing something.
numberOCR(numreg, Pattern("number"):mask()) or
numberOCR(numreg, "number"):mask() Not 100% if it works like that but if I am doing it wrong any help would be appreciated.
|
|
|
Post by AnkuLua on Oct 21, 2020 6:40:04 GMT
Thanks for the info, last question for now. For the numberOCR(numreg, "number") how do I get it to mask() the png's its accessing? I can think of these two ways but Im unsure if it works like that or if I am missing something. numberOCR(numreg, Pattern("number"):mask()) or numberOCR(numreg, "number"):mask() Not 100% if it works like that but if I am doing it wrong any help would be appreciated. Number OCR doesn't support mask.
|
|
|
Post by illunic on Oct 22, 2020 3:06:34 GMT
Okay I'm back with more numberOCR questions. So what I am trying to do is getting a number from the user and then waiting until the number is found by numberOCR.
ocr = 0 blahblah addEditNumber(num, 1)
while ocr < num do ocr = numberOCR(numregion, "numpngs") end Trying this gets me an error about comparing a boolean with a number. Any ideas what I could be doing. Should I be comparing it a different way? Like:
while not (num == numberOCR(numregion, "numpngs")) do
|
|
|
Post by Mercobots on Oct 22, 2020 9:39:30 GMT
Okay I'm back with more numberOCR questions. So what I am trying to do is getting a number from the user and then waiting until the number is found by numberOCR.
ocr = 0 blahblah addEditNumber(num, 1)
while ocr < num do ocr = numberOCR(numregion, "numpngs") end Trying this gets me an error about comparing a boolean with a number. Any ideas what I could be doing. Should I be comparing it a different way? Like:
while not (num == numberOCR(numregion, "numpngs")) do
Hi!!! First you should use local numberOCRNoFindException Exception not throwing exception, this method do the same thing as numberOCR. This method returns two values. The first one is still the recognized number. The second one is the boolean value of success (true). knowing that , now is easy to use blahblah addEditNumber(num, 1) local ocr = -1 while ocr < num do ocr, status = numberOCRNoFindException(numregion, 'numpngs') if not status then -- OCR fail -- do something to improve OCR end end
in case OCR fails ocr result will be -9999 so if you prefer you can do this too but i don't recommend while true do ocr = numberOCRNoFindException(numregion, 'numpngs')
if ocr > num then break elseif ocr < 0 then -- OCR fail -- do something to improve OCR end end
good luck
|
|
|
Post by illunic on Oct 22, 2020 11:30:44 GMT
Awesome thank you, I had mistakenly thought the noFindException was for preventing the bot from throwing an error.
|
|
|
Post by illunic on Oct 24, 2020 20:32:54 GMT
Hello, first off thank you for all the help AnkuLua and Mercobots. Ive gone from not even being able to get the thing to run more than 10 seconds without an error to now being able to run 4 instances for over 12 hours and still have everything working.
Now for the questions, I have been thinking of trying to streamline the bot a bit, I was reading up on the thread about calling a function from another file and I think I have grasped the idea of it (Im sure you'll hear from me if I haven't) I am curious as to what can be called to from another file. Could I for example have a file that contained all of the regions the bot uses and have them it load from that file as opposed to having them all in the main script? I know that might sound a little pointless but the main file has gotten to a size that I am having trouble remembering what is in what contained in what and am thinking about how to reduce the size of the thing and I think storing the majority of my loops as functions in another file will really help with progressing on in the future.
Is there some documentation on how to do this kind of stuff? Ive got no experience with function() or how variables work when calling a function from a different file.
|
|