Jump to content
Sign in to follow this  
dreadedentity

Help understanding the config file

Recommended Posts

I'm making a small script that will allow you to spawn units, so I may have had a peek under the hood at Iceman77's vSys. I think I've isolated the lines that I need to understand to make this happen.

_cfg = configFile >> "cfgVehicles";
_sidePlayer = getNumber (_cfg >> typeOf player >> "side");

What exactly do these lines do?

Also, could someone please explain these commands and how to use them: config >> name, configClasses, configName, configFile, inheritsFrom

Share this post


Link to post
Share on other sites

Well my best understanding(or guess :p ) of them is:

Line 1: Calling into the configFile which contains the subconfig of "cfgVehicles" (where all the units/empty vehicle classnames are)

Line 2: Getting the side of the player via finding the config number entry based on the player's unit classname.

config >> name: is basically defining the "directory" that you want to use from the config

configClasses: looks like it is used to comb through the config file based on a certain set of criteria/conditions and storing those classes/classnames in an array.

configName: just returns the name of the particular config file.

configFile: is the file that all the other sub-configs are located (i.e. Vehicles/Faces/etc.) (You could look at is as the C Drive on your computer, the starting point of any directory call)

inheritsFrom: the example given on that page seems to say get the "Car" from the config, and then defines the sub-config from which it comes from, under the overall config of "CfgVehicles", so if "Car" was replaced with "Plane" for example the return would be "AirVehicles" (or something similar)

Edited by JShock

Share this post


Link to post
Share on other sites
Thanks, JShock.

Do you know if there's a page like this for the Arma 3 CfgVehicles? I've looked all over, but can't find it.

Remember Arma 3 included that stuff within the vanilla editor, I believe it is the "gear" looking symbol at the top of the editor.

Share this post


Link to post
Share on other sites

*WARNING* incoming wall of text alert

Hope it helps, been typing this up for about an hour so most likely plenty of other replies have happened in the mean time.

The configFile stores all the games classes in a hierarchical format, each class can then have key/value pairs which can be STRINGS, NUMBERS, ARRAYS.

There are also two other config files called campaignConfigFile and missionConfigFile whcih are your campaign and mission Description.ext.

 

class myClass {

	class myChildClass {

		myString = "1st Child";
		myNumber = 2;
		myArray[] = {"Bob", "Betty", "Sue"};

	};

	class mySecondChildClass {

		myString = "2nd Child";
		myNumber = 3;
		myArray[] = {"Bob", "Betty", "Sue"};

	};

	myString = "Parent";
	myNumber = 1;
	myArray[] = {"David", "Kate", "Steve"};

};
As you can not alter the configFile without making an addon, make a quick mission (just a player) paste the above in a description.ext in the missions folder, save the mission and press preview.

Press Esc and open the config viewer (button "CONFIG")) and hit backspace unitl the left hand list just shows the three configs (configFile, campaignConfigFile and missionConfigFile).

If you now expand missionConfigFile you will see myClass, expand myClass and you will see the two child classes we made. Clicking on any of the classes will show all their KV pairs in the right window.

Go back to the debugConsole and in one of the watch lines type each one of the following in turn.

missionConfigFile 
You will see it displays the path to your missions description.ext

 

configName (missionConfigFile >> "myClass")
Displays the class name of myClass being "myClass"

 

getText (missionConfigFile >> "myClass" >> "myString")
Displays "Parent"

 

getNumber (missionConfigFile >> "myClass" >> "myNumber")
Displays 1

 

getArray (missionConfigFile >> "myClass" >> "myArray")
Displays ["David", "Kate", "Steve"]

Thats the basics of getting info out of a config file.

 

count (missionConfigFile >> "myClass")
Displays 5, the two child classes and the three KV pairs.

 

configName ((missionConfigFile >> "myClass") select 0)
Displays "myChildClass"

What is select 3? By looking at our description.ext we know its a KV pair, its a not a class, it is a number.

isClass ((missionConfigFile >> "myClass") select 3)
Displays false

Reaching further down the tree

getText (((missionConfigFile >> "myClass") select 0) >> "myString")
Displays "1st Child"

If you knew what you wanted you could point straight there

getText (missionConfigFile >> "myClass" >> "myChildClass" >> "myString")
Displays "1st Child"

Lets say we wanted to iterate through all the classes in myClass but only get a reference to the one that had a myNumber of 3

Run this from the execute box

h = [] spawn {
	results = [];
	_basecfg = (missionConfigFile >> "myClass");
	for "_i" from 0 to (count _basecfg)-1 do {
		_cfg = _basecfg select _i;
		if (isClass _cfg) then {
			if (getNumber (_cfg >> "myNumber") == 3) then {
				results set [count results, configName _cfg];
			};
		};
	};
};
Then in a watch line type results and you should see ["mySecondChildClass"]

commented code

h = [] spawn {
	//An array to store our results in
	results = [];

	//Our base config to start from
	_basecfg = (missionConfigFile >> "myClass");

	//A loop from 0 to however many entries there are in the base config
	for "_i" from 0 to (count _basecfg)-1 do {

		//select an entry
		_cfg = _basecfg select _i;

		//Is it a actual class, not a KV
		if (isClass _cfg) then {

		//Is this classes KV myNumber equal to 3
			if (getNumber (_cfg >> "myNumber") == 3) then {

				//Add this classes name to the result array
				results set [count results, configName _cfg];
			};
		};
	};
};

This is the old way or iterating through a config structure. BIS have now given us a new command configClasses, much like the count command it will iterate through the config starting at the base class you give it and return all classes that match what ever you put in the condition.

" condition " configClasses (base class)

Type into a watch line

" getNumber (_x >> 'myNumber') == 3 " configClasses (missionConfigFile >> "myClass")
Displays [F:\My Documents\Arma 3 - Other Profiles\Dev\missions\example_configs.VR\description.ext/myClass/mySecondChildClass] or where ever your profile missions are kept

You will see that the return result looks different to our last script, thats because configClasses returns the path to the matching class rather than its configName, you can just iterate around the results to get their configName e.g run this from the execute box

results = [];
{
	results set [_forEachIndex, configName _x];
}forEach (" getNumber (_x >> 'myNumber') == 3 " configClasses (missionConfigFile >> "myClass"))
Typing results into a watchline you see we end up with exactly the same as out first script ["mySecondChildClass"].

Inheritance

If we insert a new class into our description ext inside myClass

class myClass {

	class myChildClass {

		myString = "1st Child";
		myNumber = 2;
		myArray[] = {"Bob", "Betty", "Sue"};

	};

	class mySecondChildClass {

		myString = "2nd Child";
		myNumber = 3;
		myArray[] = {"Bob", "Betty", "Sue"};

	};

	class myInheritedChildClass : myChildClass {

		myString = "Inherited Child";

	};

	myString = "Parent";
	myNumber = 1;
	myArray[] = {"David", "Kate", "Steve"};

};
We can see that this class is inherited from myChildClass

configName (inHeritsFrom (missionConfigFile >> "myClass" >> "myInheritedChildClass"))
Displays "myChildClass"

It Has its own myString

getText (missionConfigFile >> "myClass" >> "myInheritedChildClass" >> "myString")
Displays "Inherited Child"

but inherits myNumber

getNumber (missionConfigFile >> "myClass" >> "myInheritedChildClass" >> "myNumber")
Displays 2

and myArray

getArray (missionConfigFile >> "myClass" >> "myInheritedChildClass" >> "myArray")
Displays "Bob", "Betty", "Sue"

from myChildClass

Another handy function is BIS_fnc_returnParents

[(missionConfigFile >> "myClass" >> "myInheritedChildClass"),true] call BIS_fnc_returnParents
This will return a ARRAY, the array index 0 is the class we asked about and then each following index would be who it inherited from.

From the above we get ["myInheritedChildClass","myChildClass"], but if say "myChildClass" also inherited from another class then index 2 would display this class etc etc.

One more handy command is typeOf, using this on our soldier will return its className e.g in my mission i have placed the default BLUFOR rifleman.

typeOf player
Displays "B_Soldier_F"

As we know all soldiers are vehicles and vehicles are stored in the main configFile we can access any child classes and KV pairs via

getNumber (configFile >> "CfgVehicles" >> typeOf player >> "side")
Side here is a number relating to a BIS enumeration being..

[
	east,
	west,
	resistance,
	civilian,
	sideUnknown,
	sideEnemy,
	sideFriendly,
	sideLogic,
	civilian //--- Ambient life in editor
]
 

sideNumber = getNumber (configFile >> "CfgVehicles" >> typeOf player >> "side");
soldiersSide = sideNumber call BIS_fnc_sideType;
SoldierSide would equal WEST

Other function relating to this enumeration are

BIS_fnc_sideID - turns east, west etc in their side number 0, 1

BIS_fnc_sideName - turns either a side type (west) or number (1) into a side name "BLUFOR"

BIS_fnc_sideColor = turns either a side type (west) or number (1) into a RGB array of their color value [0,0.3,0.6,1]

Hope this all helps. Although here i have chosen to show examples using the missionConfigFile (Description.ext) same principles apply to the main configFile.

Some base cfgs to start from are -

configFile >> "CfgVehicles" - vehicles, soldiers, buildings and a ton of other stuff are held here

configFile >> "CfgWeapons" - rifles, pistols etc

configFile >> "CfgMagazines" - your magazines for your weapons

configFile >> "CfgAmmo" - your ammo that goes into your magazines and is the object that goes flying when you press fire

configFile >> "CfgGroups" - where you can find predetermined group make ups

and a multitude of others helpful classes, have a browse through the config viewer

Edited by Larrow
just tidying up
  • Like 1
  • Thanks 3

Share this post


Link to post
Share on other sites

I knew we kept Larrow around for a reason....mind = flooded with info :)

Share this post


Link to post
Share on other sites

Wow, thanks a lot Larrow. Messing around with config files is extremely poorly documented on the BIKI, even dialogs have better documentation than that. I'm actually almost ready to release something, but I can't get a variable passed from one script to another (if that makes sense).

Basically, you choose what you want to spawn from a combobox, then click on a button. The button launches a script, reads the selection of the combobox with lbCurSel, then using a passed array in combination with the index spawns something. I've been trying to find out how Iceman did it, but his coding is next-level.

EDIT: @JShock, I always hope Larrow comments on my threads, he seems to know everything about everything. I haven't been able to stump him yet!

Share this post


Link to post
Share on other sites
he seems to know everything about everything. I haven't been able to stump him yet!
Far far from it but im happy to share what i know.

Share this post


Link to post
Share on other sites

One more question, Larrow. You said you can't edit the configFile without making an addon, but is there a .pbo that I can crack open and view like your missionConfigFile example?

Share this post


Link to post
Share on other sites

Goto your Arma3 install directory and do a search on *.pbo making sure to include sub folders.

Discount any that are in mod folders or your MPMissions directory.

What your left with are the main game files. each PBO's name that gives you a good idea what your going to find in it.

The actual configFile that you see in the config viewer is not one file but a multitude of config.cpp's added together.

If you copy all these PBO's somewhere and then use one of the many tools available like mikeroos dePBO and extractPbo or eliteness to extract them you can then browse through them. Its all split into folders and each folder has a config.cpp that has all the relevant classes for it. (a full extract is around 14gb)

Would also be a good idea to grab some kind of grep tool to make searching alot easier.

If you want it all in one place then the games config viewer is by far the easiest way. Although extracting the files does give you a vary good overview of how everything fits together.

Edited by Larrow

Share this post


Link to post
Share on other sites
Do you know if there's a page like this for the Arma 3 CfgVehicles? I've looked all over, but can't find it.

In case you didn't come around it yet: https://community.bistudio.com/wiki/Arma_3_CfgPatches_CfgVehicles

Edit: Though you probably wanted a classtree, which would be in the subject of the thread. D: Not sure if there is one beside the aforementioned in-game config editor, the one at the Six Config Browser is nine months old.

Share this post


Link to post
Share on other sites

I got it working Magirot, thanks for the help though. Now there's just a whole bunch of other obstacles in my way :icon_wink:

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  

×