PDA

View Full Version : Sheep's little Guide on using GS2 in non-standard ways


projectigi
12-23-2007, 12:06 PM
well atleast i have never seen anynone using it like this

adding functions to a TStaticVar without using a class

so that was the basis of all the other stuff ;D

//#CLIENTSIDE
function onCreated()
{
this.test = new TStaticVar();
this.test.bah = function()
{
player.chat = "foobar";
};
this.test.bah();
}

projectigi
12-23-2007, 12:06 PM
adding a function to another NPC:
(note, -HolyAddHere is an existing weapon that i have got on my char)

//#CLIENTSIDE
function onCreated()
{
("-HolyAddHere").onTestingTrigger = function()
{
player.chat = "b";
};
("-HolyAddHere").trigger( "TestingTrigger", "" );
}


another test:

<some npcs script>

//#CLIENTSIDE
function onCreated()
{
("-HolyAddHere").BTestingTrigger = function()
{
player.chat = "b";
};
("-HolyAddHere").callFunction( "BTestingTrigger" );
}


<script of -HolyAddHere>

//#CLIENTSIDE
public function callFunction( funcN )
{
(@ funcN)();
}


should work serverside and with TServerNPCs etc too :p

projectigi
12-23-2007, 12:08 PM
replacing functions
(now we replace a already existing function)

a) replacing an npcs functions

(note that -HolyAddHere is an existant weapon that i have got on my char )

<script of any npc>
//#CLIENTSIDE
function onCreated()
{
("-HolyAddHere").cTest = function()
{
player.chat = "a";
};
("-HolyAddHere").callFunction( "cTest" );
}


<script of -HolyAddHere>

//#CLIENTSIDE
public function callFunction( funcN )
{
(@ funcN)();
}

function cTest()
{
player.chat = "b";
}


works with servside npcs too :p

b) replacing a standard graal function

k, lets say if you do setani( "meh", "" ); the player will say "meh"... impossible? nooo

<script of some npc>

//#CLIENTSIDE
function onCreated()
{
this.setani = function( ani, aniparams )
{
player.chat = ani;
};
setani( "meh", "" );
}


or from servside:
<script of some npcs>

function onCreated()
{
this.sendtorc = function( msg )
{
echo( "NPC-Serv wants to say:" @ msg );
};
sendtorc( "meh" );
}

projectigi
12-23-2007, 12:08 PM
2 separated timeouts(note that -System/Attack1 is a non-existant(it isnt a weapon, npc or anything else in rc/serv))

running both timeouts:
( in this case player saying "running timeout1" + sitting all the time )


//#CLIENTSIDE
function onCreated()
{
("-System/Attack1") = new TStaticVar();
("-System/Attack1").onTimeout = function()
{
player.chat = "running timeout1";

setTimer( 0.05 );
};
("-System/Attack1").trigger( "Timeout", "" );
onTimeout();
}

function onTimeout()
{
setani( "sit", "" );
setTimer( 0.05 );
}



running only the main(in the npc itself)
( in this case player sitting all the time without saying "running timeout1" )


//#CLIENTSIDE
function onCreated()
{
("-System/Attack1") = new TStaticVar();
("-System/Attack1").onTimeout = function()
{
player.chat = "running timeout1";

//setTimer( 0.05 );
};
//("-System/Attack1").trigger( "Timeout", "" );
onTimeout();
}

function onTimeout()
{
setani( "sit", "" );
setTimer( 0.05 );
}



running only the "sub" timeout:
(in this case player saying "running timeout1" without sitting all the time)


//#CLIENTSIDE
function onCreated()
{
("-System/Attack1") = new TStaticVar();
("-System/Attack1").onTimeout = function()
{
player.chat = "running timeout1";

setTimer( 0.05 );
};
("-System/Attack1").trigger( "Timeout", "" );
//onTimeout();
}

function onTimeout()
{
setani( "sit", "" );
setTimer( 0.05 );
}

cbk1994
12-23-2007, 03:21 PM
french

Interesting ...
There could be practical uses for this, but I think for making them say "running timeout1" and sitting, you would be better off with something else :)

projectigi
12-23-2007, 04:32 PM
Interesting ...
There could be practical uses for this, but I think for making them say "running timeout1" and sitting, you would be better off with something else :)

well it was just an example for how to do it xD
i'm kinda lazy and didnt wanna think of useful examples heh

MysticalDragonP2P
12-23-2007, 05:13 PM
Well nether less its nice, and well put.Simple enough for anyone to figure it out.
Yay Sheepy <3

Inverness
12-23-2007, 09:16 PM
I really wish people wouldn't use object names that require quotes to be able to process :(

EX:
("-System/Attack1").attr
vs.
SystemAttack1.attr

If you're not using standard Graal Q menu then the minus signs and slashes are unnecessary for weapons.

cbk1994
12-24-2007, 01:54 AM
I really wish people wouldn't use object names that require quotes to be able to process :(

EX:
("-System/Attack1").attr
vs.
SystemAttack1.attr

If you're not using standard Graal Q menu then the minus signs and slashes are unnecessary for weapons.

Why do people use +Something in mudlibs a lot of the time?

gemini2
12-24-2007, 02:21 AM
Why do people use +Something in mudlibs a lot of the time?

Alot of the time? It's basicly used by a few or some people to organize :) Or what Napo said in the post below this post.

As Inverness said, things like slashes, plus and minus shouldn't be in the wnpc name or in any other object names. ^_^

napo_p2p
12-24-2007, 02:23 AM
Why do people use +Something in mudlibs a lot of the time?

Probably just to complicate things. It's unnecessary.

Angel_Light
12-24-2007, 03:21 AM
I do it for organization, I start all my system scripts with -, all mud with +, I use !, $ and * on few weps too.

coreys
12-24-2007, 03:25 AM
I do it doe organization, I start all my system scripts with -, all mud with +, I use !, $ and * on few weps too.

That's just poor organizations.

- is used in the Classic System weapons for weapons you don't want to shop up in the players inventory.

gemini2
12-24-2007, 03:33 AM
I do it doe organization, I start all my system scripts with -, all mud with +, I use !, $ and * on few weps too.

And, read Inverness post, tells you why you shouldn't use those :)

Inverness
12-24-2007, 04:14 AM
Why do people use +Something in mudlibs a lot of the time?Because Graal Kingdoms uses + for weapon scripts for the mud.
I do it doe organization, I start all my system scripts with -, all mud with +, I use !, $ and * on few weps too.
Thats silly. I keep my weapons nicely named on Val Dev, here is the array of weapons added on login:

// Names of weapons to add to player on login.
// Automatic: ObjectTypes, System, -ScriptedRC
this.addweapons = {
// Systems
"SysChat",
"SysNick",
"SysTileDefs",
"SysTime",
"SysMsg",
"SysOutfit",
"SysVision",
"SysBoard",
// Mud
"MudControl",
"MudWeapons",
// GUIs
"GuiCharacterSelect",
"GuiProfiles",
"GuiInfoDialog",
"GuiInventory",
"GuiHud",
"GuiNpcDialog",
"GuiChatHistory",
"GuiInputDialog",
"GuiBook",
"GuiBoard",
"GuiPlaylist",
"GuiLevelDesc",
// Other
"DialogControl",
"Console",
};

cbk1994
12-24-2007, 04:42 AM
"GuiHud"
[/php]

IMAGES FOR YUR HUD

Inverness
12-24-2007, 06:24 AM
IMAGES FOR YUR HUDGuiShowImgCtrl idiot.

Angel_Light
12-24-2007, 07:04 AM
Organization is all point of view, same with styling and etc. This is a good example, I'll respect your guy's point of views and all, but I find it easier with my symbols. =P

Twinny
12-24-2007, 07:06 AM
Do remember: scripts are compiled into bytecode and as such, I'm sure they do not give a **** however you name them. To care about such little stupid things....

Angel_Light
12-24-2007, 07:07 AM
Do remember: scripts are compiled into bytecode and I'm sure they do not give a **** however you name them.

lol, that actually brought a tear to my eye. I have no life. ^^

cbk1994
12-24-2007, 03:19 PM
GuiShowImgCtrl idiot.

sarcasm plx

coreys
12-24-2007, 05:41 PM
Do remember: scripts are compiled into bytecode and as such, I'm sure they do not give a **** however you name them. To care about such little stupid things....

A good point.

Inverness
12-24-2007, 07:00 PM
Do remember: scripts are compiled into bytecode and as such, I'm sure they do not give a **** however you name them. To care about such little stupid things....Of course the scripts don't care. If you'd read the thread instead of jumping in you'd notice the subject is about personal preference. Not about how Graal cares about the names since it doesn't at all.

Maybe you don't mind your scripts looking bad but if I were to choose from:
"SysMsg".addmsg();
or
SysMsg.addmsg();
I would choose the second option considering it looks better, its the more proper way, and its not highlighted in neon pink. The second option is only possible in the case that your weapon/object name doesn't have funky symbols in it.

If you want to name your objects with funky symbols, fine, it will just make your script look a bit worse when its really unnecessary. If you take advantage of public functions that is.
Organization is all point of view, same with styling and etc. This is a good example, I'll respect your guy's point of views and all, but I find it easier with my symbols. =PDo you think about people other than yourself when you do that?

Angel_Light
12-24-2007, 07:19 PM
blah

Do you think about people other than yourself when you do that?

Not really, since I know no one will use my scripts anyways. =P

Twinny
12-25-2007, 12:20 AM
I saw the thread as showing the lesser known ways of using gscript which was quite good. After that, I saw you *****ing about 'personal preferences'.

Inverness is the reincarnation of Gambet :whatever:

Inverness
12-25-2007, 12:45 AM
I saw the thread as showing the lesser known ways of using gscript which was quite good. After that, I saw you *****ing about 'personal preferences'.

Inverness is the reincarnation of Gambet :whatever:I was just saying why its a good idea to not use funky characters in weapon names, so you can avoid script that looks like the ones in the initial post. Contribute or go away please, thanks. And stop *****ing about our discussion.

cbk1994
12-25-2007, 03:46 AM
Inverness is the reincarnation of Gambet :whatever:

So true.
I was just saying why its a good idea to not use funky characters in weapon names, so you can avoid script that looks like the ones in the initial post. Contribute or go away please, thanks. And stop *****ing about our discussion.

Someone doesn't play well with others.

coreys
12-25-2007, 06:05 AM
Inverness is the reincarnation of Gambet :whatever:

Except Inverness can script and isn't hated by everyone.

And is intelligent.

And doesn't have as big an ego. (Although he does have one)

Inverness
12-25-2007, 07:20 AM
And doesn't have as big an ego.I beg to differ.

Angel_Light
12-25-2007, 07:47 AM
I beg to differ.

lol, it is quite huge, I know this from experience, Odd part is that he has every right to have it. =P

coreys
12-25-2007, 07:47 PM
I beg to differ.

You have a big ego, to be sure.

But nothing compared to Gambet.