Matheus Posted April 12, 2012 Group: Members Topic Count: 8 Topics Per Day: 0.00 Content Count: 63 Reputation: 6 Joined: 11/15/11 Last Seen: December 13, 2013 Share 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 Link to comment Share on other sites More sharing options...
tr0n Posted April 12, 2012 Group: Members Topic Count: 28 Topics Per Day: 0.01 Content Count: 562 Reputation: 153 Joined: 02/21/12 Last Seen: February 27, 2024 Share Posted April 12, 2012 you can actually do it. function functionname; functionname(param1, param2, param3,...); Link to comment Share on other sites More sharing options...
Matheus Posted April 13, 2012 Group: Members Topic Count: 8 Topics Per Day: 0.00 Content Count: 63 Reputation: 6 Joined: 11/15/11 Last Seen: December 13, 2013 Author Share 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. Link to comment Share on other sites More sharing options...
tr0n Posted April 13, 2012 Group: Members Topic Count: 28 Topics Per Day: 0.01 Content Count: 562 Reputation: 153 Joined: 02/21/12 Last Seen: February 27, 2024 Share 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 Link to comment Share on other sites More sharing options...
Matheus Posted April 13, 2012 Group: Members Topic Count: 8 Topics Per Day: 0.00 Content Count: 63 Reputation: 6 Joined: 11/15/11 Last Seen: December 13, 2013 Author Share Posted April 13, 2012 I know tr0n, but what i mean, is call a function with the name, without her inside of script .. Link to comment Share on other sites More sharing options...
tr0n Posted April 13, 2012 Group: Members Topic Count: 28 Topics Per Day: 0.01 Content Count: 562 Reputation: 153 Joined: 02/21/12 Last Seen: February 27, 2024 Share Posted April 13, 2012 outside the script: function script func_name { } you can call it like the other functions. Link to comment Share on other sites More sharing options...
Matheus Posted April 13, 2012 Group: Members Topic Count: 8 Topics Per Day: 0.00 Content Count: 63 Reputation: 6 Joined: 11/15/11 Last Seen: December 13, 2013 Author Share 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 Link to comment Share on other sites More sharing options...
tr0n Posted April 14, 2012 Group: Members Topic Count: 28 Topics Per Day: 0.01 Content Count: 562 Reputation: 153 Joined: 02/21/12 Last Seen: February 27, 2024 Share 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. Link to comment Share on other sites More sharing options...
FatalEror Posted April 14, 2012 Group: Members Topic Count: 0 Topics Per Day: 0 Content Count: 67 Reputation: 23 Joined: 11/14/11 Last Seen: October 3, 2014 Share 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; } Link to comment Share on other sites More sharing options...
tr0n Posted April 14, 2012 Group: Members Topic Count: 28 Topics Per Day: 0.01 Content Count: 562 Reputation: 153 Joined: 02/21/12 Last Seen: February 27, 2024 Share 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; } Link to comment Share on other sites More sharing options...
FatalEror Posted April 14, 2012 Group: Members Topic Count: 0 Topics Per Day: 0 Content Count: 67 Reputation: 23 Joined: 11/14/11 Last Seen: October 3, 2014 Share 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 Link to comment Share on other sites More sharing options...
tr0n Posted April 14, 2012 Group: Members Topic Count: 28 Topics Per Day: 0.01 Content Count: 562 Reputation: 153 Joined: 02/21/12 Last Seen: February 27, 2024 Share 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.. Link to comment Share on other sites More sharing options...
Matheus Posted April 14, 2012 Group: Members Topic Count: 8 Topics Per Day: 0.00 Content Count: 63 Reputation: 6 Joined: 11/15/11 Last Seen: December 13, 2013 Author Share 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 Link to comment Share on other sites More sharing options...
Vish Posted April 14, 2012 Group: Members Topic Count: 0 Topics Per Day: 0 Content Count: 4 Reputation: 0 Joined: 11/15/11 Last Seen: September 17, 2015 Share 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. Link to comment Share on other sites More sharing options...
FatalEror Posted April 14, 2012 Group: Members Topic Count: 0 Topics Per Day: 0 Content Count: 67 Reputation: 23 Joined: 11/14/11 Last Seen: October 3, 2014 Share 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 Link to comment Share on other sites More sharing options...
Vish Posted April 14, 2012 Group: Members Topic Count: 0 Topics Per Day: 0 Content Count: 4 Reputation: 0 Joined: 11/15/11 Last Seen: September 17, 2015 Share 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. Link to comment Share on other sites More sharing options...
Vish Posted April 14, 2012 Group: Members Topic Count: 0 Topics Per Day: 0 Content Count: 4 Reputation: 0 Joined: 11/15/11 Last Seen: September 17, 2015 Share Posted April 14, 2012 (edited) @edit sorry '-' Edited April 14, 2012 by Ansen Link to comment Share on other sites More sharing options...
JayPee Posted April 15, 2012 Group: Members Topic Count: 47 Topics Per Day: 0.01 Content Count: 633 Reputation: 78 Joined: 11/14/11 Last Seen: September 20, 2017 Share 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). Link to comment Share on other sites More sharing options...
Matheus Posted April 15, 2012 Group: Members Topic Count: 8 Topics Per Day: 0.00 Content Count: 63 Reputation: 6 Joined: 11/15/11 Last Seen: December 13, 2013 Author Share 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 Link to comment Share on other sites More sharing options...
Variant Posted April 26, 2012 Group: Members Topic Count: 3 Topics Per Day: 0.00 Content Count: 52 Reputation: 6 Joined: 01/06/12 Last Seen: December 12, 2017 Share 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 Link to comment Share on other sites More sharing options...
Panallox Posted April 26, 2012 Group: Members Topic Count: 12 Topics Per Day: 0.00 Content Count: 117 Reputation: 169 Joined: 11/10/11 Last Seen: April 10, 2024 Share 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 Link to comment Share on other sites More sharing options...
Matheus Posted April 26, 2012 Group: Members Topic Count: 8 Topics Per Day: 0.00 Content Count: 63 Reputation: 6 Joined: 11/15/11 Last Seen: December 13, 2013 Author Share Posted April 26, 2012 Thank you ! You're awesome ! Link to comment Share on other sites More sharing options...
Recommended Posts