Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   2 functions ? (https://forums.graalonline.com/forums/showthread.php?t=29498)

nyghtGT 05-19-2002 01:18 PM

2 functions ?
 
Is ok to set a function within a function?
NPC Code:

if (created||playerenters) {
toweapons Chat;
}
if (playerchats) {
tokenize #c;
for (i=0;i<tokenscount;i++) {
check();
}
}

// Functions
function check() {
if (strcontains(#t(i),#s(server.rsrvwords))) {
setplayerprop #c,Invalid and/or reserved words. Try again.;
} else {
addchat();
}
}



Bhala 05-19-2002 01:56 PM

Yes. It helps clean up code a lot that way.

nyghtGT 05-19-2002 02:27 PM

See what I am gonna have it do is have it add each token indivually to the string.

BBflat 05-19-2002 09:51 PM

I did that once, and I got a bunch of nasty commas. =( Since my tokens were one character long, I just wrote something that took out every other character...

Despo1 05-19-2002 11:52 PM

i thing the formating of a script is better to use some function in function for menues or other big scripts because itz better to a add a function to hide some images as u add the part 20times in a script or so :)

TDO2000 05-20-2002 01:06 AM

hmmm Kaimetsu said something about rekursion not working in the next version of gscript O_o
but at the moment it perfectly works ^.^

TDO2000 05-20-2002 05:04 AM

Quote:

Originally posted by Kaimetsu


I said that? I must have been temporarily crazy or something. Although... I suppose it might not work. Probably will. But I don't see any recursion in that script...?

if you peer and hold your head like this...
hmmm no you are right no recursion inside this script...
need to watch stuff longer...

Saga2001 05-20-2002 11:08 PM

Recursion is basic calling a fuction withing a function, if you don't have some sort of end to it, or a sleep timeout, you could be a very very sad person...
However, all that happens is Graal dies after a certain amount of runs, Kaimetsu, do you know how many?

Saga2001 05-21-2002 11:10 AM

Quote:

Originally posted by Kaimetsu


I have no idea. I suppose we could test it if we really cared enough.

Thats true, should have thought of that.

BBflat 05-23-2002 08:20 PM

Recursion...

NPC Code:

if (playerenters)
{
a();
}

function a()
{
if (playerx < 5 && playerx > 2)
{
sleep 1;
a();
}
else
{
messageLoop Terminated;
}
}



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

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