Page 1 of 1
Callback.bsf
Posted: Mon Oct 01, 2012 7:44 am
by enric
How can I call a function from Callback.bsf, out of the file script?
// Callback used when a unit is killed
FUNCTION KILL_CALLBACK(id, side)
{
int x ;
int y ;
int i ;
int loaded ;
call_my_function();
…
Re: Callback.bsf
Posted: Mon Oct 01, 2012 12:33 pm
by rf900
If I understand correctly, you need to modify the callback.bsf file.
Either add your function on that file:
FUNCTION call_my_function()
{
}
Or include another bsf that has your function, at the top of callback file (cleanest way for future updates):
include "yourfile.BSF"
Re: Callback.bsf
Posted: Mon Oct 01, 2012 2:16 pm
by enric
Thanks rf900, but I would like to know how the system works calling functions. Which is the heiarchy.
If a put a functions on a file (as I already have) like e_functions.bsf and put an include to this file in the scenario.bsf, I can call functions in e_functions, from the scenario.bsf file.
But I cannot call those functions from Callback.bsf. Obviously, if I put my functions in the callback.file it will work (in fact this is how the scenario works right now).
In fact, all I want is to take several actions when a unit is killed, just need to know the id and side of the unit. This is just what the FUNCTION KILL_CALLBACK(id, side) does. So, there I would like to add a call to my function say call_my_func(id, side), so the specifics actions will be defined in my scenario files.
Re: Callback.bsf
Posted: Mon Oct 01, 2012 2:45 pm
by rf900
Haven't tested it, but maybe adding an include in $DEFAULT.BSF to your file with functions will allow those functions to be called from whatever script, also the callback one. Also I have read this in the STUBs doc, maybe adding your code there will let you call functions from anywhere...
If you create a CAMPAIGN.BSF script file, then it will enable you to have campaign-level logic which you can then deal with within your battles.
Re: Callback.bsf
Posted: Mon Oct 01, 2012 3:08 pm
by enric
I tried an include in $DEFAULT.BSF but did not work, to work you need to put the file in that folder (Data/battle/script).
I'll investigate the CAMPAIGN.BSF, thank you.
Re: Callback.bsf
Posted: Tue Oct 02, 2012 10:32 pm
by pipfromslitherine
I will check it out, but having a local campaign data/battle/script/$DEFAULT should work fine.
Cheers
Pip