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 01-10-2002, 06:58 AM
Sennema Sennema is offline
Registered User
Join Date: Nov 2001
Location: Ontario, Canada
Posts: 132
Sennema is on a distinguished road
Send a message via ICQ to Sennema Send a message via AIM to Sennema
Functions and junk

I'm working on a script for something and I'm wondering if it's possible to call a function from within a function.

Something like:

NPC Code:

function test1(){
script stuff;
if(something happens){
test2();
}
return;
}


I'm not sure cause it isn't working to well with what I have. I'm actually testing for a position, and a keydown while at that position.
__________________
~Draemus Windblade


Just over 90% of all messages have no point or meaning.

"In order to preserve ourselves we seek out and eliminate anything that may do use harm. In doing so, we destroy things that, though possibly hazzardous, may be important to survival. So you see, in trying to save ourselves, we ultimately bring about our own destruction"


Luminar

Last edited by Sennema; 01-10-2002 at 08:09 AM..
Reply With Quote
  #2  
Old 01-10-2002, 08:19 AM
Goboom Goboom is offline
Pixel Monkey
Goboom's Avatar
Join Date: Dec 2001
Location: Michigan
Posts: 1,702
Goboom is on a distinguished road
Send a message via ICQ to Goboom Send a message via AIM to Goboom Send a message via MSN to Goboom Send a message via Yahoo to Goboom
Its very possible to use a function inside a function....
__________________
Reply With Quote
  #3  
Old 01-10-2002, 08:56 AM
Sennema Sennema is offline
Registered User
Join Date: Nov 2001
Location: Ontario, Canada
Posts: 132
Sennema is on a distinguished road
Send a message via ICQ to Sennema Send a message via AIM to Sennema
Ok, thanks. Now to figure out what's wrong with it...
__________________
~Draemus Windblade


Just over 90% of all messages have no point or meaning.

"In order to preserve ourselves we seek out and eliminate anything that may do use harm. In doing so, we destroy things that, though possibly hazzardous, may be important to survival. So you see, in trying to save ourselves, we ultimately bring about our own destruction"


Luminar
Reply With Quote
  #4  
Old 01-10-2002, 09:15 AM
WHIPENIE4 WHIPENIE4 is offline
I am X-Mann
Join Date: Aug 2001
Location: PA
Posts: 2,715
WHIPENIE4 is on a distinguished road
Send a message via ICQ to WHIPENIE4 Send a message via AIM to WHIPENIE4
[screen_name says:]

what does the command 'return' do??

i will probably feel stupid when someone tells me
__________________
Mind over Matter. If your body dont mind, why does it matter?

- X-Mann (Blessing Graal since 1998) Haha

- Graal 2000 Project (Contact Me to get Apart of this expierience

Windows Vista. Graal. Not a Good Combination.
Reply With Quote
  #5  
Old 01-10-2002, 11:00 AM
Er1c Er1c is offline
Registered User
Er1c's Avatar
Join Date: Mar 2001
Location: Chicago, IL
Posts: 791
Er1c is on a distinguished road
Return returns to the part of the script that called the function. In most scripting laungages, when you use return you return information back to the main script, but graal doesn't support that, in graal functions act as if they are just part of the script typed out in a different place.
__________________
Eric Kraft
Reply With Quote
  #6  
Old 01-10-2002, 08:15 PM
WHIPENIE4 WHIPENIE4 is offline
I am X-Mann
Join Date: Aug 2001
Location: PA
Posts: 2,715
WHIPENIE4 is on a distinguished road
Send a message via ICQ to WHIPENIE4 Send a message via AIM to WHIPENIE4
[screen_name says:]

so would this following code be considered good use of the return command

NPC Code:

// NPC made by screen_name
// NPC Name: N/A
// Project: N/A

if (playersays(doit)) {
setplayerprop #c, ;
doingit();
setplayerprop #c, this.counter was equal to #v(this.counter);
}

function doingit() {
this.counter=int(random(0,5));
return;
}



now this will make you say this.counter's value without having to say 'doit' again, right


so, if you are using functions in a timeout, you dont necessarily need returns right?? unless something below is using the new value??
__________________
Mind over Matter. If your body dont mind, why does it matter?

- X-Mann (Blessing Graal since 1998) Haha

- Graal 2000 Project (Contact Me to get Apart of this expierience

Windows Vista. Graal. Not a Good Combination.
Reply With Quote
  #7  
Old 01-10-2002, 08:22 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
Ive done threefold functions...function in a function which is in another function...it goes as far as you want
Reply With Quote
  #8  
Old 01-10-2002, 09:47 PM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
erm no screen_name... if a function is finished, it automatically returns to the main script. It's rather for doing stuff like this...
NPC Code:
if (actionblah) {
do some stuff;
Setani();
do more stuff;
}
function Setani() {
if (!visible) return;
else setcharani blah_idle,;
}

Reply With Quote
  #9  
Old 01-10-2002, 10:01 PM
WHIPENIE4 WHIPENIE4 is offline
I am X-Mann
Join Date: Aug 2001
Location: PA
Posts: 2,715
WHIPENIE4 is on a distinguished road
Send a message via ICQ to WHIPENIE4 Send a message via AIM to WHIPENIE4
[screen_name says:]


okay, i think i understand
__________________
Mind over Matter. If your body dont mind, why does it matter?

- X-Mann (Blessing Graal since 1998) Haha

- Graal 2000 Project (Contact Me to get Apart of this expierience

Windows Vista. Graal. Not a Good Combination.
Reply With Quote
  #10  
Old 01-10-2002, 11:16 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
And don't use playersays =P Use playerchats && strequals(#c,)
__________________
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
  #11  
Old 01-11-2002, 01:23 AM
WHIPENIE4 WHIPENIE4 is offline
I am X-Mann
Join Date: Aug 2001
Location: PA
Posts: 2,715
WHIPENIE4 is on a distinguished road
Send a message via ICQ to WHIPENIE4 Send a message via AIM to WHIPENIE4
[screen_name says:]


i usually do, but playersays was faster to type
__________________
Mind over Matter. If your body dont mind, why does it matter?

- X-Mann (Blessing Graal since 1998) Haha

- Graal 2000 Project (Contact Me to get Apart of this expierience

Windows Vista. Graal. Not a Good Combination.
Reply With Quote
  #12  
Old 01-11-2002, 01:56 AM
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
if for some reason you dont use player chats here is another way

if(strequals(#c,blah)){
setplayerprop #c,;
...commands...
}
Reply With Quote
  #13  
Old 01-11-2002, 02:13 AM
WHIPENIE4 WHIPENIE4 is offline
I am X-Mann
Join Date: Aug 2001
Location: PA
Posts: 2,715
WHIPENIE4 is on a distinguished road
Send a message via ICQ to WHIPENIE4 Send a message via AIM to WHIPENIE4
[screen_name says:]

im not a new scripter, i've been scripting npcs for graal for 2 1/2 years or so
__________________
Mind over Matter. If your body dont mind, why does it matter?

- X-Mann (Blessing Graal since 1998) Haha

- Graal 2000 Project (Contact Me to get Apart of this expierience

Windows Vista. Graal. Not a Good Combination.
Reply With Quote
  #14  
Old 01-11-2002, 03:19 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
u can also use break i believe
__________________
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
  #15  
Old 01-11-2002, 03:47 AM
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
Quote:
Originally posted by LiquidIce00
u can also use break i believe
break is for loops, it ends the if or while or for loop and continues with the script right after the loop
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 05:56 PM.


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