A plead for sanity...

Status
Not open for further replies.

Duwenbasden

Ver 6 CREATE energy AS SELECT * FROM u.energy
Reaction score
165
Lately I've seen scripts that is not only confusing, but also impossible to understand. Please, whenever you are asking for help, or helping others in GUI script or JASS...

>>> Use comments <<<

No, I am not asking you to explain to me what each line means, you just need to explain what each segment of code do. Even a general idea of the function is a good start. The helper or the person asking should not be guessing what your code is trying to do.

Example of good comments:
JASS:
local integer x = 0 // for loop integer counter
loop   // this loop creates 5 units, move them to a random location in LOCATION, and give them ability XYZ.
    exitwhen x &gt; 5
    call CreateUnitAtLoc (...)
    call MoveUnit (...)
    call AddAbility (...)
    set x = x + 1
endloop // x = 6 here


Example of bad comments:
JASS:
local integer x = 0 // for loop integer counter
loop
    exitwhen x &gt; 5  // exit the loop when x &gt; 5
    call CreateUnitAtLoc (...) // create a unit at location
    call MoveUnit (...) // move the unit to random point in LOCATION
    call AddAbility (...) // add ability XYZ to unit
    set x = x + 1 // increment x
endloop


This case, the first example is much easier to understand than the second one, which is basically repeating what the code "said".

Also, I've seen increasing use of variable names like "u" and "s". These variables are totally meaningless, and also makes the code very hard to understand (The exact reason I am so against the use of GetTriggerUnit() without accompanying comment.) Please, try to use variable names that is relevant to the thing it is trying to do, like "caster" for the caster, "victim" or "target" for the target unit. Remember, you are here to help, or to be helped.

Thanks.
 

Duwenbasden

Ver 6 CREATE energy AS SELECT * FROM u.energy
Reaction score
165
The problem is people are posting codes without comments and using ugly variables. They tend to make code deceiphering very difficult.
 

waaaks!

Zinctified
Reaction score
255
yeah some people...but others do JESP, to make people understand on what they made
 

Pineapple

Just Smile.
Reaction score
576
>> Lets make Duwenbasden charity fund to help him out.

Please give generously, for every $1 we can get one more noob off the course of bad variables and comments.:D
 

waaaks!

Zinctified
Reaction score
255
>> Lets make Duwenbasden charity fund to help him out.

Please give generously, for every $1 we can get one more noob off the course of bad variables and comments.:D

lol...we are about a thousand or more, meaning $1 each = $rich$ :D
just kiddin
 

Duwenbasden

Ver 6 CREATE energy AS SELECT * FROM u.energy
Reaction score
165
>> Lets make Duwenbasden charity fund to help him out.

Please give generously, for every $1 we can get one more noob off the course of bad variables and comments.:D

not only noobs, even some mods are also in the habit.
 

elmstfreddie

The Finglonger
Reaction score
203
You delete my reply or something?

But I'm purely serious, once you know the intention of the trigger you should be able to know what does what, unless it's poorly scripted or something, but it should still be readable by you...

Either that or I'm some kinda genius :rolleyes:

Besides, shouldn't this be in the JASS zone, since GUIers shouldn't use comments?

(PS the only time I use comments is to remind my self to put a line of script where the comment is)
 

Duwenbasden

Ver 6 CREATE energy AS SELECT * FROM u.energy
Reaction score
165
It is a difference between 5 seconds to read the general idea and understand immediately and 45 seconds to try to understand the code line by line and guess the intention. Sure I can do it, but even 1 line of description makes a lot of difference.

No I didn't delete your reply.

once you know the intention of the trigger

That's the point, post the intentions and comment on some weird/complex parts. I've seen some questions started without anything aside from 10-20 lines of code and then "why doesn't it work??!?!?!"
 

elmstfreddie

The Finglonger
Reaction score
203
No I didn't delete your reply.
Okay, weird, 3 times now something didn't post :confused:
Anyways, sorry if I sounded angry.
I seriously don't think comments are necessary >_<
It's about as anal as "planning your map on paper"

Right, 40 seconds, vital.
Don't say well the amount of script you read * 40 really adds up...
Because we are all wasting all that time on this website :p
 

Duwenbasden

Ver 6 CREATE energy AS SELECT * FROM u.energy
Reaction score
165

elmstfreddie

The Finglonger
Reaction score
203
Seems completely useless, you never set l you just take it then return it... Then you remove locations that were never set?
Then you create a peasant???

As I said though, it's required you know what it's supposed to do in the first place :p
 

Duwenbasden

Ver 6 CREATE energy AS SELECT * FROM u.energy
Reaction score
165
That's the point I've been trying to put across. Some people post codes and nothing else and expect us to help them. The confusing variables only adds to the fire.

thing creates peasants in compass directions (NESW), if the integer i is not 0, create 4 more peasant in compass directions WITH that new location with half the distance of the original compass.

So:
Code:
			1

		1	2	1
	
	7		1		3
	
7	8	7	H	3	4	3

	7		5		3

		5	6	5

			5

H = Host's, caster's, spawner's location
Peasant in "1" is created first, then 2, and so on.

P.S.: Assuming the location is passed to thing, and r (radius) and i (iteration) is given by user.
 

elmstfreddie

The Finglonger
Reaction score
203
Wait you changed it then when I last looked at it... Lemme read it again -.-

Okay, pretty much the same gayness.
What is thing btw >_>
Some function that that "annoying person" did not post?

I took this as a complaint about comments, not lack of data ;)
 

Duwenbasden

Ver 6 CREATE energy AS SELECT * FROM u.energy
Reaction score
165
lack of data is pretty much the same as the lack of comments. The only thing comments do is clarify things and help people understand. The descriptions I gave you are comments. Without comments, most people will have no idea what the function does.
 

elmstfreddie

The Finglonger
Reaction score
203
All you needed to do was post thing and I coulda understood ;)

STOP EDITING YOUR POSTS AFTER I REPLY! LOL!

Anyways, you just contradicted yourself... You said comments are a lack of data, then you said they only clarify things???

ANYWAYS WHO GIVES A CRAP >_<
Rants are for hormonal people :cool:
 
Status
Not open for further replies.
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top