I manage to fix it I believe. It will just skip the base if gold is not found. I will make it more efficient later, but this should also work:
Code:
Func CheckSearch()
Sleep(2000)
Local $countY = 0
Local $countExit = 0
$GoldCheck = getGold($x_default, $y_default + $countY)
While $GoldCheck = ""
If $countY >= 5 Then $countY = 0
$countY += 1
$countExit += 1
$GoldCheck = getGold($x_default, $y_default + $countY)
Sleep(200)
If $countExit >= 50 Then
ControlClick ($HWnD, "","", "left", "1", 715*$x_ratio, 405*$y_ratio) ;Click Next
$countExit = 0
EndIf
If $RunState = False Then
ExitLoop
EndIf
WEnd
;GUICtrlSetData($Results, "Finish check" & @CRLF, -1)
EndFunc