Condensing Script

Ask gaming related questions (AHK v1.1 and older)
Pharma
Posts: 26
Joined: 13 Dec 2016, 18:14

Condensing Script

01 Oct 2018, 10:09

Hey there!

I'm a noob looking to learn. I need to condense some code.
Basically, I'm looking to have AHK ImageSearch one area via multiple images.
This way, it can determine which image aligns with which slot.

This code works as is, but obviously this is inefficient.
How would I do this with an array?
Something like: PossibleRooms = (Crabs, Guardians, ...) until it sees the image, records that (Slot1 = __) , then moves on

Thanks so much!

Code: Select all

; Analyze Room 1 
Loop 
	{
		ImageSearch, , , Slot1_TopX, Slot1_TopY, Slot1_BotX, Slot1_BotY,*55 %A_ScriptDir%\Boss_Inv\Crabs.png
		if errorlevel = 0
			{
				Slot1 = Crabs
				Break
			}
		ImageSearch, , , Slot1_TopX, Slot1_TopY, Slot1_BotX, Slot1_BotY,*55 %A_ScriptDir%\Boss_Inv\Guardians.png
		if errorlevel = 0
			{
				Slot1 = Guardians
				Break
			}
		ImageSearch, , , Slot1_TopX, Slot1_TopY, Slot1_BotX, Slot1_BotY,*55 %A_ScriptDir%\Boss_Inv\IceDemon.png
		if errorlevel = 0
			{
				Slot1 = IceDemon
				Break
			}
		ImageSearch, , , Slot1_TopX, Slot1_TopY, Slot1_BotX, Slot1_BotY,*55 %A_ScriptDir%\Boss_Inv\Muttadiles.png
		if errorlevel = 0
			{
				Slot1 = Muttadiles
				Break
			}	
		ImageSearch, , , Slot1_TopX, Slot1_TopY, Slot1_BotX, Slot1_BotY,*55 %A_ScriptDir%\Boss_Inv\Mystics.png
		if errorlevel = 0
			{
				Slot1 = Mystics
				Break
			}
		ImageSearch, , , Slot1_TopX, Slot1_TopY, Slot1_BotX, Slot1_BotY,*55 %A_ScriptDir%\Boss_Inv\Shamans.png
		if errorlevel = 0
			{
				Slot1 = Shamans
				Break
			}
		ImageSearch, , , Slot1_TopX, Slot1_TopY, Slot1_BotX, Slot1_BotY,*55 %A_ScriptDir%\Boss_Inv\Tekton.png
		if errorlevel = 0
			{
				Slot1 = Tekton
				Break
			}
		ImageSearch, , , Slot1_TopX, Slot1_TopY, Slot1_BotX, Slot1_BotY,*55 %A_ScriptDir%\Boss_Inv\Thieving.png
		if errorlevel = 0
			{
				Slot1 = Thieving
				Break
			}
		ImageSearch, , , Slot1_TopX, Slot1_TopY, Slot1_BotX, Slot1_BotY,*55 %A_ScriptDir%\Boss_Inv\Tightrope.png
		if errorlevel = 0
			{
				Slot1 = Tightrope
				Break
			}	
		ImageSearch, , , Slot1_TopX, Slot1_TopY, Slot1_BotX, Slot1_BotY,*55 %A_ScriptDir%\Boss_Inv\Unknown.png
		if errorlevel = 0
			{
				Slot1 = Unknown
				Break
			}
		ImageSearch, , , Slot1_TopX, Slot1_TopY, Slot1_BotX, Slot1_BotY,*55 %A_ScriptDir%\Boss_Inv\Vanguards.png
		if errorlevel = 0
			{
				Slot1 = Vanguards
				Break
			}
		ImageSearch, , , Slot1_TopX, Slot1_TopY, Slot1_BotX, Slot1_BotY,*55 %A_ScriptDir%\Boss_Inv\Vasa.png
		if errorlevel = 0
			{
				Slot1 = Vasa
				Break
			}
		ImageSearch, , , Slot1_TopX, Slot1_TopY, Slot1_BotX, Slot1_BotY,*55 %A_ScriptDir%\Boss_Inv\Vespula.png
		if errorlevel = 0
			{
				Slot1 = Vespula
				Break
			}
	}

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: slowwd and 92 guests