Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Formatting (https://forums.graalonline.com/forums/showthread.php?t=37287)

Python523 09-04-2002 04:41 AM

Formatting
 
What do you people see as the correct way to format a script?
I personally see it this way:

1 line:
if(playerenters) setcharprop #c,hi;

>1 lines:
NPC Code:

if(created||timeout){
i++;
setcharprop #c,#v(i);
timeout = .05;
}


What about you people? Maybe using correct formatting shouldn't be a rule but maybe encouraged to be used more often? I personally find it annoying to see scripts that aren't formatted that way =/

emortylone 09-04-2002 04:44 AM

Ah, I think you're wrong, but i don't care. Correct is in the eye of the beholder x.X Here is what I do, and I find it QUITE easy to read and simple enough:
NPC Code:

if (created)
{ action 1;}

if (created)
{ action 1;
action 2;
action 3;
}


I think that it looks a bit more confusing when you have the opening { on the same line as the if statement. If you have a long if statement it gets harder to read =/
---Shifter

Falcor 09-04-2002 04:58 AM

They teach you to seperate cold blocks from the conditional statements... Personally I find that quite confusing to do
NPC Code:

if(pie)
{
blah;
bahhiho;
}


I do
NPC Code:

if(only_one_command) do something like this;

and

if(more_than_one_command) {
do;
stuff;
like;
this;
}


Torankusu 09-04-2002 05:01 AM

NPC Code:

if (something){
this;
because;
i_find;
it;
neater/easier to read;
}


Dach 09-04-2002 05:29 AM

I prefer the "graal style" like what falcor, python, and torankusu did, but it doesn't make much difference as long as it is indented properly so I can read it.

Torankusu 09-04-2002 05:43 AM

Quote:

Originally posted by Dach
I prefer the "graal style" like what falcor, python, and torankusu did, but it doesn't make much difference as long as it is indented properly so I can read it.
i did indent, but I didn't use [code] so it didn't show.

Dach 09-04-2002 06:10 AM

Quote:

Originally posted by Torankusu
i did indent, but I didn't use [code] so it didn't show.
I wasn't refering to you personally.

Torankusu 09-04-2002 07:20 AM

Quote:

Originally posted by Dach


I wasn't refering to you personally.

I figured I'd fix it anyway.

nyghtGT 09-04-2002 07:26 AM

Re: Formatting
 
Quote:

Originally posted by Python523

NPC Code:

if(created||timeout){
i++;
setcharprop #c,#v(i);
timeout = .05;
}



that way

screen_name 09-05-2002 08:39 AM

I personally use this style:

NPC Code:

if (blabla) {
commandhere;
}



Even if it is only one command, I use { }'s.

bigkow44 09-05-2002 08:48 AM

NPC Code:
if (1action) {command;} 
else
if (>1action) {
Command1;
Pie;
}


emortylone 09-06-2002 04:06 AM

LOL, I seem to be the only one who doesn't put the { on the statement =/ Oh well, mine is still easy to read due to I indent. Regardless if there is only one command, I almost ALWAYS try and put in { and } so that in case I need to edit it l8er I won't have to add them.
---Shifter


All times are GMT +2. The time now is 07:49 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.