maqc1 8 Posted March 16, 2016 Hi folks! According to the wiki, it is possible to call a function as a script command : http://herc.ws/wiki/Functions#Calling_Function_as_a_Script_Command Calling Function as a Script Command prontera,150,150,5<TAB>script<TAB>Calculator<TAB>999,{ mes Add(1,2); function<TAB>Add<TAB>{ return (getarg(0)+getarg(1)); } } However, I am unable to reproduce the example. The console throws me a parse_line error : [Error]: script error in file 'npc/test/test.txt' line 91 column 12 parse_line: need ';' 90: { * 91: mes Add(1,2); ~~~~~~~~~~~^ 92: 93: function Add { 94: return (getarg(0)+getarg(1)); Is there any way to make this work? Or is it an error on the wiki? Thanks in advance! Quote Share this post Link to post Share on other sites
0 Angelmelody 221 Posted March 16, 2016 (edited) prontera,150,150,5 script Calculator 999,{ function Add; mes ""+Add(1,2); close; function Add { return (getarg(0)+getarg(1)); } } Edited March 16, 2016 by Angelmelody Quote Share this post Link to post Share on other sites
0 maqc1 8 Posted March 17, 2016 Nope, still the same error. It looks like this feature isn't implemented yet... Is anyone able to reproduce the wiki's example? Quote Share this post Link to post Share on other sites
0 Garr 117 Posted March 17, 2016 (edited) Iirc if you put tabs inside function declaration it'd try to read it as an NPC declaration, so just space them out and try. I use functions that way for a while, makes it easier to change and maintain. Edited March 17, 2016 by Garr Quote Share this post Link to post Share on other sites
0 Emistry 145 Posted March 17, 2016 (edited) prontera,155,175,5 script Sample#npc 4_F_KAFRA9,{ function add { return getarg(0,0) + getarg( 1,0); } mes "You get "+ add( 1,2 ); close; } hmm, the forum seem like having some bug showing the tab indent ?? Edited March 17, 2016 by Emistry Quote Share this post Link to post Share on other sites
0 maqc1 8 Posted March 17, 2016 (edited) Thanks Emistry, got it to work. The function needs to be declared ABOVE the function call. It was that simple! Gotta get to work now EDIT : I just modified the wiki according to that rule. Edited March 17, 2016 by maqc1 Quote Share this post Link to post Share on other sites
Hi folks! According to the wiki, it is possible to call a function as a script command :
http://herc.ws/wiki/Functions#Calling_Function_as_a_Script_Command
However, I am unable to reproduce the example. The console throws me a parse_line error :
Is there any way to make this work? Or is it an error on the wiki?
Thanks in advance!
Share this post
Link to post
Share on other sites