Callback.bsf

Modders can post their questions on scripting and more.

Moderators: Slitherine Core, BA Moderators

Post Reply
enric
Brigadier-General - 8.8 cm Pak 43/41
Brigadier-General - 8.8 cm Pak 43/41
Posts: 1855
Joined: Sun May 15, 2011 8:47 am

Callback.bsf

Post 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();

rf900
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 339
Joined: Fri May 04, 2012 6:59 am

Re: Callback.bsf

Post 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"
enric
Brigadier-General - 8.8 cm Pak 43/41
Brigadier-General - 8.8 cm Pak 43/41
Posts: 1855
Joined: Sun May 15, 2011 8:47 am

Re: Callback.bsf

Post 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.
rf900
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 339
Joined: Fri May 04, 2012 6:59 am

Re: Callback.bsf

Post 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.
enric
Brigadier-General - 8.8 cm Pak 43/41
Brigadier-General - 8.8 cm Pak 43/41
Posts: 1855
Joined: Sun May 15, 2011 8:47 am

Re: Callback.bsf

Post 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.
pipfromslitherine
Site Admin
Site Admin
Posts: 9937
Joined: Wed Mar 23, 2005 10:35 pm

Re: Callback.bsf

Post by pipfromslitherine »

I will check it out, but having a local campaign data/battle/script/$DEFAULT should work fine.

Cheers

Pip
Post Reply

Return to “Battle Academy : Modders Corner ”