Jump to content
Sign in to follow this  
Sekra

Question about config inheritances...

Recommended Posts

So... I'm making a "mission" that needs the information of all the loaded addons configs, their faction and side also.. I faced a problem when trying to load all the faction information from the configfiles, and that is some lazy addonmaker just added the factoin used as a guerilla faction in CfgFactionClasses, then later just added the same units to Opfor side with inheritance and using only: side == 0; in the unit Cfg.. So naturally when I try to access the "faction" that is in side 0, I cannot access the class and displayname like explained the comments here:

http://community.bistudio.com/wiki/count_config

so my question is.. does anyone have a way to circumvent this somehow? obviously BIS does since it works in the editor and it loads the factions in the editor. The code I'm currently using looks like this:

error in old code, new code under...

basically what it needs is a way to detect if the faction is "inherited" and a way to track down all the way to the parent class to get the class and displayname... right now it adds "","" in the place where that custom addon faction should be that uses inheritance... I will continue to experiment with this but if anyone allready has a solution for this I'm listening :confused:

---------- Post added at 01:56 PM ---------- Previous post was at 01:48 PM ----------

Looks like it allready had a small flaw with the original code with the _faction + 1 thingy.. so the new code looks like this but now it will not even add the empty entry to the opfor side.. But like I've said, BIS is obviously doing this differently in the editor since it will show that "faction" in opfor and guerilla sides even though in the addon it has only a guerilla CfgFactionClasses entry and the units themselves have just a:

class EUnit : Unit {
   side = 0;
};

SEKRA_spawn_sides = ["Opfor", "Blufor", "Resistance", "Civilian"];

_sides = count SEKRA_spawn_sides;
_i = 0;

while {_i < _sides} do
{
call compile format["SEKRA_spawn_faction_%1 = [];", _i];

_cfg = configFile >> "CfgFactionClasses";
_factions = count (configFile >> "CfgFactionClasses");
_j = 1;

while {_j < _factions} do 
{
	call compile format["if(getnumber (_cfg select %1 >> ""side"") == %2) then { _index = count SEKRA_spawn_faction_%2; SEKRA_spawn_faction_%2 set [_index, [(getText (_cfg select %1 >> ""displayName"")), (configName(_cfg select %1))]]; };", _j, _i];
	_j = _j + 1;
};

_i = _i + 1;
};

Share this post


Link to post
Share on other sites

Actually... I came to the conclusion that there is little I can do in my script to circumvent this unless the custom addonmaker "fixes" his config to properly introduce the factions his units use. For the record if any of you browsing this post makes attempts on doing addons, declare all the factions your units use under the CfgFactionClasses, even if only to have:

class EFaction : Faction {
   side = TEast;
};

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  

×