Epoque 147 Posted April 27, 2012 Summary As of r15982, variables used within scripts can be directly assigned to as you would using another programming language. That is to say, that the following set of predicates will work: @i = 1; @i++; @i *= 2; @i = @j = 1; @i -= @j; for( @i = 0; 10 > @i; @i++ ) { } while( (@i += 1) < 20 ) { } Support for all of the major operator methods have been included (+=, -=, /=, *= etc.) This announcement is to ensure that any and all problems encountered while using this method of accessing variables must be reported, along with any traces you can possibly provide (and a clear example of the script is appreciated.) This comes as a secondary update to the scripting engine to unify the language to conform to standards set by other languages. The scripting engine now supports both the direct invocation of user-defined functions (r15979 and r15981) and variable access systems (r15982.) Notes This does not affect previous scripts at all. The new engine converts patterns that match var = value; to set(var, value); for backwards compatibility. Testing was performed using all of the operator methods, and was tested using loops. However, nested operations have not yet been thoroughly tested. 15 Share this post Link to post Share on other sites
Nameless2you 52 Posted April 27, 2012 Interesting.. Share this post Link to post Share on other sites
jTynne 193 Posted April 27, 2012 Finally! XD Thanks guys. Share this post Link to post Share on other sites
Hiero 5 Posted April 27, 2012 Finally ! Thanks a lot. Share this post Link to post Share on other sites
Erid 3 Posted April 27, 2012 Yeah, great news!, I don't know why, but this made me very happy, it always annoyed me having to use set. Share this post Link to post Share on other sites
malufett 70 Posted April 27, 2012 makes life more easy! thumbs up! Share this post Link to post Share on other sites
Lemongrass 264 Posted April 27, 2012 and now please run a small script to replace the code within the npc folder, that would be awesome! Share this post Link to post Share on other sites
Matheus 6 Posted April 27, 2012 That's a great news, congratulations ! Share this post Link to post Share on other sites
Zeromaru 0 Posted April 27, 2012 (edited) I think in line 1092 of script.c there is a mistake. Edited April 27, 2012 by Zeromaru Share this post Link to post Share on other sites
Epoque 147 Posted April 27, 2012 I think in line 1092 of script.c there is a mistake. You're correct good sir. Thanks for pointing that out, wouldn't have seen it otherwise. Share this post Link to post Share on other sites
Vianna 8 Posted April 27, 2012 You should keep the values returned by search_str("set"), search_str("callfunc") and search_str("getelementofarray") into global variables to avoid searching for them at every occurrence of assignment statements and user-defined function calls. Share this post Link to post Share on other sites
Epoque 147 Posted April 27, 2012 You should keep the values returned by search_str("set"), search_str("callfunc") and search_str("getelementofarray") into global variables to avoid searching for them at every occurrence of assignment statements and user-defined function calls. Indeed, this was something I brought up in the staff channel on IRC. I've been trying to collect a list of additional changes that need committing, and this is on the list. You have a keen eye, great minds think alike Share this post Link to post Share on other sites
xRaisen 8 Posted April 28, 2012 Thanks! that will make our lives more easier. P.S If you are not busy, try adding abs() also. So the unidentified groupranditem() will be reverted to its normal Ya know what has been broken down there. Share this post Link to post Share on other sites
Epoque 147 Posted April 29, 2012 Update It's important to note that r15998 appears to fix a long-standing issue that appears to have been present in rAthena for an extended period of time. For whatever reason, the instance variable storage system was not being initialised (thus instance variables were not being saved or recorded.) If anyone has any reports prior to r15998 of instance variables not working, please let me know. It baffled our team temporarily as to why this was the case in the source. Thanks. Share this post Link to post Share on other sites
Sneaky 47 Posted April 29, 2012 was looking forward to this, thanks <3 Love you, Love it! Share this post Link to post Share on other sites
Emistry 1,890 Posted April 29, 2012 Wow...this is nice...xD now Z3R0 wont be needed to worry of writing these in the scripts xD hahaha~ Share this post Link to post Share on other sites
rafoka 8 Posted April 30, 2012 Nice! I always enjoyed this new-old way of scripting (More Like-C) from that mod-released in the old ea. Good job ... Share this post Link to post Share on other sites
Ind 748 Posted August 2, 2012 the last known bug from this feature has been fixed in r16555. should you step by any bugs please step by our core bug tracker :3 thank you 5 Share this post Link to post Share on other sites
Swadon 4 Posted August 5, 2012 Great ! But how to call a function without using "callfunc", I have not found how to do it. It does not work like that : - script Test_Call_Function -1,{ OnInit: Test("Hello !"); end; } function script Test { announce getarg(0),bc_all; return; } Thank you for your help ! Share this post Link to post Share on other sites
Euphy 1,105 Posted August 5, 2012 @Swadon: The function needs to be loaded before it's called, so either move it before the script or place it in another script file altogether. 1 Share this post Link to post Share on other sites
Swadon 4 Posted August 5, 2012 Ooh, stupid error ! Thank you ! .. Share this post Link to post Share on other sites
Brian 583 Posted August 6, 2012 Test("Hello !"); To call functions like that, you have to define the function within the npc object, not as a separate object. There's an example in trunk/doc/script_commands.txt prontera,150,150,0 script TestNPC 123,{ function MyAdd; mes "Enter two numbers."; next; input [email protected]; input [email protected]; mes [email protected]+" + "[email protected]+" = "+MyAdd([email protected],[email protected]; close; function MyAdd { return getarg(0)+getarg(1); } } Share this post Link to post Share on other sites