Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 12-14-2001, 11:01 PM
btedji btedji is offline
bryan986
btedji's Avatar
Join Date: Apr 2001
Location: Force 10
Posts: 1,153
btedji is on a distinguished road
Send a message via ICQ to btedji Send a message via AIM to btedji Send a message via Yahoo to btedji
function arguments

can you pass arguments through functions in graal like this?

funtion Test(this.test){
this.test+=5;
}

Test(5);


this.test would now be worth 10 if it worked
Reply With Quote
  #2  
Old 12-14-2001, 11:18 PM
Xaviar Xaviar is offline
Registered User
Join Date: Aug 2001
Location: Fairyland
Posts: 463
Xaviar is on a distinguished road
Send a message via ICQ to Xaviar Send a message via AIM to Xaviar
Re: function arguments

Quote:
Originally posted by btedji
can you pass arguments through functions in graal like this?

funtion Test(this.test){
this.test+=5;
}

Test(5);


this.test would now be worth 10 if it worked
I've tried, and it didn't turn out to well...just put this.test = 5; before the function call
__________________
One by one, the penguins steal my sanity.

*cookie for Xaviar* --Originally posted by Tyhm

--Xaviar

A m e r i c a
Reply With Quote
  #3  
Old 12-14-2001, 11:27 PM
btedji btedji is offline
bryan986
btedji's Avatar
Join Date: Apr 2001
Location: Force 10
Posts: 1,153
btedji is on a distinguished road
Send a message via ICQ to btedji Send a message via AIM to btedji Send a message via Yahoo to btedji
Re: Re: function arguments

Quote:
Originally posted by Xaviar


I've tried, and it didn't turn out to well...just put this.test = 5; before the function call
Does that mean it doesn't work??
Reply With Quote
  #4  
Old 12-14-2001, 11:30 PM
Xaviar Xaviar is offline
Registered User
Join Date: Aug 2001
Location: Fairyland
Posts: 463
Xaviar is on a distinguished road
Send a message via ICQ to Xaviar Send a message via AIM to Xaviar
Re: Re: Re: function arguments

Quote:
Originally posted by btedji


Does that mean it doesn't work??
I'm sure there is some way to do it...or maybe it was never implemented, but if you screw up a function call, and you test it, it'll say "Error: Expected function() or function(x,y)" or something like that...But, I can't get it to work, so if you can manage, please tell me how...but otherwise, just set the variable to the value you want it, before the function call...You really don't need to pass values, technically, because from a scripts perspective, all variables are global, regardless of where you declare them...
__________________
One by one, the penguins steal my sanity.

*cookie for Xaviar* --Originally posted by Tyhm

--Xaviar

A m e r i c a
Reply With Quote
  #5  
Old 12-14-2001, 11:55 PM
TDO2000 TDO2000 is offline
Registered User
TDO2000's Avatar
Join Date: Jul 2001
Location: Germany
Posts: 655
TDO2000 is on a distinguished road
at the moment there is no way to use parameters with functions
the () are just used to say, that a function is called...
but functions in gscript accept every variable that was set in the NPC so u can just use this.test if u set it somewhere else in the whole code like

if(playerenters){
this.test=5;
showtext();
}

function showtext() {
message The Number is #v(this.test);
}
__________________
No Webhost at the moment
Reply With Quote
  #6  
Old 12-15-2001, 04:14 AM
LiquidIce00 LiquidIce00 is offline
RadioActive Monkeeh
LiquidIce00's Avatar
Join Date: Apr 2001
Location: dirty south
Posts: 2,112
LiquidIce00 is on a distinguished road
Send a message via ICQ to LiquidIce00 Send a message via AIM to LiquidIce00 Send a message via Yahoo to LiquidIce00
Stefan had said he wasnt gonna do it cuz it had to change a lot of stuff or something
__________________
LiquidIce *Owner* (UnholyNation)
-UN Website
http://www.unholynation.com
-UN Forum
http://forums.unholynation.com
-
-the thinker
-

-
onwall2 for nonp2p (i suck at onwall)
Reply With Quote
  #7  
Old 12-15-2001, 06:24 AM
Saga2001 Saga2001 is offline
Wishing he had 3 feet
Join Date: Aug 2001
Location: Basement
Posts: 1,565
Saga2001 is on a distinguished road
Send a message via ICQ to Saga2001 Send a message via AIM to Saga2001 Send a message via Yahoo to Saga2001
well...

see you can't do that..
but it doesn't matter...
cause since gscript has a global scope there is no point...
i have always thought there should be global function like
NPC Code:

server/database npc...
global_function functionName() {
do stuff...
}
Other npc on a level...
if (true) {functionName();}


like have a server npc for doing l33t server stuff...
-Past...
__________________

!Wan ( 11:27:55 AM):
can i c ur scripts please?
Zorg (RC): If I hear NPC Server call Ne0, Past Austin or Brent sexy one more time im disconnecting it
Reply With Quote
  #8  
Old 12-17-2001, 08:17 PM
btedji btedji is offline
bryan986
btedji's Avatar
Join Date: Apr 2001
Location: Force 10
Posts: 1,153
btedji is on a distinguished road
Send a message via ICQ to btedji Send a message via AIM to btedji Send a message via Yahoo to btedji
Re: well...

Quote:
Originally posted by Saga2001
see you can't do that..
but it doesn't matter...
cause since gscript has a global scope there is no point...
i have always thought there should be global function like
NPC Code:

server/database npc...
global_function functionName() {
do stuff...
}
Other npc on a level...
if (true) {functionName();}


like have a server npc for doing l33t server stuff...
-Past...
that would be cool
Reply With Quote
  #9  
Old 12-17-2001, 10:04 PM
kyle0654 kyle0654 is offline
-. .`
kyle0654's Avatar
Join Date: Mar 2001
Posts: 1,000
kyle0654 will become famous soon enough
*wants Stefan to add support for arguments in functions*
*has wanted him to since functions were added*
Reply With Quote
  #10  
Old 12-19-2001, 03:13 AM
joseyisleet joseyisleet is offline
Registered User
Join Date: Aug 2001
Posts: 378
joseyisleet is on a distinguished road
OK, I made this `script` a LONG time ago. It shows how to add stuff for string and stuff.

NPC Code:

// NPC made by Josey Hunt
if (created){
dontblock;
drawoverplayer;
setimg goldball.png;
message Pushups NPC!;
}
if (playertouchsme&&!hasweapon(pushups)) {
toweapons pushups;
setstring pushups,0;
say2 You get 1 gralat for every#b2 push up you do.#bThis is the easiest way#bto make money on Xitami!!#bCommands:Show pushups#bGet money. That's it.;
}
if (weaponfired) {
playerdir=2;
pushups();
i=strtofloat(#s(pushups))+1;
if (i==1000) {setstring pushups,max;
say2 You have done the#bmaximum amount of pushups#ballowed!#bSo cash in and start over!; }
setstring pushups,#v(i);
this.pushups=strtofloat(#s(pushups));
}
if (playerchats&&strequals(#c,show pushups)){
say2 You have done #s(pushups) pushup(s)!;
}
if (playerchats&&strequals(#c,Get money)&&strequals(#w,pushups)){
say2 Here is your money!;
this.rupees=strtofloat(#s(pushups))*2;
playerrupees+=this.rupees;
setstring pushups,0;
}
function pushups(){
disabledefmovement;
playersprite=14;
sleep .1;
playersprite=15;
sleep .1;
playersprite=16;
sleep .1;
playersprite=17;
sleep .1;
playersprite=18;
sleep .1;
playersprite=14;
sleep .1;
playersprite=15;
sleep .1;
playersprite=16;
sleep .1;
playersprite=17;
sleep .1;
playersprite=18;
sleep .1;
playersprite=14;
sleep .1;
playersprite=15;
sleep .1;
playersprite=16;
sleep .1;
playersprite=17;
sleep .1;
playersprite=18;
sleep .1;
playersprite=1;
setani idle,;
enabledefmovement;
}

__________________
Account used by Josey and Howard.
Ali G: 'Is it cause i Black?'
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 08:01 AM.


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