Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   KSI-GS (Coding Standards) (https://forums.graalonline.com/forums/showthread.php?t=46557)

Tseng 08-16-2003 08:42 AM

Quote:

Originally posted by wonderboysp2p
i agree with tseng... ive uploaded old levels and found "toweapons" in there... had a good time getting disconnected about 7 times before i realized it was there too
I'm talking about serverside toweapons (overwrites weapons in NC), not clientside toweapons (disconnects because clientside/offline style toweapons is the kind of thing trainers inject to try to add a weapon).

wonderboysp2p 08-17-2003 05:26 AM

ooooooooooooooooooooooooooooooooooooooooooh
that's another problem heh

prozac424242 08-17-2003 03:58 PM

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?

wonderboysp2p 08-18-2003 05:46 AM

heh my dad's always telling meh to use comments while programming... it's fun because you can pretend that whateber you put is a sublimnal message repeated OVER AND OVER while the script is functioning but yea...

comments are very underused in gscript (as far as ive seen)... i think it would be ince to see a script once in a while that ya know says

if (actionjewer){
message #p(1) Is A Jew!; //#p(1) is the player's account name
}

or something like that, so we have like a little helper when we're debugging other people's scripts... or scripts we made when we were "in a state where we wouldnt remember" heh...

most scripters can easily identify (looking at the triggeraction) that #p(1) would be the players account name but it saves time and is much easier to just look to the right and say "oh!"

or say, the script keeps coming up with something like
"12 is a jew!" people can say "hmm..."
"oh ok well that's the problem! #p(1) is scripted to be the players damage! they have 'account name' listed as #p(2) in the triggeraction! Silly NATs..."

it can cause more confusion if someone types the wrong thing as a comment then what the script is actually intended to do but everything's got drawbacks right?

duzzel 08-22-2003 02:32 PM

another word for scripting hmm...geek
anyways I wish there were a good tuturial that teaches people to script easier... i just don't get it

wonderboysp2p 08-23-2003 07:48 AM

Quote:

Originally posted by duzzel
another word for scripting hmm...geek

Hey look! now im not gonna help you learn how to scirpt.. in fact, go to hell

-Ramirez- 08-23-2003 08:53 AM

Quote:

Originally posted by Neoreno
Mleh. Classic is supposed to be getting a conversion. So all the more insentive to hurry it up.
...a conversion that has taken a total duration of almost a year now. It's pathetic.

Kaimetsu 08-23-2003 09:00 AM

Quote:

Originally posted by -Ramirez-
...a conversion that has taken a total duration of almost a year now. It's pathetic.
The speed is pathetic, you mean? Not really. There's a lot of work, and they seem to be trying to do it properly (unlike most online playerworlds ¬_¬).

-Ramirez- 08-23-2003 06:05 PM

Quote:

Originally posted by Kaimetsu


The speed is pathetic, you mean? Not really. There's a lot of work, and they seem to be trying to do it properly (unlike most online playerworlds ¬_¬).

Yes, it has taken far too much time. And yes, there is a lot of work, but if there were more people actually working, it would have been done by now. Com and Jeff were the only two doing anything for a while. Then Com hired some new people back in February. Of those people hired, I think I was the only scripter. So far, I've been the only one who has actually stayed with it and done the work. Even I haven't done much, as I've been doing quite a bit for the clientside only Classic server as well. Soul appears to have taken over the administrating of the LAT now. He just got through a hiring, and we'll be reviewing applications soon. Hopefully this will give us some new scripters that will actually HELP. Oh well... only time will tell. (...yet more time...)

Maybe I shouldn't have posted this here, as it doesn't really belong with the topic. :(

Ziro_Vitrudestec 08-28-2003 04:32 AM

Quote:

Originally posted by Kaimetsu

Because making a tutorial wouldn't benefit me in any way whatsoever?

Selling it should.

Kaimetsu 08-28-2003 04:34 AM

Quote:

Originally posted by Ziro_Vitrudestec


Selling it should.

Not realistic.

Tseng 08-28-2003 04:41 AM

Quote:

Originally posted by -Ramirez-

Yes, it has taken far too much time. And yes, there is a lot of work, but if there were more people actually working, it would have been done by now. Com and Jeff were the only two doing anything for a while. Then Com hired some new people back in February. Of those people hired, I think I was the only scripter. So far, I've been the only one who has actually stayed with it and done the work. Even I haven't done much, as I've been doing quite a bit for the clientside only Classic server as well. Soul appears to have taken over the administrating of the LAT now. He just got through a hiring, and we'll be reviewing applications soon. Hopefully this will give us some new scripters that will actually HELP. Oh well... only time will tell. (...yet more time...)

Maybe I shouldn't have posted this here, as it doesn't really belong with the topic. :(

I already indicated my willingness to help, but it'd be convenient if I had some applicable rights on Classic Dev to fascilitate this (e.g. rw to the weapons for which I am to convert, so I can add them myself for easier transferrence, and verification that they work properly. With NC Rights, I do not think this should be an issue).

(Also, why in the world would you attempt/hope to gain scripters from Levels Team? That seems rather foolish, if you ask me.)

Python523 08-28-2003 05:28 AM

Quote:

Originally posted by Tseng

(Also, why in the world would you attempt/hope to gain scripters from Levels Team? That seems rather foolish, if you ask me.)

Once upon a time there was no such thing as NATs or GATs, it was all one general category, LATs, and classic has continued this tradition

Tseng 08-28-2003 05:29 AM

Quote:

Originally posted by Python523


Once upon a time there was no such thing as NATs or GATs, it was all one general category, LATs, and classic has continued this tradition

Tradition is no excuse for foolishness.

A

Levels
Administration
Team

is just that.

Python523 08-28-2003 05:33 AM

Quote:

Originally posted by Tseng


Tradition is no excuse for foolishness.

A

Levels
Administration
Team

is just that.

On non-npcserver servers you had to insert NPCs into levels by editing them, there was no such thing as NC with a weapons database where you can directly insert weapons or an NPC list where you directly insert NPCs into them without editing, the name does make some sense if you look at it that way

Tseng 08-28-2003 05:42 AM

Quote:

Originally posted by Python523


On non-npcserver servers you had to insert NPCs into levels by editing them, there was no such thing as NC with a weapons database where you can directly insert weapons or an NPC list where you directly insert NPCs into them without editing, the name does make some sense if you look at it that way

That may explain "scripts", but it does not explain graphics. And, the question is still begged about why levels people would be doing major scripting.

Aside from all of that, my question related to why a levels administration team was dealing with scripting for an NPC-Server. :)

-Ramirez- 08-28-2003 08:59 PM

Quote:

Originally posted by Tseng
I already indicated my willingness to help, but it'd be convenient if I had some applicable rights on Classic Dev to fascilitate this (e.g. rw to the weapons for which I am to convert, so I can add them myself for easier transferrence, and verification that they work properly. With NC Rights, I do not think this should be an issue).
Well, Soul can't even give people rights on Dev, as he doesn't even have the rights himself. Tyhm has yet to give them. (He says he can't, but Stefan checked his rights and told me he could...) When Soul has the rights, I'll let you know when you can come and help.

Btw, don't you have 2001 to work on? When are you going to find the time for Classic?

Tseng 08-29-2003 04:33 AM

Quote:

Originally posted by -Ramirez-

Well, Soul can't even give people rights on Dev, as he doesn't even have the rights himself. Tyhm has yet to give them. (He says he can't, but Stefan checked his rights and told me he could...) When Soul has the rights, I'll let you know when you can come and help.

Btw, don't you have 2001 to work on? When are you going to find the time for Classic?

I've got an internet-less 3 hour break twice a week in which I am very bored, and several smaller ones also internet-less. I can convert a few scripts at a time.

I also have bored nights+weekends, and a willingness to help out where I can.

And to answer the inevitable question - correct, I do have no life.

-Ramirez- 08-29-2003 07:31 PM

Quote:

Originally posted by Tseng
And to answer the inevitable question - correct, I do have no life.
That's ok, I don't have one either. ;)

And as I said, I'll see about getting you rights whenever I can. I'll forum PM you or something when you have them.

GoZelda 09-14-2003 01:43 PM

Quote:

Originally posted by voicedcow6666
my turn for input. :)

For for statements, the initial varible you should use is i. If you must nest them, start with i, followed by j, then k, and so on.

NPC Code:

for (i=0;i<5;i++) {
}

for (i=0;i<5;i++) {
for (j=0;j<3;j++) {
for (k=0;i<1;k++) {
}
}
}


Wrong. You can use any letter, as long it isn't used (x,y,z).
I,j,k,l etc. is for compability with Java and C++, just like == is.
Also, this. variables can be used to.

Kaimetsu 09-14-2003 04:01 PM

Quote:

Originally posted by GoZelda

Wrong. You can use any letter, as long it isn't used (x,y,z).
I,j,k,l etc. is for compability with Java and C++, just like == is.

Wrong. Those variable names are used simply for the sake of uniformity. Compatibility isn't even a factor.

Tseng 09-14-2003 04:11 PM

Quote:

Originally posted by GoZelda

I,j,k,l etc. is for compability with Java and C++, just like == is.

AHAHAHAHAHAHAHA

GoZelda 09-14-2003 04:34 PM

Quote:

Originally posted by Kaimetsu


Wrong. Those variable names are used simply for the sake of uniformity. Compatibility isn't even a factor.

o.O crappy Java tutorial. Crappy NPCprogramming.RTF.
:grrr:

Tseng 09-14-2003 04:43 PM

Quote:

Originally posted by GoZelda

o.O crappy Java tutorial. Crappy NPCprogramming.RTF.
:grrr:

Dude, that has nothing to do with it. I don't think you fully understand the word 'compatibility'.

GoZelda 09-14-2003 04:48 PM

Quote:

Originally posted by Tseng


Dude, that has nothing to do with it. I don't think you fully understand the word 'compatibility'.

That could very well be XD

GoZelda 09-21-2003 04:01 PM

Quote:

Originally posted by Tseng


AHAHAHAHAHAHAHA

Quote:

Originally said by Stefan Knorr in NPCprogramming.rtf

You can also use other symbols like ":=" and a single "=" for checking equality, but it's not recommended (to keep compability to the Java/C++ syntax)

I'll get the for stuff later.

Kaimetsu 09-21-2003 04:13 PM

Quote:

Originally posted by GoZelda
I'll get the for stuff later.
English isn't Stefan's first language.

Anyway, i and j aren't part of Java or C and they're not syntactic devices. They're just variable names.

GoZelda 09-21-2003 05:35 PM

Quote:

Originally posted by Kaimetsu


English isn't Stefan's first language.

Nor is it mine, so i guess that's the reason of this... misunderstanding.

Admins 12-09-2003 02:40 PM

There is now a new command on RC:

/style scripttype name

Scripttype can be class, npc or weapon.
It is reformatting the script to look nicer. Please test it before using, sometimes triggeractions can be messed up because it divides weapon names like Day-Night in Day - Night. You can change the style options in the server options:

scriptstyle=spaces=2,padding=oper,brackets=attach

Spaces gives the number of spaces to put in front of each line (indenting).

Padding says where to put spaces in between:
'oper' will put spaces behind commands like 'if' and before and after operands like '+' and '==',
'paren' will put spaces in [] and (),
'all' will do both.

Brackets says if it should break lines before and after { and } ('break'),
or if it should actually attach it to the previous 'if' or 'for' command ('attach'). Use 'linux' as option if you want to break declarations (array declarations like a = {1,23}) but want to attach brackets after commands.

The npcserver uses the astyle library to format the text.

[edit: post merge by Loriel :cool:]

Yes i,j,k is common standard for loop index variables. The 'l' is not used often because it looks like a 1. So better continue with m,n,o,p,q,r,s,t etc. :)

osrs 12-09-2003 05:10 PM

Quote:

Originally posted by Stefan
There is now a new command on RC:

/style scripttype name

Scripttype can be class, npc or weapon.
It is reformatting the script to look nicer. Please test it before using, sometimes triggeractions can be messed up because it divides weapon names like Day-Night in Day - Night. You can change the style options in the server options:

scriptstyle=spaces=2,padding=oper,brackets=attach

Spaces gives the number of spaces to put in front of each line (indenting).

Padding says where to put spaces in between:
'oper' will put spaces behind commands like 'if' and before and after operands like '+' and '==',
'paren' will put spaces in [] and (),
'all' will do both.

Brackets says if it should break lines before and after { and } ('break'),
or if it should actually attach it to the previous 'if' or 'for' command ('attach'). Use 'linux' as option if you want to break declarations (array declarations like a = {1,23}) but want to attach brackets after commands.

The npcserver uses the astyle library to format the text.

[edit: post merge by Loriel :cool:]

Yes i,j,k is common standard for loop index variables. The 'l' is not used often because it looks like a 1. So better continue with m,n,o,p,q,r,s,t etc. :)

Finally!
But a style button wouldn't be better?

Loriel 12-09-2003 06:37 PM

A style button would have required yet another RC update, and would also need to be rescripted for the new RC later on. Also, I doubt it would do much good to the RC's compactness to link it with the library Stefan mentioned.
Edit: Actually, no. Forget that. A style button would be better.

VeX_RaT_Boy 12-10-2003 01:22 AM

Finnaly! Good job Stefan :)

But, yea, A style button would be better;)

xPuppetMasterx 12-10-2003 01:33 AM

Very nice. This will come in handy. :)

xManiamaNx 12-10-2003 01:56 AM

Wait for the new scripted rc, then you'll be able to have style buttons ;)

ForgottenLegacy 12-10-2003 06:18 AM

What are the options to have the same style that Stefan uses when he scripts? Fourm PM this to me please, as I never read this thread much.
NPC Code:

if (created) { //Braces on the same line, 1 space after the )
operations(); //Next command is on another line, alone, 2 spaces indented;
if (myflag) {
operations(); //Embedded command is 2 spaces indented, added to the origional 2 spaces
} // Closing brace on it's own line
}


dlang 12-10-2003 06:48 AM

I set the brackets to linux style but I can't seem to get them to change back to attached.

Loriel 01-07-2004 06:46 PM

Quote:

Originally posted by Kaimetsu in another thread
It's interesting to see that KSI-GS found its way into the Classic tab requirements. I would never have agreed with that decision.
Uhh... why not? :(

Hevaricubed 01-07-2004 11:47 PM

simply because the KSI-GS is just common sense, and if a playerworld had scripts which dont conform, that playeworld shalt be striketh down in a firey rain of brimstone and ash.

Kaimetsu 01-08-2004 05:43 AM

Quote:

Originally posted by Loriel
Uhh... why not? :(
Because only a small portion of scripters have the sense to adhere to it, so it almost certainly won't be enforced. Heck, the runt doesn't even understand the rules, let alone follow them. Do you really expect him to insist on their use?

Of course, the runt shouldn't be a GST member, but that's another story

Hevaricubed 01-11-2004 03:23 AM

Oooh which runt, gossip gossip gossip :P


All times are GMT +2. The time now is 01:38 PM.

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