Matheus Posted April 12, 2012 Posted April 12, 2012 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
tr0n Posted April 12, 2012 Posted April 12, 2012 you can actually do it. function functionname; functionname(param1, param2, param3,...);
Matheus Posted April 13, 2012 Author Posted April 13, 2012 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.
tr0n Posted April 13, 2012 Posted April 13, 2012 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)... } } 1
Matheus Posted April 13, 2012 Author Posted April 13, 2012 I know tr0n, but what i mean, is call a function with the name, without her inside of script ..
tr0n Posted April 13, 2012 Posted April 13, 2012 outside the script: function script func_name { } you can call it like the other functions.
Matheus Posted April 13, 2012 Author Posted April 13, 2012 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
tr0n Posted April 14, 2012 Posted April 14, 2012 It is possible to call the function with the functionname only. That's what I'm telling you all the time.
FatalEror Posted April 14, 2012 Posted April 14, 2012 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; }
tr0n Posted April 14, 2012 Posted April 14, 2012 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; }
FatalEror Posted April 14, 2012 Posted April 14, 2012 (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 April 14, 2012 by FatalEror 2
tr0n Posted April 14, 2012 Posted April 14, 2012 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..
Matheus Posted April 14, 2012 Author Posted April 14, 2012 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
Vish Posted April 14, 2012 Posted April 14, 2012 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.
FatalEror Posted April 14, 2012 Posted April 14, 2012 (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 April 14, 2012 by FatalEror
Vish Posted April 14, 2012 Posted April 14, 2012 =/ 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.
Vish Posted April 14, 2012 Posted April 14, 2012 (edited) @edit sorry '-' Edited April 14, 2012 by Ansen
JayPee Posted April 15, 2012 Posted April 15, 2012 - 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).
Matheus Posted April 15, 2012 Author Posted April 15, 2012 (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 April 15, 2012 by Dreaming
Variant Posted April 26, 2012 Posted April 26, 2012 (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 April 26, 2012 by Variant
Panallox Posted April 26, 2012 Posted April 26, 2012 After reviewing this topic, I dove into the source and had a poke around and support for direct function invocation was added in r15979 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; } 3
Recommended Posts