It is good to see people who know that programming is an art form, and there are certain rules that should apply for asthetic reasons, and to save on processor time (thus slashing away at the lag monster).
Good code should be self-documenting, but comments are encouraged - at least a purpose statement, like with your graal name and an exploination of what the npc does, at the top of the code.
There are two ways to make comments, line at a time, and in a block.
NPC Code:
// NPC by Prozac
// This npc is uber 1337 and will ownz all of joo!
// this line is a comment and will not be read by the parser
///////// text lines like this help break up long scripts ///////
// for short query-action stuf like the code below
// I think its ok to put it on one line . less scrolling
// in the code window too.
if (playerenters) {message I Ownz joo!;}
a=0; //variable a is set to 0: after the two slashes is a comment until you press enter
The comments that go on for more than one line should be put in a comment block
NPC Code:
/* NPC by Prozac
This npc shows how I prefer to layout code after querying for a
comdition, then listing more than one command.
I like to have the curly brackets on their own line
at the start and end of the blocks, two spaces in if nested condition checks.
In long scripts or blocks of code, I place and indent my if
(condition) and brackets { and } beforehand, then fill in the
commands afterwards. This habit helps to make sure you don't
forget to close your brackets, that they end in the right place.
A good indentation rule is two spaces, thats what I usually end
up doing. But as in all art, try the general convention, then find what works for you.
And yes, all this is a comment. Here comes the comment end..
*/
//////// code begins here //////////
if (created)
{
setplayerprop #c,I am here!;
a=0;
if (weaponsenabled)
{
say2 Weapons are enabled;
}
}
Forgive spelling or grammar mistakes, as its early morning and am half awake .. and half asleep .. so my consiousness is twice as big as it needs to be?