| 01-25-2007, 05:24 PM | #1 |
Hi all, I am trying to tidy up my Custom Script Code functions (expecially the heroes abilities) and so I wanted to move some functions from the core to blank triggers. Basically something like this: JASS:function Function takes nothing returns nothing endfunction //=========================================================================== function InitTrig_Trigger takes nothing returns nothing endfunction and then another trigger JASS:function Trig_Caller_Actions takes nothing returns nothing call Function( ) endfunction //=========================================================================== function InitTrig_Caller takes nothing returns nothing set gg_trg_Caller = CreateTrigger( ) call TriggerAddAction( gg_trg_Caller, function Trig_Caller_Actions ) endfunction However it doesn't work, because when I call the function Function in another trigger (which must be below the first trigger, right?), the WE gives me the "Expected a function name" error. It can be a newbie question, but can someone explain to me why the compiler can't find my function? Is there a better way to move functions from the Custom Script Core to another place? EDIT: viewing the Map Script, I saw that the trigger trigger Caller is written before the function Function and maybe this causes the error; this is strange because the trigger Caller which calls the dummy function is BELOW (I mean, its folder is below) the first trigger containing the function. |
| 01-25-2007, 06:08 PM | #2 |
WE arranges them based on the time they were created/enabled. You must use preprocessors (WEHelper/JASSHelper) so that they arrange the code the way you need it to be. |
| 01-25-2007, 06:29 PM | #3 | |
Quote:
What do you mean with "enabled"? Is there any way to enable/disable them so that they can be arranged without using a 3rd part program? Thanks. |
| 01-25-2007, 06:33 PM | #4 |
I am not sure exactly. What I do remember is that it is quite tedious to do it every time. |
| 01-25-2007, 06:48 PM | #5 |
becaus eof stuff like this, I wish you could prototype functions on JASS. You wouldn't have to worry about this stuff. |
| 01-25-2007, 06:59 PM | #6 |
Creating new triggers and then pasting the old code will do the job but it's very time consuming... For example I have a function that calls all the other functions and so I need to delete/replace it every time I make a new function... Isn't there any other way (apart from 3rd part programs)? Thanks. |
| 01-25-2007, 07:31 PM | #7 |
Prototyping is silly, if the function is defined anywhere and there's no REPL then it should just work. |
| 01-25-2007, 08:14 PM | #8 |
I like prototyping because I can plaster a lot of documentation there. |
| 01-25-2007, 09:45 PM | #9 |
| 01-25-2007, 10:05 PM | #10 | |
Quote:
Very useful answer. |
| 01-26-2007, 01:35 AM | #11 |
Functions that you want to call must be above the function you're calling it from. If you want to call a function anywhere, you have to use ExecuteFunc which works for functions which take no arguments and return nothing. It also runs the function in another thread. |
| 01-26-2007, 09:41 AM | #12 | |
Quote:
Actually I moved all my functions "prototyping" them (thanks to PipeDream for the word :) ), but every time I make a new function I have to retype a function to call them all (lol, seems LOTR). Thanks. |
| 01-26-2007, 05:31 PM | #13 |
... You can always use an struct and an static method (zomg 3rd party stuff stay away) like JASS:function something takes nothing returns nothing call BJDebugMsg(" 3 = "+I2S(whyastruct.waht(2,1))) endfunction struct whyastruct static method waht takes integer a, integer b returns integer return a+b endmethod endstruct |
