Jump to content
Sign in to follow this  
Crackbone

BI Studio Preprocessor

Recommended Posts

Is it possible *conditionally* include portions of files if a file is present with commands for the preprocessor?

For example, suppose that definitions for vehicles in the file rebelvehicles.hpp were included *only* if the file rebelvehicles.pbo were present?

I've tinkered with this. I've tried to include files with #ifdef after having first expressed '#define REBEL_VEHICLES_PRESENT 1' in config.cpp for rebelvehicles.pbo, but definitions are local to the files where they're defined.

I'm sure that this is somehow possible, and it would be greatly helpful if anyone explains how.

Thanks

Share this post


Link to post
Share on other sites

I think UNN has done work on this sort of thing, though I'm not sure if he came up with a solution or not.

One little trick that may (or may not) be helpful is that you can include ofp scripting commands in a config. I think they can only be used in a #define, but I don't know that for sure (and would like the truth on it).

In my HS command system, I use the 'camcreate' command to detect if a particular sound addon is installed. If I can camcreate a game logic (defined in the sound addon), then it is installed; otherwise, no error message is displayed. This is all done in scripts of course, but since you can put some script commands in a config, this might lead to something.

Basically, the detection function looks like this:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">private ["_detector", "_return"];

_return = false;

_detector = "GENB_HS_sounds_english" camcreate [0,0,0];

if(_detector == _detector) then {_return = true; deletevehicle _detector;};

_return

It will return 'true' if the addon where "GENB_HS_sounds_english" is configged in is installed, or 'false' otherwise.

SO.....

I don't know all of the commands that can go in a config, but I don't think there is any type of conditional, other than 'ifdef'. But if there is some way to make 'ifdef' true or false depending on scripting code, then you are set.

Maybe you could return an empty string in the function above if it isn't installed? Something like this:

#define addon_installed loadfile "blah\addon_check.sqf"

#ifdef addon_installed ...

Another idea might be to actually return the config from the OFP scripting function. So basically, your function checks if the other addon is installed (as above), and if it is, then it uses "loadfile" to return some config file from that addon.

...or, maybe return a piece of config that has a #define in it, and then use the #ifdef in the first addon's config. So basically, if the second addon is installed, then it will return a string that makes a #define. If the second addon isn't installed, then an empty string will be returned. Either way the string is used in the first addon's config.

Hope that made sense, and let me know if it might/could/does work. smile_o.gif

Share this post


Link to post
Share on other sites

You can prevent addons being displayed in the mission editor, if another addon is not installed. But this is only checked when you first launch the editor and the addon you want to check has to use a stringtable. There is an old post here:

http://www.flashpoint1985.com/cgi-bin....t=47527

If you want to detect the presence of an addon during a mission, use the methods General Baron mentioned, or global variables e.t.c

Share this post


Link to post
Share on other sites

Aha. Yes. This will work, I'm sure. I'll tinker with it to find if it's possible to exclude portions of the definition in config.cpp for add-ons *without* the file stringTable.csv (such as JAM).

Thanks much for the help.

Share this post


Link to post
Share on other sites
Quote[/b] ]Aha. Yes. This will work, I'm sure. I'll tinker with it to find if it's possible to exclude portions of the definition in config.cpp for add-ons *without* the file stringTable.csv (such as JAM).

Good luck, I've spent a fair few hours trying to find an alternative to stringtables. Mainly because most addons don't use them.

If the likes of JAM e.t.c just added a simple string table, with just say a version number or something, it would make life a lot easier.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×