halex1316 3 Posted December 25, 2017 Hi, I've taken to reading through a lot of the BI Wiki to learn ArmA scripting, but this example here is eluding my understanding. ___ _cfgArray = "( (getNumber (_x >> 'scope') >= 2) && {getText (_x >> 'vehicleClass') in ['WeaponsPrimary','weaponsSecondary','weaponsHandGuns'] && {_lootArray pushBack ( configName _x ); true} } )" configClasses (configFile >> "CfgVehicles"); So, to clarify what I do understand : scope is pulling the value of scope under the various CfgVehicles. Why it is important to pull this number, I am not sure, because it doesn't look like the value from the first use of getNumber is being used. vehicleClass refers to the thing itself. Like a classname for an object or vehicle (I think). But where it makes the clarification that it is looking "in ['WeaponsPrimary','weaponsSecondary','WeaponsHandGuns'] I do not understand. I've done a lot of searching and I cannot find references to these things anywhere. It doesn't look like it is listed in the config of any gun listed in CfgVehicles. Can anyone explain to me what is happening here while putting together the _cfgArray? Thank you! Share this post Link to post Share on other sites
pierremgi 4890 Posted December 25, 2017 As you, i can understand scope from 0 to 2 as explained here. Scope 3 or more ??? The vehicleClass like "weaponsPrimary" is for edited weapons (empty vehicle placed in editor, weapons list), or spawned like vehicles; If you place an AK-12 on the ground, right click "find in config viewer) configfile >> "CfgVehicles" >> "Weapon_arifle_AK12_F" then vehicleClass = "WeaponsPrimary"; Interesting way to spawn weapons through cfgVehicles classes (createVehicle) instead of creating a weaponHolder then add a weapon from cfgWeapons. But the weapon holder takes an advantage if you spawn some magazines along with the weapon. 1 Share this post Link to post Share on other sites
halex1316 3 Posted December 25, 2017 Oh, okay. I see that now. So in theory, I could replace "WeaponsPrimary" with "Car", let's say, if I wanted to pull an array of everything that matched that vehicleClass? Thank you for your response! Share this post Link to post Share on other sites
pierremgi 4890 Posted December 25, 2017 Yes "car" is working as vehicleClass. Equivalent to some filter like: _x isKindOf "car". Share this post Link to post Share on other sites
Larrow 2822 Posted December 25, 2017 2 hours ago, halex1316 said: Why it is important to pull this number, I am not sure, because it doesn't look like the value from the first use of getNumber is being used. All spawnable items come from CfgVehicles or CfgNonAIVehicles (for things like Triggers). Scope refers to if the config item is... 0 - Used as base class for inheritance 1 - Spawnable but does not appear in editor categories 2 - Spawnable and appears in editor categories 2 hours ago, halex1316 said: vehicleClass refers to the thing itself. Like a classname for an object or vehicle (I think). VehicleClass holds a reference to the Editor category of which the item is to appear under, and was used for the old editor in the 'Insert unit' dialog for the 'class' dropdown. The text which VehicleClass holds relates to another class in CfgVehicleClasses eg CfgVehicleClasses >> "WeaponsPrimary" which holds the displayName for the 'Insert Unit' class dropdown that the item should be listed under e.g getText( CfgVehicleClasses >> "WeaponsPrimary" >> "displayName" ) == "Weapons (Primary)" This has mainly been replaced for Eden with the members "editorCategory" and "editorSubcategory" which can be found in "CfgEditorCategories" and "CfgEditorSubcategories" respectively. e.g The code could be replaced with _cfgArray = "( (getNumber (_x >> 'scope') >= 2) && {getText (_x >> 'editorSubCategory') in ['EdSubcat_AssaultRifles','EdSubcat_MachineGuns','EdSubcat_SubMachineGuns','EdSubcat_SniperRifles','EdSubcat_Launchers','EdSubcat_Pistols'] && {_lootArray pushBack ( configName _x ); true} } )" configClasses (configFile >> "CfgVehicles"); So either of the codes are basically saying make an array of item configs(_cfgArray) and place their configName(type name to spawn in _lootArray) from all the classes in CfgVehicles that are spawnable and belong to the editor categories of #WEAPONS#. 1 Share this post Link to post Share on other sites
halex1316 3 Posted December 25, 2017 Hmm... So I'm looking in the Editor Config Viewer now, and I see that CfgEditorSubcategories (for example) provides a list of things that I would see in the eden editor (duh!). Is there a way to find a list of these things in the ConfigViewer? So, I realize I can look at the editor and see all of the different Sniper and Marksmen Rifles (for example). When I'm using EdSubcat_SniperRIfles, other than looking in the editor, how do I know what this is referring to? Or is it just as simple as looking at the editor? Thanks! Your explanation helped a lot. Still trying to figure this stuff out. Edit: I see now - the weapon itself, "Weapon_srifle_DMR_03_F" has a value in its config called editorSubcategory = "EdSubcat_SniperRifles"; I think it's really cool that it's possible to build arrays of objects by referring to these shared parameters. Share this post Link to post Share on other sites
Larrow 2822 Posted December 25, 2017 5 minutes ago, halex1316 said: how do I know what this is referring to? Or is it just as simple as looking at the editor? To decompile this backwards to get a common name (display name) of what a category holds you can either look at the Assets panel in the editor or compile a list by code. e.g TAG_fnc_findItemsOfCategory = { params[ "_cat" ]; _items = ""; { _items = format [ "%1\n%2", _items, getText( _x >> "displayName" ) ]; }forEach ( format [ " getNumber (_x >> 'scope') >= 2 && { getText (_x >> 'editorSubCategory') == '%1' } ", _cat ] configClasses (configFile >> "CfgVehicles") ); _items }; hint ( "EdSubcat_SniperRifles" call TAG_fnc_findItemsOfCategory ); Would hint back to you, by name (e.g what its display name in the editor asset panel is) a list of items that are spawnable and belong to EdSubcat_SniperRifles. Just change the category sent to the function to find out what items it would actually return. Share this post Link to post Share on other sites
halex1316 3 Posted December 25, 2017 If you wouldn't mind humoring my questions a little longer - so I see the magic variable _x . In this case, is it referring to (configFile >> "CfgVehicles") so that, in the line where we are formatting _items, it would actually read: _items = format [ "%1\n%2", _items, getText(configFile >> "CfgVehicles" >> "displayName" ) ]; ? The only use of _x I'm familiar with is, for example: {_x additem "map"} forEach playableUnits How is it applying in this case? I'm getting lost in all of the nested items haha! Share this post Link to post Share on other sites
Larrow 2822 Posted December 25, 2017 In.. " getNumber (_x >> 'scope') >= 2 && { getText (_x >> 'editorSubCategory') == '%1' } ", _cat ] configClasses (configFile >> "CfgVehicles") _x refers to the current classes under CfgVehicles being checked. .eg ConfigFile >> "CfgVehicles" >> "someClass" So it first looks at getNumber ( ConfigFile >> "CfgVehicles" >> "someClass" >> "scope" ) then getText(ConfigFile >> "CfgVehicles" >> "someClass" >> "editorSubCategory") The configClasses command builds an array of config paths that match (scope >= 2 and editorSubCategory == "EdSubcat_SniperRifles") so you would end up with an array looking like this.. [ bin\config.bin/CfgVehicles/Weapon_srifle_EBR_F, bin\config.bin/CfgVehicles/Weapon_srifle_GM6_F, bin\config.bin/CfgVehicles/Weapon_srifle_LRR_F, bin\config.bin/CfgVehicles/Weapon_srifle_DMR_01_F, bin\config.bin/CfgVehicles/Weapon_srifle_GM6_camo_F, bin\config.bin/CfgVehicles/Weapon_srifle_LRR_camo_F, bin\config.bin/CfgVehicles/Weapon_srifle_DMR_02_F, bin\config.bin/CfgVehicles/Weapon_srifle_DMR_02_camo_F, bin\config.bin/CfgVehicles/Weapon_srifle_DMR_02_sniper_F, bin\config.bin/CfgVehicles/Weapon_srifle_DMR_03_F, bin\config.bin/CfgVehicles/Weapon_srifle_DMR_03_khaki_F, bin\config.bin/CfgVehicles/Weapon_srifle_DMR_03_tan_F, bin\config.bin/CfgVehicles/Weapon_srifle_DMR_03_multicam_F, bin\config.bin/CfgVehicles/Weapon_srifle_DMR_03_woodland_F, bin\config.bin/CfgVehicles/Weapon_srifle_DMR_04_F, bin\config.bin/CfgVehicles/Weapon_srifle_DMR_04_Tan_F, bin\config.bin/CfgVehicles/Weapon_srifle_DMR_05_blk_F, bin\config.bin/CfgVehicles/Weapon_srifle_DMR_05_hex_F, bin\config.bin/CfgVehicles/Weapon_srifle_DMR_05_tan_f, bin\config.bin/CfgVehicles/Weapon_srifle_DMR_06_camo_F, bin\config.bin/CfgVehicles/Weapon_srifle_DMR_06_olive_F, bin\config.bin/CfgVehicles/Weapon_srifle_DMR_07_blk_F, bin\config.bin/CfgVehicles/Weapon_srifle_DMR_07_hex_F, bin\config.bin/CfgVehicles/Weapon_srifle_DMR_07_ghex_F, bin\config.bin/CfgVehicles/Weapon_srifle_LRR_tna_F, bin\config.bin/CfgVehicles/Weapon_srifle_GM6_ghex_F ] Where each entry is of type CONFIG a data type holding an address to a config class. For instance... bin\config.bin/CfgVehicles/Weapon_srifle_EBR_F is a CONFIG data type representing.. configFile >> "CfgVehicles" >> "Weapon_srifle_EBR_F" The top forEach then goes through each of these CONFIGs in the array.. { _items = format [ "%1\n%2", _items, getText( _x >> "displayName" ) ]; }forEach (config addresses passed from configClasses commmand) So here each _x represents the address so the first would be.. getText( configFile >> "CfgVehicles" >> "Weapon_srifle_EBR_F" >> "displayName" ) and I have just used the format command to add the text to the previous after adding a new line (\n). Share this post Link to post Share on other sites
halex1316 3 Posted December 25, 2017 Okay, that explanation helps a lot! Thank you. If something has a scope of 2, being spawnable (and as I'm understanding this, it means it can be placed on the map in the editor, that being different from being placed into the inventory of a unit), that means the same classname ("Weapon_srifle_EBR_F") cannot be placed directly into the inventory of a unit? Instead, it seems I would need to truncate the classname and use just "srifle_EBR_F"? Or can the "Weapon_srifle_EBR_F" be used in both cases - being spawend on the ground, and added to the inventory? I guess I'm wondering if I would need to do this twice, and find two different arrays of weapons to do both of these things (spawning on the ground + adding to inventory). Or can both things be done with the one array we've (you've) created lol. Share this post Link to post Share on other sites
pierremgi 4890 Posted December 25, 2017 46 minutes ago, halex1316 said: Okay, that explanation helps a lot! Thank you. If something has a scope of 2, being spawnable (and as I'm understanding this, it means it can be placed on the map in the editor, that being different from being placed into the inventory of a unit), that means the same classname ("Weapon_srifle_EBR_F") cannot be placed directly into the inventory of a unit? Instead, it seems I would need to truncate the classname and use just "srifle_EBR_F"? Or can the "Weapon_srifle_EBR_F" be used in both cases - being spawend on the ground, and added to the inventory? I guess I'm wondering if I would need to do this twice, and find two different arrays of weapons to do both of these things (spawning on the ground + adding to inventory). Or can both things be done with the one array we've (you've) created lol. You should consider cfgVehicles and "WeaponsPrimary" for spawning weapons on ground (in a weapon holder in fact). Classname "Weapon_srifle_EBR_F", and cfgWeapons for using all commands /functions modifying units/cargo inventory, with expected className: "srifle_EBR_F". You can truncate the string but I'm not sure this will work for mods as well. Anyway, I prefer using the cfgWeapons class inside a created weapon holder (vehicle) in which I can also spawn some extra magazines. If you work with magazines cfgWeapons is fine. 1 Share this post Link to post Share on other sites
Larrow 2822 Posted December 25, 2017 3 hours ago, halex1316 said: that means the same classname ("Weapon_srifle_EBR_F") cannot be placed directly into the inventory of a unit? Correct. 2 hours ago, pierremgi said: Instead, it seems I would need to truncate the classname and use just "srifle_EBR_F"? I would not rely on the truncated name being correct. 2 hours ago, pierremgi said: Or can the "Weapon_srifle_EBR_F" be used in both cases - being spawend on the ground, and added to the inventory? No. 3 hours ago, halex1316 said: Or can both things be done with the one array we've (you've) created lol. Look in the CfgVehicles class for "Weapon_srifle_EBR_F" you will see three sub classes called "TransportItems" "TransportWeapons" and "TransportMagazines" these will hold the item class names for any items, weapons and magazines the CfgVehicle class spawns. You will see under "Weapons_srifle_EBR_F" >> "TransportWeapons" the item "srifle_EBR_F" which is the "CfgWeapons" classname of the rifle, that you would use to add it to a crate, inventory etc. Ill leave you to figure out how to retrieve this from the knowledge you have gained in this thread. Always welcome to reply later if you are still struggling. Share this post Link to post Share on other sites
pierremgi 4890 Posted December 25, 2017 I'm not sure I asked all these questions. This topic seems clear for me. As I said, I'm using cfgWeapons. There is no (or small) added value to play with the tokens of a cfgVehicles for a weapon. Share this post Link to post Share on other sites
halex1316 3 Posted December 25, 2017 I don't think he was suggesting you didn't understand. He quoted me in your message, so it tagged you in them. Not everyone is clear on the topic though, so more responses never hurt. Thank you Larrow! Share this post Link to post Share on other sites
Larrow 2822 Posted December 26, 2017 11 hours ago, pierremgi said: I'm not sure I asked all these questions. Oops yes I may have inadvertently quoted @halex1316 from your quote @pierremgi. 11 hours ago, pierremgi said: This topic seems clear for me. As I said, I'm using cfgWeapons. There is no (or small) added value to play with the tokens of a cfgVehicles for a weapon. No there is not particularly, but that was not the overall topic of the thread. It was from the original question of 'Understanding References Made to ConfigFile' and is what I continued to show, what the original members provided referred to, where they came from and what further information you could attain from them. I never said CfgWeapons wouldn't be a better option but if @halex1316 wanted to make a list of CfgVehicle weapons that he could spawn, without having to worry about weapon holders and weapons separately and then from that list also attain a list of CfgWeapon configs that where spawned, then job done. Share this post Link to post Share on other sites
pierremgi 4890 Posted December 26, 2017 7 hours ago, Larrow said: Oops yes I may have inadvertently quoted @halex1316 from your quote @pierremgi. No there is not particularly, but that was not the overall topic of the thread. It was from the original question of 'Understanding References Made to ConfigFile' and is what I continued to show, what the original members provided referred to, where they came from and what further information you could attain from them. I never said CfgWeapons wouldn't be a better option but if @halex1316 wanted to make a list of CfgVehicle weapons that he could spawn, without having to worry about weapon holders and weapons separately and then from that list also attain a list of CfgWeapon configs that where spawned, then job done. Totally agree with that. I assume I said it's better to use cfgWeapons instead of cfgVehicles for weapons. The forum allows some personal opinion also. I think both ideas are useful. You digged far in cfgVehicles tokens, I emitted an advice on the difference between the configs, not really out of scope here. What else? Share this post Link to post Share on other sites