-
-
Save JonBons/a65b168042f9ee78ee20 to your computer and use it in GitHub Desktop.
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
| ///////// XML & CSV EXPORT | |
| ///////// Usage: [name,CfgPatches name] | |
| ///////// Usage: [name] to export bis stuff | |
| ///////// Usage: Paste everything below in the debug console and run it | |
| _CfgPatches = false; | |
| _configPath = ""; | |
| _collectionName = "test"; | |
| if(count [] > 1) then | |
| { | |
| _configPath = _configPath + _this select 1; | |
| _CfgPatches = true; | |
| }; | |
| _getClass = { | |
| _out = ""; | |
| if(typename _this == "STRING") then | |
| { | |
| _out = _this; | |
| } | |
| else | |
| { | |
| _out = configName _this; | |
| }; | |
| _out; | |
| }; | |
| _wepsEx = []; | |
| _itemsEx = []; | |
| _magsEx = []; | |
| _backEx = []; | |
| _weapons = []; | |
| _backpacks = []; | |
| _magazines = []; | |
| if(_CfgPatches) then | |
| { | |
| _weapons = _weapons + getArray(configfile >> "CfgPatches" >> _configPath >> "weapons"); | |
| _backpacks = _backpacks + getArray(configFile >> "CfgPatches" >> _configPath >> "units"); | |
| } | |
| else | |
| { | |
| _magazines = [configfile >> "CfgMagazines"] call BIS_fnc_returnChildren; | |
| _weapons = [configFile >> "CfgWeapons"] call BIS_fnc_returnChildren; | |
| _backpacks = [configFile >> "CfgVehicles"] call BIS_fnc_returnChildren; | |
| }; | |
| { | |
| _configName = _x call _getClass; | |
| _name = getText(configFile >> "CfgWeapons" >> _configName >> "displayname"); | |
| _picture = getText(configFile >> "CfgWeapons" >> _configName >> "picture"); | |
| if(_name != "" && _picture != "" && !(isClass (configFile >> "CfgWeapons" >> _configName >> "LinkedItems"))) then | |
| { | |
| _parents = [_x, true] call BIS_fnc_returnParents; | |
| _type = switch true do { | |
| case ((configname inheritsFrom (Configfile >> "CfgWeapons" >> _configName >> "ItemInfo")) == "InventoryOpticsItem_Base_F"): {"OpticAttachment"}; | |
| case ((configname inheritsFrom (Configfile >> "CfgWeapons" >> _configName >> "ItemInfo")) == "InventoryMuzzleItem_Base_F" || getText(configFile >> "CfgWeapons" >> _configName >> "ItemInfo" >> "muzzleend") != ""): {"MuzzleAttachment"}; | |
| case ((configname inheritsFrom (Configfile >> "CfgWeapons" >> _configName >> "ItemInfo")) == "InventoryFlashLightItem_Base_F"): {"SideAttachment"}; | |
| case ("Rifle" in _parents): {"PrimaryWeapon"}; | |
| case ("Pistol" in _parents): {"SecondaryWeapon"}; | |
| case ("Launcher" in _parents): {"Launcher"}; | |
| case ("H_HelmetB" in _parents): {"HeadGear"}; | |
| case ("Uniform_Base" in _parents): {"Uniform"}; | |
| case ("Vest_Camo_Base" in _parents || "Vest_NoCamo_Base" in _parents): {"Vest"}; | |
| case ("ItemCore" in _parents || "DetectorCore" in _parents): {"CommonItem"}; | |
| case ("ItemMap" in _parents): {"Map"}; | |
| case ("ItemWatch" in _parents): {"Watch"}; | |
| case ("ItemCompass" in _parents): {"Compass"}; | |
| case ("ItemGPS" in _parents): {"GPS"}; | |
| case ("ItemRadio" in _parents): {"Radio"}; | |
| case ("NVGoggles" in _parents || _configName == "NVGoggles"): {"NVGoggles"}; | |
| case ("Binocular" in _parents): {"Binocular"}; | |
| default {"unknown"}; | |
| }; | |
| if(_type == "unknown") exitWith {systemChat _configName}; | |
| _classname = _configName; | |
| _mags = getArray(configFile >> "CfgWeapons" >> _configName >> "magazines"); | |
| if(_CfgPatches) then | |
| { | |
| _magazines = _magazines + _mags; | |
| }; | |
| if(_type in ["PrimaryWeapon","SecondaryWeapon","Launcher"]) then | |
| { | |
| _mass = getNumber(configFile >> "CfgWeapons" >> _configName >> "WeaponSlotsInfo" >> "mass"); | |
| _capacity = 0; | |
| _wepsEx = _wepsEx + [[_name,_type,_classname,_mags,_mass]]; | |
| }; | |
| if(_type != "unknown" && !(_type in ["PrimaryWeapon","SecondaryWeapon","Launcher"]) ) then | |
| { | |
| _mass = getNumber(configFile >> "CfgWeapons" >> _configName >> "ItemInfo" >> "mass"); | |
| _capacity = getText(configFile >> "CfgWeapons" >> _configName >> "ItemInfo" >> "containerclass"); | |
| if(_capacity != "") then | |
| { | |
| _capacity = getNumber(configFile >> "CfgVehicles" >> _capacity >> "maximumload"); | |
| } | |
| else | |
| { | |
| _capacity = 0; | |
| }; | |
| _armor = switch (_type) do { | |
| case "HeadGear"; | |
| case "Vest": {getNumber(configFile >> "CfgWeapons" >> _configName >> "ItemInfo" >> "armor")}; | |
| case "Uniform": {getNumber(configFile >> "cfgVehicles" >> (getText(configFile >> "CfgWeapons" >> _configName >> "ItemInfo" >> "uniformclass")) >> "Hitpoints" >> "Hitbody" >> "armor")}; | |
| default {"N/A"}; | |
| }; | |
| _passthrough = switch (_type) do { | |
| case "HeadGear"; | |
| case "Vest": {getNumber(configFile >> "CfgWeapons" >> _configName >> "ItemInfo" >> "passthrough")}; | |
| case "Uniform": {getNumber(configFile >> "cfgVehicles" >> (getText(configFile >> "CfgWeapons" >> _configName >> "ItemInfo" >> "uniformclass")) >> "Hitpoints" >> "Hitbody" >> "passthrough")}; | |
| default {"N/A"}; | |
| }; | |
| _itemsEx = _itemsEx + [[_name,_type,_classname,_mass,_capacity,_armor,_passthrough]]; | |
| }; | |
| }; | |
| } foreach _weapons; | |
| { | |
| _configName = _x call _getClass; | |
| _name = getText(configFile >> "CfgMagazines" >> _configName >> "displayname"); | |
| _picture = getText(configFile >> "CfgMagazines" >> _configName >> "picture"); | |
| _mass = getNumber(configFile >> "CfgMagazines" >> _configName >> "mass"); | |
| if(_name != "" && _picture != "") then | |
| { | |
| _classname = _configName; | |
| _magsEx = _magsEx + [[_name,_classname,_mass]]; | |
| }; | |
| } foreach _magazines; | |
| { | |
| _configName = _x call _getClass; | |
| _parents = [(configFile >> "CfgVehicles" >> _configName), true] call BIS_fnc_returnParents; | |
| _name = getText(configFile >> "CfgVehicles" >> _configName >> "displayname"); | |
| _picture = getText(configFile >> "CfgVehicles" >> _configName >> "picture"); | |
| _mass = getNumber(configFile >> "CfgVehicles" >> _configName >> "mass"); | |
| _capacity = getNumber(configFile >> "CfgVehicles" >> _configName >> "maximumload"); | |
| if(_name != "" && _picture != "" && !(isClass (configFile >> "CfgVehicles" >> _configName >> "TransportItems")) && "Bag_Base" in _parents && _configName != "Bag_Base") then | |
| { | |
| _backEx = _backEx + [[_name,"bag",_configName,_mass,_capacity]]; | |
| }; | |
| } foreach _backpacks; | |
| diag_log "--- CONFIG DUMP CSV START ---"; | |
| diag_log text("name;type;class name;mass;capacity;armor;passthrough;mags"); | |
| { | |
| _name = _x select 0; | |
| _type = _x select 1; | |
| _classname = _x select 2; | |
| _magazines = _x select 3; | |
| _mass = _x select 4; | |
| diag_log text(format["%1;%2;%3;%4;%5;%6;%7;%8", _name,_type,_classname,_mass,"N/A","N/A","N/A",_magazines]); | |
| } forEach _wepsEx; | |
| { | |
| _name = _x select 0; | |
| _type = _x select 1; | |
| _classname = _x select 2; | |
| _mass = _x select 3; | |
| _capacity = _x select 4; | |
| _armor = _x select 5; | |
| _passthrough = _x select 6; | |
| diag_log text(format["%1;%2;%3;%4;%5;%6;%7;%8", _name,_type,_classname,_mass,_capacity,_armor,_passthrough]); | |
| } forEach _itemsEx; | |
| { | |
| _name = _x select 0; | |
| _type = _x select 1; | |
| _classname = _x select 2; | |
| _mass = _x select 3; | |
| _capacity = _x select 4; | |
| diag_log text(format["%1;%2;%3;%4;%5",_name,_type,_classname,_mass,_capacity]); | |
| } forEach _backEx; | |
| diag_log "--- CONFIG DUMP CSV END ---"; | |
| diag_log "--- CONFIG DUMP XML START ---"; | |
| _append = { | |
| diag_log text _this; | |
| }; | |
| '<?xml version="1.0" encoding="utf-8"?>' call _append; | |
| '<Collection>' call _append; | |
| ' <Name>'+_collectionName+'</Name>' call _append; | |
| ' <Weapons>' call _append; | |
| { | |
| _name = _x select 0; | |
| _type = _x select 1; | |
| _classname = _x select 2; | |
| _magazines = _x select 3; | |
| _mass = _x select 4; | |
| " <Weapon>" call _append; | |
| format [" <Name>%1</Name>",_name] call _append; | |
| format [" <ClassName>%1</ClassName>",_classname] call _append; | |
| format [" <WeaponType>%1</WeaponType>",_type] call _append; | |
| format [" <Mass>%1</Mass>",_mass] call _append; | |
| if(count _magazines > 0) then | |
| { | |
| " <Magazines>" call _append; | |
| { | |
| " <Magazine>" call _append; | |
| format[" <ClassName>%1</ClassName>",_x] call _append; | |
| " </Magazine>" call _append; | |
| } foreach _magazines; | |
| " </Magazines>" call _append; | |
| }; | |
| " </Weapon>" call _append; | |
| } foreach _wepsEx; | |
| ' </Weapons>' call _append; | |
| ' <Magazines>' call _append; | |
| { | |
| _name = _x select 0; | |
| _classname = _x select 1; | |
| _mass = _x select 2; | |
| " <Magazine>" call _append; | |
| format [" <Name>%1</Name>",_name] call _append; | |
| format [" <ClassName>%1</ClassName>",_classname] call _append; | |
| format [" <Mass>%1</Mass>",_mass] call _append; | |
| " </Magazine>" call _append; | |
| } foreach _magsEx; | |
| ' </Magazines>' call _append; | |
| ' <Items>' call _append; | |
| { | |
| _name = _x select 0; | |
| _type = _x select 1; | |
| _classname = _x select 2; | |
| _mass = _x select 3; | |
| _capacity = _x select 4; | |
| _armor = _x select 5; | |
| _passthrough = _x select 6; | |
| " <Item>" call _append; | |
| format [" <Name>%1</Name>",_name] call _append; | |
| format [" <ClassName>%1</ClassName>",_classname] call _append; | |
| format [" <ItemType>%1</ItemType>",_type] call _append; | |
| format [" <Mass>%1</Mass>",_mass] call _append; | |
| format [" <Capacity>%1</Capacity>",_capacity] call _append; | |
| format [" <Armor>%1</Armor>",_armor] call _append; | |
| format [" <Passthrough>%1</Passthrough>",_passthrough] call _append; | |
| " </Item>" call _append; | |
| } foreach _itemsEx; | |
| { | |
| _name = _x select 0; | |
| _type = _x select 1; | |
| _classname = _x select 2; | |
| _mass = _x select 3; | |
| _capacity = _x select 4; | |
| " <Item>" call _append; | |
| format [" <Name>%1</Name>",_name] call _append; | |
| format [" <ClassName>%1</ClassName>",_classname] call _append; | |
| format [" <ItemType>%1</ItemType>","Backpack"] call _append; | |
| format [" <Mass>%1</Mass>",_mass] call _append; | |
| format [" <Capacity>%1</Capacity>",_capacity] call _append; | |
| " </Item>" call _append; | |
| } foreach _backEx; | |
| ' </Items>' call _append; | |
| '</Collection>' call _append; | |
| diag_log "--- CONFIG DUMP XML END ---"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment