Last active
August 29, 2015 14:16
-
-
Save JonBons/65788094c3e2e52684f0 to your computer and use it in GitHub Desktop.
Script to automatically build compatibility configs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_vm = [] execVM "buildTranslationData.sqf"; | |
waitUntil {scriptDone _vm}; | |
//TODO LIST | |
/* | |
Soon: | |
Attempt to build CfgPatches entries for legacy mods | |
Build CfgMagazines based upon a list of all legacy magazines used in the below CfgWeapons array | |
Question: | |
Do we really want to support the Cows/Muzzle/Pointer slots? | |
How are those items built, etc (another translation table) | |
*/ | |
hint "STARTING EXPORT PROCESS, MAKE SURE YOU ARE RUNNING TAW CLIPBOARD MONITORING TOOL"; | |
copyToClipboard " "; | |
_weaponMagazineTable = []; | |
_weaponDependsTable = []; | |
_weaponTable = []; | |
// build weapon table | |
{ | |
_oldConfig = configFile >> "CfgWeapons" >> (_x select 0); | |
_newConfig = configFile >> "CfgWeapons" >> (_x select 1); | |
_data = []; | |
_data set [0, _x select 0]; // old classname | |
_data set [1, _x select 1]; // new classname | |
// handle new config dependancies | |
_parents = [_newConfig, true] call BIS_fnc_returnParents; | |
reverse _parents; // reverse so when we output the lowest base depend is first | |
_newDepends = []; | |
{ | |
if (toLower (_data select 0) != toLower _x) then { | |
_newDepends append [_x]; | |
// handle global depend tracking | |
if !(_x in _weaponDependsTable) then { | |
_weaponDependsTable append [_x]; | |
}; | |
}; | |
} forEach _parents; | |
_data set [2, _newDepends]; | |
// handle old config magazines[] array | |
_outMagazines = []; | |
_oldMagazines = getArray (_oldConfig >> "magazines"); | |
_newMagazines = getArray (_newConfig >> "magazines"); | |
{ | |
if !(_x in _newMagazines) then { | |
_outMagazines append [_x]; | |
// handle global magazine table | |
if !(_x in _weaponMagazineTable) then { | |
_weaponMagazineTable append [_x]; | |
}; | |
}; | |
} forEach _oldMagazines; | |
_data set [3, _outMagazines]; | |
// handle old config weapon slots data = WeaponSlotsInfo >> [CowsSlot, MuzzleSlot, PointerSlot] >> compatibleitems[] | |
_weaponSlotsInfo = []; | |
// cows slot data | |
_outCows = []; | |
_oldCows = getArray (_oldConfig >> "WeaponSlotsInfo" >> "CowsSlot" >> "compatibleitems"); | |
_newCows = getArray (_newConfig >> "WeaponSlotsInfo" >> "CowsSlot" >> "compatibleitems"); | |
{ | |
if !(_x in _newCows) then { | |
_outCows append [_x]; | |
}; | |
} forEach _oldCows; | |
_weaponSlotsInfo set [0, _outCows]; | |
// muzzle slot data | |
_outMuzzle = []; | |
_oldMuzzle = getArray (_oldConfig >> "WeaponSlotsInfo" >> "MuzzleSlot" >> "compatibleitems"); | |
_newMuzzle = getArray (_newConfig >> "WeaponSlotsInfo" >> "MuzzleSlot" >> "compatibleitems"); | |
{ | |
if !(_x in _newMuzzle) then { | |
_outMuzzle append [_x]; | |
}; | |
} forEach _oldMuzzle; | |
_weaponSlotsInfo set [1, _outMuzzle]; | |
// pointer slot data | |
_outPointer = []; | |
_oldPointer = getArray (_oldConfig >> "WeaponSlotsInfo" >> "PointerSlot" >> "compatibleitems"); | |
_newPointer = getArray (_newConfig >> "WeaponSlotsInfo" >> "PointerSlot" >> "compatibleitems"); | |
{ | |
if !(_x in _newPointer) then { | |
_outPointer append [_x]; | |
}; | |
} forEach _oldPointer; | |
_weaponSlotsInfo set [2, _outPointer]; | |
// save weapon slots data to main array | |
_data set [4, _weaponSlotsInfo]; | |
_weaponTable append [_data]; | |
} forEach weaponTranslationTable; | |
// OUTPUT CFGWEAPONS | |
copyToClipboard "TAW::class CfgWeapons\n{"; | |
sleep 0.01; | |
// OUTPUT WEAPON DEPEND DATA | |
{ | |
_config = configFile >> "CfgWeapons" >> _x; | |
_out = format ["TAW::\tclass %1", _x]; | |
_parents = [_config, true] call BIS_fnc_returnParents; | |
if (count _parents > 2) then { | |
_out = _out + format [": %1 {}", _parents select 1]; | |
}; | |
_out = _out + ";"; | |
//diag_log _out; | |
copyToClipboard _out; | |
sleep 0.01; | |
} forEach _weaponDependsTable; | |
hint format["FINISHED EXPORTING %1 BASE WEAPON ENTRIES", count _weaponDependsTable]; | |
// OUTPUT WEAPON DATA | |
_buildSlotString = { | |
_out = ""; | |
if (count _this > 0) then { | |
_entryArray = toArray (format ["%1", _this]); | |
for "_i" from 1 to (count _entryArray - 2) do { | |
_out = _out + toString [_entryArray select _i]; | |
}; | |
}; | |
_out | |
}; | |
{ | |
_out = format ["TAW::\tclass %1: %2 { \n\t\tscope = 1;\n", _x select 0, _x select 1]; | |
// magazines | |
if (count (_x select 3) > 0) then { | |
_mags = ""; | |
_magArray = toArray (format ["%1", (_x select 3)]); | |
for "_i" from 1 to (count _magArray - 2) do { | |
_mags = _mags + toString [_magArray select _i]; | |
}; | |
_out = _out + format ["\t\tmagazines[] += {%1};\n", _mags]; | |
}; | |
// weapon slots info >> cows slot | |
_slotsArray = _x select 4; | |
_slotsClass = (count (_slotsArray select 0)) + (count (_slotsArray select 1)) + (count (_slotsArray select 2)); | |
if (_slotsClass > 0) then { | |
_out = _out + "\t\tclass WeaponSlotsInfo {\n"; | |
// cow slots | |
if (count (_slotsArray select 0) > 0) then { | |
_out = _out + format ["\t\t\tclass CowsSlot { compatibleitems[] += {%1}; };\n", (_slotsArray select 0) call _buildSlotString]; | |
}; | |
// muzzle slots | |
if (count (_slotsArray select 1) > 0) then { | |
_out = _out + format ["\t\t\tclass MuzzleSlot { compatibleitems[] += {%1}; };\n", (_slotsArray select 1) call _buildSlotString]; | |
}; | |
// muzzle slots | |
if (count (_slotsArray select 2) > 0) then { | |
_out = _out + format ["\t\t\tclass PointerSlot { compatibleitems[] += {%1}; };\n", (_slotsArray select 2) call _buildSlotString]; | |
}; | |
_out = _out + "\t\t};\n"; | |
}; | |
_out = _out + "\t};"; | |
//diag_log _out; | |
copyToClipboard _out; | |
sleep 0.01; | |
} forEach _weaponTable; | |
hint format["FINISHED EXPORTING %1 WEAPON ENTRIES", count _weaponTable]; | |
// FINISH OUTPUT CFGWEAPONS | |
copyToClipboard "TAW::};\n"; | |
sleep 0.01; | |
copyToClipboard format["TAW::\nMagazinesToHandle = %1", _weaponMagazineTable]; | |
sleep 0.01; | |
sleep 3; | |
hint "FINISHED EXPORTING CONFIG DATA" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment