HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Transfering Functions - JASS Help

01-25-2007, 05:24 PM#1
StockBreak
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:

Collapse JASS:
function Function takes nothing returns nothing
endfunction

//===========================================================================
function InitTrig_Trigger takes nothing returns nothing
endfunction

and then another trigger

Collapse 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
shadow1500
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
StockBreak
Quote:
Originally Posted by shadow1500
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.
Thank you very much.
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
shadow1500
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
Alevice
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
StockBreak
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
PipeDream
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
Alevice
I like prototyping because I can plaster a lot of documentation there.
01-25-2007, 09:45 PM#9
Mapz_Maker
IT IS 3rd Party programs NOT 3rd part programs!!
01-25-2007, 10:05 PM#10
StockBreak
Quote:
Originally Posted by Mapz_Maker
IT IS 3rd Party programs NOT 3rd part programs!!
...
Very useful answer.
01-26-2007, 01:35 AM#11
wyrmlord
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
StockBreak
Quote:
Originally Posted by wyrmlord
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.
Yes, I have read a Blade's tutorial about the ExecuteFunc, but I have many functions taking and returning something. Anyway, with ExecuteFunc, can I call a function anywhere on my script even if this function is not above the caller?
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
Vexorian
...

You can always use an struct and an static method (zomg 3rd party stuff stay away)

like

Collapse 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