adamrl018 Posted June 23, 2009 Report Share Posted June 23, 2009 Hey guys, Im having some trouble setting up a macro for the game i play. Basically im tring to get a "Shadow Creeper" to run continually until a pixel changes "Health Bar" And when that pixel changes then run "Heal". I got both of the macros running good but i cant seem to get the "shadow creeper" to run "heal" if the pixel changes. Anyway.. here's what i got. Thanks in advance for you help Script 1 "Shadow Creeper" Get Pixel: Screen Coords: 324,197 into %N1%Repeat Until %N1% <> %N1% Get Pixel: Screen Coords: 324,197 into %N1% If Variable %N1% <> variable %N2% Break End If Repeat End Delay 10 Milliseconds Macro Playback Speed: Normal Speed Mouse Move Screen 835, 426 Mouse Left Button Down Mouse Left Button Up Delay 2 Seconds Mouse Move Screen 658, 742 Mouse Left Button Down Mouse Left Button Up Delay 2 Seconds Mouse Move Screen 824, 745 Mouse Left Button Down Mouse Left Button Up Mouse Move Screen 775, 746 Mouse Left Button Down Mouse Left Button Up Delay 10 Seconds Mouse Move Screen 775, 746 Mouse Left Button Down Mouse Left Button Up Delay 10 Seconds Mouse Move Screen 775, 746 Mouse Left Button Down Mouse Left Button Up Delay 10 Seconds Mouse Move Screen 775, 746 Mouse Left Button Down Mouse Left Button Up Delay 10 Seconds Mouse Move Screen 1087, 749 Mouse Left Button Down Mouse Left Button Up Delay 15 Seconds Macro Run: Heal Script 2 "Heal" Macro Playback Speed: Normal SpeedDelay 60 Milliseconds Mouse Move Screen 857, 688 Mouse Left Button Down Mouse Left Button Up Delay 5 Seconds Mouse Move Screen 917, 259 Mouse Left Button Down Mouse Left Button Up Delay 5 Seconds Mouse Move Screen 1080, 751 Mouse Left Button Down Mouse Left Button Up Delay 25 Seconds Macro Run: Shadow Creeper Quote Link to comment Share on other sites More sharing options...
paul Posted June 23, 2009 Report Share Posted June 23, 2009 Line 4 of Script1 refers to variable N2. Where is this set? Quote Link to comment Share on other sites More sharing options...
stevecasper Posted June 23, 2009 Report Share Posted June 23, 2009 Why the 2nd macro isn't running: My first guess is that you're trying to run a macro that doesn't exist. The name of the macro you said you're trying to run is Run away and heal Your posted code is: Macro Run: Heal You'll need to change the Macro Run command to Macro Run: Run away and heal Maybe I've misunderstood something, or maybe you have them named correctly in your actual macros, but what you've given us in this thread makes it look like this is the problem. __________________ Once you get the second script to run, you may want to move the 5 second delays up one line each. That way you'll have: Mouse button down Delay 5 seconds Mouse button up This is, of course, assuming that the "mouse button down" command is what is causing you to run away. I don't know the game you're trying to automate, or its dynamics, so it is possible that clicking in one spot will cause your character to run to that spot, in which case your code is fine (though a "Mouse Left Click" command would be simpler in that case). But if the dynamic is that your character will only run as long as the button is held down (a very good reason to use the Mouse button down / Mouse button up combination), then you'll want to make the change shown above. Quote Link to comment Share on other sites More sharing options...
adamrl018 Posted June 23, 2009 Author Report Share Posted June 23, 2009 Ok fixed the names. Hopefully that will make it more clearer Quote Link to comment Share on other sites More sharing options...
rberq Posted June 23, 2009 Report Share Posted June 23, 2009 Get Pixel: Screen Coords: 324,197 into %N1% Repeat Until %N1% <> %N1% Get Pixel: Screen Coords: 324,197 into %N1% If Variable %N1% <> variable %N2% Break End If Repeat End As Paul pointed out, variable N2 is not being set anywhere. I think you want your second Get Pixel command to get into N2, not N1. Quote Link to comment Share on other sites More sharing options...
adamrl018 Posted June 24, 2009 Author Report Share Posted June 24, 2009 Ok i think i fixed it... Does the "End if, End Repeat" need to be at the end of the actions? Or do i even have this right? when i start it it does nothing.. Macro Playback Speed: Normal SpeedGet Pixel: Screen Coords: 324,197 into %N1% Repeat Until %N1% <> %N1% Get Pixel: Screen Coords: 324,197 into %N1% If Variable %N1% <> variable %N1% Break Mouse Move Screen 835, 426 Mouse Left Button Down Mouse Left Button Up Delay 2 Seconds Mouse Move Screen 658, 742 Mouse Left Button Down Mouse Left Button Up Delay 2 Seconds Mouse Move Screen 824, 745 Mouse Left Button Down Mouse Left Button Up Mouse Move Screen 658, 742 Mouse Left Button Down Mouse Left Button Up Mouse Move Screen 775, 746 Mouse Left Button Down Mouse Left Button Up Delay 10 Seconds Mouse Move Screen 775, 746 Mouse Left Button Down Mouse Left Button Up Delay 10 Seconds Mouse Move Screen 658, 742 Mouse Left Button Down Mouse Left Button Up Mouse Move Screen 775, 746 Mouse Left Button Down Mouse Left Button Up Delay 10 Seconds Mouse Move Screen 658, 742 Mouse Left Button Down Mouse Left Button Up Mouse Move Screen 775, 746 Mouse Left Button Down Mouse Left Button Up Delay 10 Seconds Mouse Move Screen 1087, 749 Mouse Left Button Down Mouse Left Button Up Delay 15 Seconds End If Repeat End Macro Run: Heal Quote Link to comment Share on other sites More sharing options...
paul Posted June 24, 2009 Report Share Posted June 24, 2009 1 Macro Playback Speed: Normal Speed2 Get Pixel: Screen Coords: 324,197 into %N1% 3 Repeat Until %N1% <> %N1% 4 Get Pixel: Screen Coords: 324,197 into %N1% 5 If Variable %N1% <> variable %N1% 6 Break 1) Every If needs an End If command as soon as you have completed processing the If statements 2) Same with Repeat 3) Line 4 should place its results into N2 4) Line 5 will never ever be true 5) Line 5 should compare N1 with N2 6) Line 5 needs an End If, probably after line 6 7) Your Repeat End should probably be after the End If which you inserted after Line 6 I think you have quite a lot of studying of programming, logic and Macro Express to do. I personally would rewrite the above lines as follows: 1 Get Pixel: Screen Coords: 324,197 into %N1% 2 Copy N1 to N2 3 Repeat Until %N1% <> %N2% 4 Get Pixel: Screen Coords: 324,197 into %N2% 5 Repeat End The danger with this code is that if, for some reason, the pixel colour never changes, your Repeat loop will never end. I would therefore insert a counter, which, when exceeded, causes the macro to return. Quote Link to comment Share on other sites More sharing options...
adamrl018 Posted June 24, 2009 Author Report Share Posted June 24, 2009 Ok i changed the script like you said. but when i start it it still will not move. And remember im tring to get the macro to run another macro if that pixel changes Macro Playback Speed: Normal SpeedGet Pixel: Screen Coords: 324,170 into %N1% Variable Modify Integer: Copy %N1% to %N2% Repeat Until %N1% <> %N1% Get Pixel: Screen Coords: 324,170 into %N2% Repeat End Mouse Move Screen 637, 516 Mouse Left Button Down Mouse Left Button Up Delay 2 Seconds Mouse Move Screen 658, 742 Mouse Left Button Down Mouse Left Button Up Delay 2 Seconds Mouse Move Screen 824, 745 Mouse Left Button Down Mouse Left Button Up Mouse Move Screen 658, 742 Mouse Left Button Down Mouse Left Button Up Mouse Move Screen 775, 746 Mouse Left Button Down Mouse Left Button Up Delay 10 Seconds Mouse Move Screen 775, 746 Mouse Left Button Down Mouse Left Button Up Delay 10 Seconds Mouse Move Screen 658, 742 Mouse Left Button Down Mouse Left Button Up Mouse Move Screen 775, 746 Mouse Left Button Down Mouse Left Button Up Delay 10 Seconds Mouse Move Screen 658, 742 Mouse Left Button Down Mouse Left Button Up Mouse Move Screen 775, 746 Mouse Left Button Down Mouse Left Button Up Delay 10 Seconds Mouse Move Screen 1087, 749 Mouse Left Button Down Mouse Left Button Up Delay 15 Seconds Macro Run: Heal Quote Link to comment Share on other sites More sharing options...
adamrl018 Posted June 24, 2009 Author Report Share Posted June 24, 2009 ok i kinda experimented with the first one i had and fixed the things you said. I got the macro to run but then N1 <> N2 it does not run "Heal" Im tring to get it to run "Heal" right when that variable changes Macro Playback Speed: Normal SpeedGet Pixel: Screen Coords: 324,170 into %N1% Get Pixel: Screen Coords: 324,170 into %N2% Repeat Until %N1% <> %N2% If Variable %N1% <> variable %N2% Macro Run: Heal End If Mouse Move Screen 637, 516 Mouse Left Button Down Mouse Left Button Up Delay 2 Seconds Mouse Move Screen 658, 742 Mouse Left Button Down Mouse Left Button Up Delay 2 Seconds Mouse Move Screen 824, 745 Mouse Left Button Down Mouse Left Button Up Mouse Move Screen 658, 742 Mouse Left Button Down Mouse Left Button Up Mouse Move Screen 775, 746 Mouse Left Button Down Mouse Left Button Up Delay 9 Seconds Mouse Move Screen 775, 746 Mouse Left Button Down Mouse Left Button Up Delay 10 Seconds Mouse Move Screen 658, 742 Mouse Left Button Down Mouse Left Button Up Mouse Move Screen 775, 746 Mouse Left Button Down Mouse Left Button Up Delay 10 Seconds Mouse Move Screen 658, 742 Mouse Left Button Down Mouse Left Button Up Mouse Move Screen 775, 746 Mouse Left Button Down Mouse Left Button Up Delay 10 Seconds Mouse Move Screen 1087, 749 Mouse Left Button Down Mouse Left Button Up Delay 15 Seconds Repeat End Quote Link to comment Share on other sites More sharing options...
randallf Posted June 25, 2009 Report Share Posted June 25, 2009 The problem is that you are using a conditional statement at the front of the loop and then a bunch of commands. Think like the program here, you need to nest things correctly. There is a logical order to it all and whatever you want to repeat needs to be nested, from what I can tell you want something to fire when n1 and n2 are no longer the same color, and have it run this check constantly. Repeat until is a nested statement just like If/End If, a simple repeat loop is like this: Repeat _UNTIL_ n1 > n2 Variable set integer n2 = 10 Variable modify integer n1 = n1 + 1 Repeat _END_ Text type: repeat ended Now, this loop will just continue to run forever until it satisfies the initial repeat requirement, i.e. N1 is 11 and it will return to the next part of the macro, the text type command, so, if you want something to repeat UNTIL something changes, and then stop, and then do something, but keep doing all of that forever, you will have to nest repeats... your sequential ordering needs to be more like this: >REPEAT UNTIL N99 <> N99 (repeat everything nested in here FOREVER as N99 won't ever not equal itself, or add your own other condition to stop it) >>Repeat Until %N1% <> %N2% >>>Get Pixel: Screen Coords: 324,170 into %N1% >>>Get Pixel: Screen Coords: 324,170 into %N2% >>Repeat End >MACRO RUN: HEAL >REPEAT END And so we have two nested repeat statements, one that runs the inner repeat forever, and the inner one which runs our other macro. I have never tried to run macros from other macros before, but failing that it doesn't work right in nested repeats, you can just put your other code in instead of macro run: heal... Hope this helps Rand Edit: something topologically more like this is probably faster (twice, in fact) but I'm not sure how necessary that is.... >REPEAT UNTIL N99 <> N99 (repeat everything nested in here FOREVER as N99 won't ever not equal itself, or add your own other condition to stop it) >Get Pixel: Screen Coords: 324,170 into %N2% >>Repeat Until %N1% <> %N2% >>>Get Pixel: Screen Coords: 324,170 into %N1% >>Repeat End >MACRO RUN: HEAL >REPEAT END Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.