[Sikuli-driver] [Question #684034]: Needs to pick someones brain
New question #684034 on Sikuli: https://answers.launchpad.net/sikuli/+question/684034 Started a new gaming project and I'm faced with a small problem which I can't think of a clever function. The issue is the health bar of characters, they're always green in color (i know sikuli probably doesn't see colors). When the character looses health the green color depletes from the health bar Now these health bars can change positions as the character moves up or down, this is no problem because I can use region. How can I make sure sikuli clicks the bar with the lowest amount of Health or the colour green? The health bars can also change in shape for eg: The one at the very top can look the the 3rd one... Really stumped :S This is what the health bars look like: https://i.imgur.com/jhOB1IG.png Any suggestion is greatly appreciated! -- You received this question notification because your team Sikuli Drivers is an answer contact for Sikuli. ___ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp
Re: [Sikuli-driver] [Question #684034]: Needs to pick someones brain
Question #684034 on Sikuli changed: https://answers.launchpad.net/sikuli/+question/684034 Status: Open => Answered RaiMan proposed the following answer: You might use the Location.getColor() feature. a sample with the most left bar in your image: switchApp("opera") img = Pattern("img.png").targetOffset(-24,1) patR = Pattern("img.png").targetOffset(21,1) offsetR = patR.getTargetOffset() hover(img) start = Mouse.at() end = start.offset(offsetR.x * 2, 0) for n in range(offsetR.x * 2 + 10): print start.offset(n,0).getColor().getGreen() To get specific points in an image (as here the left side middle and the right side middle of the bar) you can use the image Preview feature in the IDE. There are about 40 pixels to check. If you use the check-the-middle algorithm, you would have your result latest with 6 checks in a loop: - test the middle of the bar - if it is black, test the middle of the left half of the bar - if it is not black, test the middle of the right half of the bar - ... hope you got it ;-) -- You received this question notification because your team Sikuli Drivers is an answer contact for Sikuli. ___ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp
Re: [Sikuli-driver] [Question #684034]: Needs to pick someones brain
Question #684034 on Sikuli changed: https://answers.launchpad.net/sikuli/+question/684034 xyz_User posted a new comment: Not on a PC atm going to check as soon as I get home, thanks RaiMan. As always, very prompt in your response! -- You received this question notification because your team Sikuli Drivers is an answer contact for Sikuli. ___ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp
Re: [Sikuli-driver] [Question #684034]: Needs to pick someones brain
Question #684034 on Sikuli changed: https://answers.launchpad.net/sikuli/+question/684034 Status: Answered => Open xyz_User is still having a problem: Just got a chance to try this, I think i'm missing the point and require some more explanation. If you have the time, can you show me the function for this scenerio: Let's say I'm the healer character in the game, and I need to scan who has the lowest amount of health comparing all of those 4 health bars and then click it. -- You received this question notification because your team Sikuli Drivers is an answer contact for Sikuli. ___ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp
Re: [Sikuli-driver] [Question #684034]: Needs to pick someones brain
Question #684034 on Sikuli changed: https://answers.launchpad.net/sikuli/+question/684034 xyz_User gave more information on the question: The last sentence I should have said comparing who has the least of "GREEN" health bar -- You received this question notification because your team Sikuli Drivers is an answer contact for Sikuli. ___ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp
Re: [Sikuli-driver] [Question #684034]: Needs to pick someones brain
Question #684034 on Sikuli changed: https://answers.launchpad.net/sikuli/+question/684034 Status: Open => Answered RaiMan proposed the following answer: ok, but might take till somewhen tomorrow. -- You received this question notification because your team Sikuli Drivers is an answer contact for Sikuli. ___ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp
Re: [Sikuli-driver] [Question #684034]: Needs to pick someones brain
Question #684034 on Sikuli changed: https://answers.launchpad.net/sikuli/+question/684034 xyz_User posted a new comment: thanks very much! This will be amazing -- You received this question notification because your team Sikuli Drivers is an answer contact for Sikuli. ___ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp
Re: [Sikuli-driver] [Question #684034]: Needs to pick someones brain
Question #684034 on Sikuli changed: https://answers.launchpad.net/sikuli/+question/684034 RaiMan proposed the following answer: ok, this is all I can do for you - other priorities. Based on the given image shown in browser Opera The offsets have been manually evaluated in IDE Preview. Not all bar images in your shot show the left end, so I decided to evaluate right to left. def init(): switchApp("opera") pat1R = Pattern("img.png").targetOffset(20,1) pat1L = Pattern("img.png").targetOffset(-23,1) offsetR = pat1R.getTargetOffset() offsetL = pat1L.getTargetOffset() length = offsetR.x - offsetL.x hover(pat1R) start1 = Mouse.at() pat2 = Pattern("img.png").targetOffset(47,-41) start2 = start1.offset(pat2.getTargetOffset()).offset(-offsetR.x -1, 0) pat3 = Pattern("img.png").targetOffset(82,11) start3 = start1.offset(pat3.getTargetOffset()).offset(-offsetR.x -1, 0) pat4 = Pattern("img.png").targetOffset(94,-19) start4 = start1.offset(pat4.getTargetOffset()).offset(-offsetR.x -1, 0) return (length, start1, start2, start3, start4) def evalHealth(start): for n in range(length + 1): color = start.offset(-n,0).getColor().getGreen() if color > 50: break return 100 - int(n * 100.0/length) length, start1, start2, start3, start4 = init() print evalHealth(start1) hover(start2) print evalHealth(start2) hover(start3) print evalHealth(start3) hover(start4) print evalHealth(start4) -- You received this question notification because your team Sikuli Drivers is an answer contact for Sikuli. ___ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp
Re: [Sikuli-driver] [Question #684034]: Needs to pick someones brain
Question #684034 on Sikuli changed: https://answers.launchpad.net/sikuli/+question/684034 Status: Answered => Solved xyz_User confirmed that the question is solved: THANK YOU!! This did it!! -- You received this question notification because your team Sikuli Drivers is an answer contact for Sikuli. ___ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp