Jump to content

Recommended Posts

Posted

function call with script should be called like C, just the name of the function with the params, example:

functioname(param1, param2, param3...);

Much more easy in my vision .. this will make the emulador be more slowly ?

ps: sorry for my bad english

Posted

Yes, but the function should be inside the script. If the functions being called just by their names, out stead of changing the source, you can do with scripts (and you can create a lot of library's too, make the work of create a script, easier).

sorry for my bad english.

Posted

you can call the function by just using the functionname in script.

Read my snippet. ^

- script sample -1,{
function func_sample;

func_sample(param1,param2,...);

function func_sample {
blablabla getarg(0) blabla getarg(1)...
}
}

  • Upvote 1
Posted

for god sake tr0n, i know that, i'm scripter, i know you can call that function, but need of "callfunc", i want call the function JUST WITH THE NAME !

again: sorry for my bad english

Posted

I think he want to call the function without the "callfunc"

function	script	plus	{
return getarg(0) + getarg(1);
}

prontera,100,100,4	script	Plus NPC	508,{
mes "5 + 6 = " + plus(5, 6);
close;
}

yes you can't do that, but.. whats wrong with "callfunc"?

function	script	plus	{
return getarg(0) + getarg(1);
}

prontera,100,100,4	script	Plus NPC	508,{
mes "5 + 6 = " + callfunc("plus", 5, 6);
close;
}

Posted
function	script	plus	{
return getarg(0) + getarg(1);
}

prontera,100,100,4	script	Plus NPC	508,{

function plus;

mes "5 + 6 = " + plus(5, 6);
close;
}

Posted (edited)

Please read this: ../doc/script_commands.txt

*function <function name>;

*<function name>;

*function <function name> {

<code>

}

(Skotlex stop being so selfish and give us all the commands T~T! J/k lol :P)

This works like callfunc. It's used for cleaner and fast scripting. Also they

must be inside a script. They're not separated scripts and they work more like

labels with arguments.

for function outside npc script, it must use "callfunc"

Edited by FatalEror
  • Upvote 2
Posted

Please read this: ../doc/script_commands.txt

*function <function name>;

*<function name>;

*function <function name> {

<code>

}

(Skotlex stop being so selfish and give us all the commands T~T! J/k lol :P)

This works like callfunc. It's used for cleaner and fast scripting. Also they

must be inside a script. They're not separated scripts and they work more like

labels with arguments.

for function outside npc script, it must use "callfunc"

I didn't read that. mkay..

Posted

callfunc in my opinion is ugly, and tr0n, i know you can't call a function just by her name, that's why i created this topic, to see if some core developer can do it

Posted

It's this?

prontera,150,150,5/*Tab*/script/*Tab*/normal/*Tab*/50,{

function exit;

exit "msg";

}

function/*Tab*/script/*Tab*/exit/*Tab*/{

mes getarg( 0);

return close;

}

To use a function without use a callfunc you, you just have to use function name_of_the_function; in the beggining of the script.

Posted (edited)

It's this?

prontera,150,150,5/*Tab*/script/*Tab*/normal/*Tab*/50,{
function exit;
exit "msg";
}

function/*Tab*/script/*Tab*/exit/*Tab*/{
mes getarg( 0);
return close;
}

To use a function without use a callfunc you, you just have to use function name_of_the_function; in the beggining of the script.

umm.. please read my post above..

you can't declare a function that is outside of npc script..

Edited by FatalEror
Posted

=/

I figure out that the correct way is:

prontera,150,150,5 script normal 50,{
function exit;
exit "msg";


function exit {
mes getarg(0);
close;
}
}

But there is no way to use just "function exit;" in other scripts, just if you use the function together.

Posted

- script sample -1,{
function func_sample;

func_sample(param1,param2,...);

function func_sample {
blablabla getarg(0) blabla getarg(1)...
}
}

I think @Dreaming means is the global side of that function since it can only be use inside the script (hope Iam right).

Posted (edited)

- script sample -1,{
function func_sample;

func_sample(param1,param2,...);

function func_sample {
blablabla getarg(0) blabla getarg(1)...
}
}

I think @Dreaming means is the global side of that function since it can only be use inside the script (hope Iam right).

Yes !! With that, you can use one function, with 9999999999999 scripts and use each function without putting them on everyone Edited by Dreaming
  • 2 weeks later...
Posted (edited)

You can use the function globally just with 'callfunc("FunctionName",arg1,arg2,...);', which other people have stated. Wouldn't it just be a cosmetic change to make it follow C syntax (as in, FunctionName(arg1,arg2,arg3,...); )?

I mean... call it 'ugly' but I actually like callfunc, using it as a way to keep track of various function calls is convenient for large scripts, especially when you can just ctrl+F for callfunc when you forget your function names after a month of not looking at a script.

I guess it would be cool and all, but is it really worth the work necessary to get it in? (Especially if SketchyPhoenix's Lua Script Engine gets finished and implemented)

tl;dr

Is it really that much of an inconvenience to type callfunc("FunctionName",arg1,arg2,...);?

Edit: Wow, 10 days later, sorry! Facebook just posted this up for me today so I thought it was more recent.

Edited by Variant
Posted

After reviewing this topic, I dove into the source and had a poke around and support for direct function invocation was added in r15979 :o

As such, the following should now work:

function<tab>script<tab>helloworld<tab>{
       mes "Hello " + getarg(0);
       return 1;
}

prontera,150,150,4<tab>script<tab>Say Hello!<tab>811,{
       helloworld strcharinfo(0);
       close;
}

  • Upvote 3
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...