Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > AutoIt
You last visited: Today at 04:05

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Too many if statements?

Discussion on Too many if statements? within the AutoIt forum part of the Coders Den category.

Reply
 
Old   #1
 
O-Drop's Avatar
 
elite*gold: 10
Join Date: Oct 2011
Posts: 71
Received Thanks: 9
Question Too many if statements?

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:
O-Drop is offline  
Old 06/08/2016, 06:05   #2
 
alpines's Avatar
 
elite*gold: 60
Join Date: Aug 2009
Posts: 2,256
Received Thanks: 815
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.
alpines is offline  
Old 06/08/2016, 16:51   #3
 
O-Drop's Avatar
 
elite*gold: 10
Join Date: Oct 2011
Posts: 71
Received Thanks: 9
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?
O-Drop is offline  
Old 06/08/2016, 19:58   #4
 
alpines's Avatar
 
elite*gold: 60
Join Date: Aug 2009
Posts: 2,256
Received Thanks: 815
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.
alpines is offline  
Thanks
1 User
Old 06/08/2016, 22:26   #5
 
O-Drop's Avatar
 
elite*gold: 10
Join Date: Oct 2011
Posts: 71
Received Thanks: 9
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?
O-Drop is offline  
Old 06/08/2016, 23:48   #6
 
alpines's Avatar
 
elite*gold: 60
Join Date: Aug 2009
Posts: 2,256
Received Thanks: 815
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?
alpines is offline  
Old 06/09/2016, 00:41   #7
 
O-Drop's Avatar
 
elite*gold: 10
Join Date: Oct 2011
Posts: 71
Received Thanks: 9
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:
O-Drop is offline  
Old 06/09/2016, 01:15   #8
 
alpines's Avatar
 
elite*gold: 60
Join Date: Aug 2009
Posts: 2,256
Received Thanks: 815
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.
alpines is offline  
Thanks
1 User
Reply


Similar Threads Similar Threads
Learn SQL statements...where?
08/14/2014 - General Coding - 9 Replies
Hello, i had some basic SQL this year at school, but i feel like i didnt really learn that much, just basic stuff... like SELECT, UPDATE, DELETE, etc.. Does anyone know a site or something where i could learn to use more advanced SQL senteces?
[RELEASE] Usefull SQL statements - for GM's
02/07/2011 - Shaiya PServer Development - 16 Replies
This one lists all items that can drop from any particular monster. The one I post here will return MobName, ItemName, Grade, DropChance. You can add more if you want to. To make it work type the monster name between the percent signs (red colour). It doesn't have to be the full name. Partial names will work too, i.e. '%Ruined Wolf%', '%Cryptic%': DECLARE @MobName varchar(60); SET @MobName = '%%'; SELECT M.MobName, I.ItemName, MI.Grade, MI.DropRate
hackers out there! u can post ur statements here ^^
05/13/2009 - Grand Chase - 32 Replies
juz read the rules over and over again (5x actually) im hopin that this thread will somehow enlightened those MISUSERS on how to use their hacks or someone else's properly. and i guess that this post will not break any of this forum's rules so.. here we go! Why or what is/are the reason/s why you are using hacks in the game? ;) ME= use this hacks coz i want to catch up to my friends playin for a whole weekend w/c are lvl 50+. ( i do have a job ) i guess this hacks really makes me...



All times are GMT +1. The time now is 04:07.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.