|
Post by pitchninja on Jun 5, 2022 16:18:18 GMT
Hello, I am trying to have Mmm look and see whether 5 different parts of the screen equal a certain color. If they all equal, the colors specified then it should go to another macro line. The only way I know of how to do this is by adding an AND action and so I came up with a very long row that looks like this:
47 | IF | PIXEL COLOR | Color [R=85, G=118, B=28]::At Location [X:980 Y:353] | IS THE SAME | GOTO MACRO LINE | 57 | AND | 1 | IF | PIXEL COLOR | Color [R=86, G=119, B=29]::At Location [X:980 Y:477] | IS THE SAME | GOTO MACRO LINE | 57 | AND | 1 | IF | PIXEL COLOR | Color [R=85, G=118, B=28]::At Location [X:980 Y:596] | IS THE SAME | GOTO MACRO LINE | 57 | AND | 1 | IF | PIXEL COLOR | Color [R=85, G=118, B=28]::At Location [X:978 Y:720] | IS THE SAME | GOTO MACRO LINE | 57 | AND | 1 | IF | PIXEL COLOR | Color [R=85, G=118, B=28]::At Location [X:979 Y:842] | IS THE SAME | GOTO MACRO LINE | 57
It's weird because it is working most of the time but sometimes it is not. It will actually jump to macro line 57 before all 5 conditions are met. I am not as familiar with conditions, but is there a better way to have done this? To make it so that the loop that this is in is looking to see these 5 different spots are matching the color specified before it jumps to the specified line?
|
|
|
Post by pitchninja on Jun 6, 2022 1:15:58 GMT
Okay I found the solution, though if someone has a better one I am open to it. I had to separate the code into 5 different lines and use Else in the code.
47 | IF | PIXEL COLOR | Color [R=85, G=118, B=28]::At Location [X:980 Y:353] | IS THE SAME | GOTO MACRO LINE | 48 | ELSE | 47 | RUN ACTION | GOTO MACRO LINE | 53 48 | IF | PIXEL COLOR | Color [R=86, G=119, B=29]::At Location [X:980 Y:477] | IS THE SAME | GOTO MACRO LINE | 49 | ELSE | 48 | RUN ACTION | GOTO MACRO LINE | 53 49 | IF | PIXEL COLOR | Color [R=85, G=118, B=28]::At Location [X:980 Y:596] | IS THE SAME | GOTO MACRO LINE | 50 | ELSE | 49 | RUN ACTION | GOTO MACRO LINE | 53 50 | IF | PIXEL COLOR | Color [R=85, G=118, B=28]::At Location [X:978 Y:720] | IS THE SAME | GOTO MACRO LINE | 51 | ELSE | 50 | RUN ACTION | GOTO MACRO LINE | 53 51 | IF | PIXEL COLOR | Color [R=85, G=118, B=28]::At Location [X:979 Y:842] | IS THE SAME | GOTO MACRO LINE | 61 | ELSE | 51 | RUN ACTION | GOTO MACRO LINE | 53
So this is really a chain or waterfall condition. it would look for a pixel color in one row, if it found it, it would move onto the next line which looked for a pixel color in that row. If it found it, it would then go to the next row to look for a pixel color for that row and so on. If at any point it did not match a pixel in a given row, it couldn't go further. So it could not progress to row 5 if Row 4 condition hadn't been fulfilled, could not progress to 4 if 3 hadnt been fulfilled etc. If the conditions weren't fulfilled it would basically start the loop over doing a sequence of actions that happened right before the pixel color check. But once it got to Row 51 which was the last row to fulfill the pixel condition, if it fulfilled it, it could then successfully jump to row 61 which is the beginning of a second sub Loop in that macro. It was definitely an interesting macro to come up with for sure oh, and at least there it does have 100% consistency. I could see before though the reason why mine worked some of the time in the initial code that I pasted was because it was only looking truly for the first pixel color match which was actually the top row(sometimes the top row pixel color could be fulfilled before the other rows were causing it to prematurely jump to the next loop)
|
|
|
Post by Steve on Jun 6, 2022 6:48:45 GMT
Hi pitchninjaYou could do this with some variables to make it run a little neater but what you have will do the trick and it's easy to read and follow. I like it. I would change one thing though, I'd remove the positive catch on focus on the negative. This removes any line processing that is not absolutely necessary. In my example I have changed 'IS THE SAME' to 'IS NOT THE SAME' and removed the else. If the line does match it will continue to the next line without any additional line processing. 47 | IF | PIXEL COLOR | Color [R=85, G=118, B=28]::At Location [X:980 Y:353] | IS NOT THE SAME | GOTO MACRO LINE | 53 48 | IF | PIXEL COLOR | Color [R=86, G=119, B=29]::At Location [X:980 Y:477] | IS NOT THE SAME | GOTO MACRO LINE | 53 49 | IF | PIXEL COLOR | Color [R=85, G=118, B=28]::At Location [X:980 Y:596] | IS NOT THE SAME | GOTO MACRO LINE | 53 50 | IF | PIXEL COLOR | Color [R=85, G=118, B=28]::At Location [X:978 Y:720] | IS NOT THE SAME | GOTO MACRO LINE | 53 51 | IF | PIXEL COLOR | Color [R=85, G=118, B=28]::At Location [X:979 Y:842] | IS NOT THE SAME | GOTO MACRO LINE | 53 52 | RUN ACTION | GOTO MACRO LINE | 61
|
|
|
Post by pitchninja on Jun 6, 2022 9:08:20 GMT
Ah good thinking. I like that better since it's more concise. I will adjust it to function like that
|
|
|
Post by zeak on Jun 7, 2022 7:00:17 GMT
Hi pitchninja,
I had a thought, not sure if it applies to your macro. If you had the colour on the screen ever appear in a different sequence then you were expecting then you run a tally check.
* | Color Check Loop 1 | RUN ACTION | DEFINE INTEGER VARIABLE | %COLOR1%::0 2 | RUN ACTION | DEFINE INTEGER VARIABLE | %COLOR2%::0 3 | RUN ACTION | DEFINE INTEGER VARIABLE | %COLOR3%::0 4 | RUN ACTION | DEFINE INTEGER VARIABLE | %COLOR4%::0 5 | RUN ACTION | DEFINE INTEGER VARIABLE | %COLOR5%::0 6 | IF | PIXEL COLOR | Color [R=255, G=255, B=255]::At Location [X:1212 Y:610] | IS THE SAME | DEFINE INTEGER VARIABLE | %COLOR1%::1 7 | IF | PIXEL COLOR | Color [R=85, G=118, B=28]::At Location [X:980 Y:353] | IS THE SAME | DEFINE INTEGER VARIABLE | %COLOR1%::1 8 | IF | PIXEL COLOR | Color [R=86, G=119, B=29]::At Location [X:980 Y:477] | IS THE SAME | DEFINE INTEGER VARIABLE | %COLOR2%::1 9 | IF | PIXEL COLOR | Color [R=85, G=118, B=28]::At Location [X:980 Y:596] | IS THE SAME | DEFINE INTEGER VARIABLE | %COLOR3%::1 10 | IF | PIXEL COLOR | Color [R=85, G=118, B=28]::At Location [X:978 Y:720] | IS THE SAME | DEFINE INTEGER VARIABLE | %COLOR4%::1 11 | IF | PIXEL COLOR | Color [R=85, G=118, B=28]::At Location [X:979 Y:842] | IS THE SAME | DEFINE INTEGER VARIABLE | %COLOR5%::1 13 | RUN ACTION | DEFINE INTEGER VARIABLE | %TALLYTOTAL%::%COLOR1%::+%COLOR2%::+%COLOR3%::+%COLOR4%::+%COLOR5% 13 | IF | INTEGER VARIABLE | %TALLYTOTAL% | IS NOT | 5 | GOTO MACRO LINE | Color Check Loop This would work by checking each location and adding a Boolean to sum up at the end. If the sum total matches what your expecting then continue, if not then go back to start and check again.
|
|
|
Post by cyberchipz on Jun 16, 2022 16:26:13 GMT
I think you could shorten that one a bit...
* | ColorCheckLoop
1 | RUN ACTION | DEFINE INTEGER VARIABLE | %COLOR1%::0 6 | IF | PIXEL COLOR | Color [R=85, G=118, B=28]::At Location [X:980 Y:353] | IS THE SAME | DEFINE INTEGER VARIABLE | %COUNTER%::1 7 | IF | PIXEL COLOR | Color [R=86, G=119, B=29]::At Location [X:980 Y:477] | IS THE SAME | DEFINE INTEGER VARIABLE | %COUNTER%::+1 8 | IF | PIXEL COLOR | Color [R=85, G=118, B=28]::At Location [X:980 Y:596] | IS THE SAME | DEFINE INTEGER VARIABLE | %COUNTER%::+1 9 | IF | PIXEL COLOR | Color [R=85, G=118, B=28]::At Location [X:978 Y:720] | IS THE SAME | DEFINE INTEGER VARIABLE | %COUNTER%::+1 10 | IF | PIXEL COLOR | Color [R=85, G=118, B=28]::At Location [X:979 Y:842] | IS THE SAME | DEFINE INTEGER VARIABLE | %COUNTER%::+1 13 | IF | INTEGER VARIABLE | %COUNTER% | IS | 5 | GOTO MACRO LINE | MatchHandler * | NoMatchHandler . . . * | MatchHandler . . * | Note - All done, do it again. 60 | RUN ACTION | GOTO MACRO LINE | ColorCheckLoop
If 5 colors don't match, drops out of check, otherwise goes to the line you want to handle if success. Same as zeak's, but how I would do it. Of course, Zeak's is better if you need debugging and want to know which line failed. ;-)
Chip
|
|