# better way to do this instead of multiple nested if then loops

## Recommended Posts

```If \$result = 1 Then
;still looting
Sleep(1000)
If \$result = 1 Then
;still looting
Sleep(1000)
If \$result = 1 Then
;still looting
Sleep(1000)
If \$result = 1 Then
;still looting
Sleep(1000)
If \$result = 1 Then
;still looting
Sleep(1000)
If \$result = 1 Then
;still looting
Sleep(1000)
If \$result = 1 Then
;still looting
Sleep(1000)
If \$result = 1 Then
;still looting
Sleep(1000)
If \$result = 1 Then
;still looting
Sleep(1000)
If \$result = 1 Then
;still looting
Sleep(1000)
If \$result = 1 Then
;still looting
Sleep(1000)
If \$result = 1 Then
;still looting
Sleep(1000)
If \$result = 1 Then
;still looting
Sleep(1000)
If \$result = 1 Then
;still looting
Sleep(1000)
If \$result = 1 Then
;still looting
Sleep(1000)
Else
Call("Logic")
EndIf
Else
Call("Logic")
EndIf
Else
Call("Logic")
EndIf
Else
Call("Logic")
EndIf
Else
Call("Logic")
EndIf
Else
Call("Logic")
EndIf
Else
Call("Logic")
EndIf
Else
Call("Logic")
EndIf
Else
Call("Logic")
EndIf
Else
Call("Logic")
EndIf
Else
Call("Logic")
EndIf
Else
Call("Logic")
EndIf
Else
Call("Logic")
EndIf
Else
Call("Logic")
EndIf
Else
Call("Logic")
EndIf```

##### Share on other sites

Can you explain how does the \$result variable's value is changed? Right now if it's 1 it'll sleep 15 seconds, otherwise Logic function will be invoked once. If you want it to be this way but in any arbitrary depth you can use recursion with a counter, or a loop inside a loop.

##### Share on other sites

I'm assuming what you're doing here is testing whether you're still looting, waiting one second, testing again, and so on, until you're not looting anymore.

```Do
Sleep(1000)
\$result = Logic()
Until \$result <> 1```

That's the Do, Until version. You could also use While, Wend, and even a For, Next loop.

##### Share on other sites

well you are right jRowe I dropped idea of it comparing result now it compares the position of the loot

```\$position = MouseMove(\$a1, \$b1, 0)
If @error Then
\$bootyfound = \$bootyfound - 1
Call("Logic")
Else
Sleep(1000)
EndIf```

## Create an account

Register a new account