Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Sheep's little Guide on using GS2 in non-standard ways (https://forums.graalonline.com/forums/showthread.php?t=78024)

projectigi 12-23-2007 12:06 PM

Sheep's little Guide on using GS2 in non-standard ways
 
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
PHP Code:

//#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)

PHP Code:

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

another test:

<some npcs script>
PHP Code:

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

<script of -HolyAddHere>
PHP Code:

//#CLIENTSIDE
public function callFunctionfuncN )
  {
  (@ 
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>
PHP Code:

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

<script of -HolyAddHere>
PHP Code:

//#CLIENTSIDE
public function callFunctionfuncN )
  {
  (@ 
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>
PHP Code:

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

or from servside:
<script of some npcs>
PHP Code:

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 )

PHP Code:

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

    
setTimer0.05 );
    };
  (
"-System/Attack1").trigger"Timeout""" );
  
onTimeout();
  }
  
function 
onTimeout()
  {
    
setani"sit""" );
    
setTimer0.05 );
  } 

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

PHP Code:

//#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""" );
    
setTimer0.05 );
  } 

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

PHP Code:

//#CLIENTSIDE
function onCreated()
  {
  (
"-System/Attack1") = new TStaticVar();
  (
"-System/Attack1").onTimeout = function()
    {
    
player.chat "running timeout1";
  
    
setTimer0.05 );
    };
  (
"-System/Attack1").trigger"Timeout""" );
  
//onTimeout();
  
}
  
function 
onTimeout()
  {
    
setani"sit""" );
    
setTimer0.05 );
  } 


cbk1994 12-23-2007 03:21 PM

Quote:

Originally Posted by projectigi (Post 1365208)
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

Quote:

Originally Posted by cbkbud (Post 1365230)
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

Quote:

Originally Posted by Inverness (Post 1365337)
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

Quote:

Originally Posted by cbkbud (Post 1365433)
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

Quote:

Originally Posted by cbkbud (Post 1365433)
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

Quote:

Originally Posted by Angel_Light (Post 1365454)
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

Quote:

Originally Posted by Angel_Light (Post 1365454)
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

Quote:

Originally Posted by cbkbud (Post 1365433)
Why do people use +Something in mudlibs a lot of the time?

Because Graal Kingdoms uses + for weapon scripts for the mud.
Quote:

Originally Posted by Angel_Light (Post 1365454)
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:
PHP Code:

  // 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

Quote:

Originally Posted by Inverness (Post 1365465)
"GuiHud"
[/php]

IMAGES FOR YUR HUD

Inverness 12-24-2007 06:24 AM

Quote:

Originally Posted by cbkbud (Post 1365476)
IMAGES FOR YUR HUD

GuiShowImgCtrl 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

Quote:

Originally Posted by Twinny (Post 1365509)
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

Quote:

Originally Posted by Inverness (Post 1365502)
GuiShowImgCtrl idiot.

sarcasm plx

coreys 12-24-2007 05:41 PM

Quote:

Originally Posted by Twinny (Post 1365509)
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

Quote:

Originally Posted by Twinny (Post 1365509)
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.
Quote:

Originally Posted by Angel_Light (Post 1365508)
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

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

Angel_Light 12-24-2007 07:19 PM

Quote:

Originally Posted by Inverness (Post 1365580)
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

Quote:

Originally Posted by Twinny (Post 1365627)
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

Quote:

Originally Posted by Twinny (Post 1365627)
Inverness is the reincarnation of Gambet :whatever:

So true.
Quote:

Originally Posted by Inverness (Post 1365633)
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

Quote:

Originally Posted by Twinny (Post 1365627)
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

Quote:

Originally Posted by coreys (Post 1365660)
And doesn't have as big an ego.

I beg to differ.

Angel_Light 12-25-2007 07:47 AM

Quote:

Originally Posted by Inverness (Post 1365674)
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

Quote:

Originally Posted by Inverness (Post 1365674)
I beg to differ.

You have a big ego, to be sure.

But nothing compared to Gambet.


All times are GMT +2. The time now is 02:32 AM.

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