Script cleanup -
Kwarde - 15.12.2010
Hey! I've noticed that some people have difficulty with fixing errors and warnings.
Mostly, it are "Loose indentation" warnings. And sometimes errors. Well, I'll try to explain in this tutorial how to fix them!
And I'll also give some tips, for the scripters. Let's start.
Warning Loose Indentation.
This code means, more or less, that your code is MESSY. Sorry to say it like that, but it's the hard truth.
And the funny thing is, it is easy to remove the warnings! All lines within a bracket 'group' need to be on the same line.
Here's an example:
BAD EXAMPLE:
pawn Код:
stock BadFunction()
{
if(true)
{
a = 1;
true = false;
b = 2;
c = 3;
}
}
GOOD EXAMPLE:
pawn Код:
stock BetterFunction()
{
if(true)
{
a = 1;
true = false;
b = 2;
c = 3;
}
}
You can see it. The 'a = 1' to 'c = 3' is now on one line. That's much more clearer! And warnings will be gone now.
And in the "BetterFunction" I've added tabs after the opening brackets. This will also probaly remove the loose indentation warnings.
There are multilple reason's why good scripters are using this.
1) It's much more clearer
2) It's easier to find and fix an error/warning
3) It's much easier to find something you wanna find
I know that this costs more diskspace. But I want that more, then having an messy code!
Fixing errors
There are alot of errors. I won't say how to fix them all. I'll just give an tip. This is an example error line:
Код:
C:\SampServer\GM.pwn(202) : error 055: start of function body without function header
You see, after the 'GM.pwn' this: (202). This is the line where the error is. It is handy to go to it with
CTRL+G.
With that, you can simply go to a line of the script. So if you typ '202' in it and then press ENTER, you'll go to the line with the error!
I'll give an example again.
pawn Код:
stock ThisFunction(true = false) //line 1
{ //line 2
if(true) //line 3
{ //line 4
true = playerid; //line 5
} //line 6
} //line 7
I'll get an error on line 5! It will say that 'playerid' is unknown. There is no where an 'playerid' defined, so it's impossible to use it in that function!
Well. I got the error. Now I press CTRL+G. I typ in that, '5' and I press ENTER. I'll go to this line:
true = playerid;.
The error also said that 'playerid' was unknown. I have to change that! Let's change it to 'true'. Now, compile it again.
NO ERRORS ANYMORE IN THAT FUNCTION!
- Fixed.
What did you learn?
* How to make your script clean
* How to remove loose indentation warnings
* How to fix/find errors
Please confirm that you have learned that! If you didn't learn it yet, read this tutorial once again! And whatever, here is a rule:
* An warning is different then an error! If you have an warning, your script will PROBABLY still work. Don't be scared if you have a warning. It's not funny, but it's not critical too!
I HOPE that this tutorial was a bit usefull.
And I hope that you've learned something with this. Good luck with scripting
- Kevin
Re: Script cleanup -
Ricardo187 - 15.12.2010
ONLY GREAT! I Fixed the last errors
Re: Script cleanup -
Kwarde - 15.12.2010
Yeah my tutorial worked
Do you know that I made it especially for you? :O - But other people can use it.
Whatever well done. Good luck. I'm tired. I'll catch ya later.
PS REQUEST:
If you're totally English, please say if my English is good or not. And also give me tips for better gramatica etc, if needed. How better my English is, how much clearer my tutorials will be,
- Kevin
AW: Script cleanup -
Meta - 15.12.2010
BETTER EXAMPLE:
#pragma tabsize 0
No Changes needed ^^
Re: AW: Script cleanup -
Retardedwolf - 15.12.2010
Quote:
Originally Posted by Meta
BETTER EXAMPLE:
|
#pragma semicolon 0
Re: Script cleanup -
Leon_Rahil! - 16.12.2010
This'll really help people who always get these warning, like me. Thanks + Great job.
Re: AW: Script cleanup -
Kwarde - 16.12.2010
Quote:
Originally Posted by Retardedwolf
#pragma semicolon 0
|
Quote:
Originally Posted by Meta
BETTER EXAMPLE:
#pragma tabsize 0
No Changes needed ^^
|
Thanks but ehm... what does that two do. 'tab'size. Does it fixs the tab? And semicolon does the ';' does fix the forgotten semicolon's?
In that case THANKS :P - But ehm. It won't fix loose indentation does it? And I have to say, I personally like it more to fix it myself, do get more experience etc. If you use the #pragma stuff, you won't learn much of it, do you?
Whatever thanks, again
- Kevin
Re: Script cleanup -
Ricardo187 - 16.12.2010
Quote:
Originally Posted by Kwarde
Yeah my tutorial worked
Do you know that I made it especially for you?
- Kevin
|
Yes, i Know and i only can say: Thanks you VERY MUTCH!
Re: AW: Script cleanup -
sciman001 - 03.04.2011
Quote:
Originally Posted by Meta
BETTER EXAMPLE:
#pragma tabsize 0
No Changes needed ^^
|
thats foor noobs.
Re: AW: Script cleanup -
alpha500delta - 03.04.2011
Quote:
Originally Posted by sciman001
thats foor noobs.
|
Yes, but it's bad.
Btw. Are you bumping every topic or something?