An issue with two loops and a long Sleep Topic is solved

Ask gaming related questions (AHK v1.1 and older)
Nolan431
Posts: 2
Joined: 29 Jul 2021, 23:05

An issue with two loops and a long Sleep

Post by Nolan431 » 30 Jul 2021, 00:18

Hello there, I recently tried to add another loop with a long Sleep to my script and discovered that it breaks my first loop, is there any workaround?

Code: Select all

	random, delayHP, 120, 140
	random, delayHP2, 120, 140
	
Insert::
{
	PixelGetColor, ColorHP, 113, 702
	PixelGetColor, ColorHP2, 90, 670
	
	SetTimer, LoopHP, %delayHP%
	SetTimer, LoopHP2, %delayHP2%
}
return

LoopHP:
{
	PixelGetColor, color1, 113, 702
	if (color1 = ColorHP)
{
	sleep, 60
}
	else
{
	send, {1}
	sleep, 60
}
}
return

LoopHP2:
{
	PixelGetColor, color2, 90, 670
	if (color2 = ColorHP2)
{
	sleep, 60
}
	else
{
	send, {2}
	sleep, 4750	; <== LoopHP stops triggering during this sleep in LoopHP2
}
}
return
Rohwedder
Posts: 7630
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: An issue with two loops and a long Sleep  Topic is solved

Post by Rohwedder » 30 Jul 2021, 02:00

Hallo,
I don't think that sleep broke your first loop, but what's the point of sleeping at all?
Try:

Code: Select all

random, delayHP, 120, 140
random, delayHP2, 120, 140
Insert::
PixelGetColor, ColorHP, 113, 702
PixelGetColor, ColorHP2, 90, 670
SetTimer, LoopHP, %delayHP%
SetTimer, LoopHP2, %delayHP2%
return
LoopHP:
PixelGetColor, color1, 113, 702
if (color1 <> ColorHP)
	send, {1}
return
LoopHP2:
PixelGetColor, color2, 90, 670
if (color2 = ColorHP2)
	SetTimer,, %delayHP2%
Else
{
	send, {2}
	SetTimer,, 4750
}
return
Nolan431
Posts: 2
Joined: 29 Jul 2021, 23:05

Re: An issue with two loops and a long Sleep

Post by Nolan431 » 30 Jul 2021, 02:41

Will try later today, thank you for answering
Post Reply

Return to “Gaming Help (v1)”