Too many if statements?

06/08/2016 01:38 O-Drop#1
Hi there!

I'm working on a bot, suddenly my If code doesn't work. Is there a limit for if links?
I'm 100% sure the Pixelcolor fits since I checked with ControlViewer.
I was just adding more and more "or if and if" statements. I even tried to create a new if loop. What is the mistake?

Edit: Also I'm getting this in console:
>"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "@ScriptFullPath"
What does /ErrorStdOut mean?

On the bottom
Code:
06/08/2016 06:05 alpines#2
There is no specific amount of allowed if-statements within an AutoIt3 script so you can make how much you want.

As far as my PC is concerned your script seems to run just fine and the syntax check doesn't spit out something suspicious.

Why don't you go ahead and post the error you get?

/ErrStdOut just means to reflow the error output of the console to the normal output.
This is an option because the console usually has two outputs, normal and error and since some programs are reading only the normal console instead of the error one too /ErrStdOut redirects it so it gets displayed within the SciTE Console Monitor.

By the way, I'd heavily recommend you to rework your code especially the PixelGetColor lines because that is an inefficient way of programming. Why don't you make an array containing the coordinates and colors and iterating through it while checking every index to see if all the color matches? If one fails you can immediately break then.
06/08/2016 16:51 O-Drop#3
Quote:
As far as my PC is concerned your script seems to run just fine and the syntax check doesn't spit out something suspicious.

Why don't you go ahead and post the error you get?
Thats my Problem. I don't get any errors. The PixelGetColor lines suddenly stopped working as I was adding more. $status doesn't change to "karte1" but it should. The Coordinates fit and the color fits too.

Quote:
/ErrStdOut
Thank you for your explanation.

Quote:
By the way, I'd heavily recommend you to rework your code especially the PixelGetColor lines because that is an inefficient way of programming. Why don't you make an array containing the coordinates and colors and iterating through it while checking every index to see if all the color matches? If one fails you can immediately break then.
I Struggle understanding what you mean. I'm not very good in autoit I can't properly code what I think you mean. I needed Hours to make my Code from above. Something Like this?:

EDIT: Or more like this?
What lines beside the PixelGetColor ones are inefficient?
06/08/2016 19:58 alpines#4
The performance of your script won't vary much by stuffing the pixel information into arrays but it will make it a LOT easier and better to read. I'd suggest you to do something like this
Code:
Global $aPixel[2][3] = [[900, 800, 0xABABAB], [800, 700, 0xABACAD]]

;and then iterating through the array with this logic

For $i = 0 To UBound($aPixel) - 1
	;This may not serve your purpose since you're linking And and Ors in the long if-statement
	;so adjust this for your needs.
	If Not PixelGetColor($aPixel[$i][0], $aPixel[$i][1]) = $aPixel[$i][2] Then
		$status = ""
	Else
		$status = "karte1"
	EndIf
Next
Since you're saying that it suddenly stopped working I'd like to know what happened when it stopped working. If it's not spitting out any errors then the program must exit itself somehow.
06/08/2016 22:26 O-Drop#5
Thank you for that eye openener! For now I leave the code because I need to know which pixel fit for debugging. But I keep that in mind!

I work like this
I play the game
start the map
see if status changes - if repeat.
If not add 2 Pixelgetcolor to the code
Compile it and run it again without moving ingame.
Status changes now. - Repeat.

I'm not 100% sure but very sure I didn't change the code in another place than in the Pixelgetcolor if's. But the status doesn't change anymore. Even if I add new coordinates without moving.
I get no error but Pixelgetcolor doesn't work/ there seem to be an error. The script is running, I can reset $status through the GUIbutton and the tray icon exists.
It stoped working within one save. I think I just added 2 Pixelgetcolor. I could find any mistake, but tbh I might not see everything.

Is there any way to debug line by line?
06/08/2016 23:48 alpines#6
Quote:
Originally Posted by O-Drop View Post
Thank you for that eye openener! For now I leave the code because I need to know which pixel fit for debugging. But I keep that in mind!

I work like this
I play the game
start the map
see if status changes - if repeat.
If not add 2 Pixelgetcolor to the code
Compile it and run it again without moving ingame.
Status changes now. - Repeat.

I'm not 100% sure but very sure I didn't change the code in another place than in the Pixelgetcolor if's. But the status doesn't change anymore. Even if I add new coordinates without moving.
I get no error but Pixelgetcolor doesn't work/ there seem to be an error. The script is running, I can reset $status through the GUIbutton and the tray icon exists.
It stoped working within one save. I think I just added 2 Pixelgetcolor. I could find any mistake, but tbh I might not see everything.

Is there any way to debug line by line?
Natively in SciTE Code Walkthrough is not supported, you have to use an AutoIt3 IDE for that (there is one but it's kinda outdated).

I'd recommend you to put the colors in the array and then simply check if one color doesnt match, then you can easily tell at which index you are in the array and that maybe holds the wrong colorcode?
06/09/2016 00:41 O-Drop#7
I just deleted the whole Pixelgetcolor stuff and started over with 2 new coordinates. It worked! Even in my old script. I don't know why. Nvm I will rework this.
Ist there a better way than switch to prevent $i from getting beyond 0? I'm getting a badly formated code error then. Since I always want to check 2 Pixel I need to work with +/-1. But going unbound+1 doesn't work too.

My code so far:
06/09/2016 01:15 alpines#8
Why are you switching the $i, what are you trying to achieve with that?

The For-Loop is adjusted to iterate through every single element of the $aPixel array so you only have to do your check.
If $aPixel's dimension is [2][3] the For-Loop will go: 0, 1, stop.

Oh, you're trying to compare two pixels at once. Well you have many ways to choose from.
Either you simply change the [2][3] to [2][6] and put the other pixel data in the same index just behind the old one....
Or you adjust the For-Loop to something like this
Code:
Global $aPixel[2][3] = [[915, 160, 0xCA3E61], [983, 139, 0xFF595A]]
While 1
	For $i = 1 To UBound($aPixel) - 1 Step 2
		If PixelGetColor($aPixel[$i][0], $aPixel[$i][1]) = $aPixel[$i][2] And PixelGetColor ($aPixel[$i-1][0], $aPixel[$i-1][1]) = $aPixel[$i-1][2] Then
			$status = "Karte1"
		Else
			$status = ""
		EndIf

		Sleep (500)
	Next
WEnd
This will make it go in two steps for each incrementation instead of 1 and will end on the last index by starting at the second. So it will go like this: $aPixel dimension: [10][3] - 1, 3, 5, 7, 9, stop.