| 07-03-2006, 08:28 AM | #1 |
From what I can tell, the WorldEdit JASS parser doesn't want to share functions between triggers. Now, I know I can stick what I need into the Custom Script code section (or do all the JASS externally) - but for convenience I'd really like to be able to group common functions together by trigger, and be able to call those functions from other triggers. Is there any way around this? |
| 07-03-2006, 08:31 AM | #2 |
Not what i know of, the stupid WE parser dosent declare functions inside of a trigger when its parsing. So it will always say Expected a name, meaning the function could not be found. The only way to declare it would be to put it in your Custom Code section to parse. |
| 07-03-2006, 08:38 AM | #3 |
Meh, alright, thanks :'( |
| 07-03-2006, 09:23 AM | #4 |
You can use functions between triggers. The only trick is that the called function must come before the calling function. You just have to know in what order does the editor compile the triggers when saving. That is the order in which the editor has the triggers in it's memory, apparently. When you load a map, and then save it, the triggers will be added to the JASS script in the order they appear in the editor; however, any trigger you add after you load the map, will be added to the script at the end when saving, even if you put it in the top of the trigger list. If you do so, however, then the next time you load the map, that trigger will be put to the script first when saving again, which can cause problems again if that trigger calls any functions from other triggers. |
| 07-03-2006, 09:51 AM | #5 |
Hmm, well here's the symptom's I'm running up against after a save/reload of WE: Ok, so I have this trigger: (this is what the error dialog shows), Announce() and LocIntro() are missing. JASS://*************************************************************************** //* //* Global Variables //* //*************************************************************************** globals ... endglobals function InitGlobals takes nothing returns nothing endfunction function Trig_Game_Start_Actions takes nothing returns nothing call Announce(LocIntro()) endfunction //=========================================================================== function InitTrig_Game_Start takes nothing returns nothing set gg_trg_Game_Start = CreateTrigger( ) call TriggerAddAction( gg_trg_Game_Start, function Trig_Game_Start_Actions ) endfunction However, the missing functions are defined in a trigger that's up at the top of my trigger list. And even looking at the *full* JASS code for the map (causing a syntax error, without that offending line) shows that those functions are defined prior to their usage in that trigger. Seems to me that the parser is just appending my trigger onto the end of the initglobals stuff, rather than parsing everything together - am I doing something wrong here? |
| 07-03-2006, 10:03 AM | #6 |
Is your trigger set to run at map initialization? Maybe that's what pushes it up in the script, I don't know, just a guess. |
| 07-03-2006, 10:07 AM | #7 |
Good call! Yeah, that was checked on - I had to save and reload the map, but after that things are golden - thanks |
| 07-03-2006, 12:29 PM | #8 |
Download 1trigadd from wc3jass, allows you to add a trigger's code before all triggers. |
| 07-03-2006, 12:56 PM | #9 |
When you enable a trigger after disabling it, the stupid WE parser will ignore the rest of the triggers when parsing that one. |
