Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Future Improvements (https://forums.graalonline.com/forums/forumdisplay.php?f=10)
-   -   New Script features! (https://forums.graalonline.com/forums/showthread.php?t=5208)

Falcor 06-20-2001 06:34 AM

New Script features!
 
Ok, If any of you know JavaScript ud understand this..

You know how functions() are called like that. Well if you didnt already know this. fuctions can contain objects!!!! Yes its true people.. But this is disabled in Graal I was hoping stefan could ad this...
'
Simple Explanation
NPC Code:

function funcName(argument1,argument2,etc)
{ statements; }



and then

NPC Code:

funcName(value1,value2,ect)



============================

MoreBiggernier Explanation

Ok. Well Function Arguments or Objects are like when you put an argument into a command. For example..

message text;

text is the 1 argument in that commandline

Now Functions are made to take in objects and spit out results...

Example..
NPC Code:

cut_out_token_one(Call me Cool)



And the function

NPC Code:

function cut_out_token_one(message) {
tokenize #o(message); /*Im using #o cuz of strings. in
javaScript strings are set with "" not setstring.*/
for(i=0;i<tokenscount;i++;) {
if (i!=1) {
setstring result,#T(#s(result) #t(i));
}
}
return;
}



So it would return in the string
result

and have the value = Call Cool;

I hope that explains function aguments or objects ^^;

Adn calling then for you information...

A function waits in the wings until it is called onto the stage. You call a function simply by specifying its name followed by a parenthetical list of arguments, if any:


clearPage();
cut_out_token_one(Call me Cool);
Functions which return a result should be called from within an expression:


total=raiseP(2,8);
if (raiseP(tax,2)<100) ...



Spearman 06-20-2001 08:38 AM

Good idea, I have seen functions and stuff before like in javascripts and whatnot and I'm not that great of a scripter, but I was wondering why graal didn't have something like that in their functions

grim_squeaker_x 06-20-2001 06:04 PM

In the debugger it already says something along these lines actually... Perhaps it's worth experimenting to see if there's already something like that?

Falcor 06-21-2001 09:35 PM

*Staying alive*

Kaimetsu 06-21-2001 09:41 PM

Nah, args and returns have not yet been implemented.

grim_squeaker_x 06-21-2001 11:49 PM

That's too bad... It could be a perfect script shortener in some cases.

Kaimetsu 06-21-2001 11:51 PM

Variables:

param1
param2
param3
return

Sure, they're not perfect but what is?

grim_squeaker_x 06-21-2001 11:53 PM

Well yes you're right, although in the case of a function which has a chance of calling itself it should actually be a couple of arrays.

AlexH 06-21-2001 11:54 PM

*reads the first post*
*thinks*
*looooooooooong silence*
*looks puzzle*
*runs away*

Kaimetsu 06-21-2001 11:55 PM

Nurk! I hate recursion anyway...

grim_squeaker_x 06-21-2001 11:57 PM

Well it sometimes (very rarely) necesarry.

Kaimetsu 06-21-2001 11:59 PM

True, I've had to use it once myself. I didn't want to, but life's a beach.

Solareon 06-24-2001 03:32 PM

just do the following....
 
do something along to the lines of

function ProcessParam();
if (multicasevar="value for action to be called") {
Script functions here
}
if (multicasevar="value for different action") {
Script Functions here
}


not sure if that is proper graal script but that would be somethign similar (don't want to open up commands.rtf and read through all the things for it.

then to call the function do the following

setstring multicasevar,#s(variable)
ProcessParam()

it is similar in effect but you just have to have the varibles preset before you call them. In VB this is called Select Case (although VB handles variables passed to functions normally)

few extra lines of code but for the extra script functions you can have in a shorter space. If you wanted to you could change the Script Functions here part to call another Function (shortens script so you can have a parser function and then actually script functions that do something.

Defitions of variables:
multicasevar, set this to what the case is you want to call a certain function or set of script commands.
variable, this is the text tat is passed to the parser
the things in quotes change that to something to match a varible the multicasevar may be set to.

if someone would translate this to mroe of a graal script that would be most appreciated.


All times are GMT +2. The time now is 09:39 PM.

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