Nice first attempt, it's just sometimes knowledge is power and the more you know about certain functions, the better. And that knowledge will be brought now~ (Ah, a little note: you can use the [.code][/code] feature (without the period) to wrap your code around.)
Concerning time, there's a command called Macro.Start stopwatch() that essentially lets you create a timer.
Then we'll 'Read the stopwatch' and compare it to an if statement to see if the time exceeds 15 seconds (This function uses the unit 'ms' miliseconds, so 1 second = 1000 ms). The important part is that we need the timer to stop and reset itself so that way it'll only count for those 15 seconds the moment it finds another enemy to target on.
Here's a small example:
Code:
Macro.Start stopwatch("Switch Enemies")
begin loop()
Macro.Read stopwatch("Switch Enemies", "time")
if Variable.Is greater than (Math)("time", "14999")
begin
Macro.Reset stopwatch("Switch Enemies")
Macro.Stop stopwatch("Switch Enemies")
Macro.Break from loop("no")
end
end
The Macro.Break from loop "no" signifies to break the loop immediately. If you want this to loop infinity until you want it to stop, there's a tickmark you can check called 'Infinite' under loops. You can click on that and your entire macro will loop regardless. Make sure under 'Trigger' that you actually set up a hotkey to stop your macro (I recommend Ctrl+A).
I'll go under the assumption that 'tab' is to switch enemies, and to make this macro efficient, you already got one pixel detection that essentially activates the whole macro, so we'll leave the beginning part alone, and get rid of the second pixel detection. Here's a revised code I came up with on the fly, let me know what you think and report back. You may edit this particular line if you choose to edit the amount of seconds:
Code:
if Variable.Is greater than (Math)("Switch Enemies", "14999") //Edit the "14999" of your liking, keep in mind that 1 second = 1000 ms.
Modified code for you (with a bit of Gigus on the side):
Code:
begin
if Color.At coordinate is within (RGB range)("113", "129", "44", "0", "529", "663")
begin
Keyboard.Press key("{<tab>}")
Macro.Pause("300")
Macro.Start stopwatch("Switch Enemies")
begin loop()
Keyboard.Press key("{<f1>}")
Macro.Pause("320")
Macro.Read stopwatch("Switch Enemies", "time")
if Variable.Is greater than (Math)("time", "14999")
begin
Macro.Reset stopwatch("Switch Enemies")
Macro.Stop stopwatch("Switch Enemies")
Macro.Break from loop("no")
end
end
end
end
Edit: Reflects on Gigus's post. I must of been on a sugar rush typing this out~
_________________
Code:
> Meanwhile at Blue Eye Macro...
> BEM Video Games Department - Moderator, Coder, Debugger, Math/Physics & Algorithm Enthusiast - USA
Current Project: Mod Duty