Advertisement

Author Topic: deriving array of "car"s from config  (Read 339 times)

0 Members and 1 Guest are viewing this topic.

Offline Trexian

  • Members
  • *
deriving array of "car"s from config
« on: 10 Dec 2009, 14:52:40 »
I've had some experience generating an array using configFile >> class >> whatever (city positions, arrays of groups), but now that I'm trying to create an array of vehicles of the class "car" from cfgVehicles, I can't figure it out.

I can use something like
Code: [Select]
_carGroup = configFile >> cfgVehicles >> "car"

... and it'll tell me there are 91 entries (which seems about right), but they are all config entries, and not "objects" (according to the rpt error report).

Anybody got an easy answer?

TIA!
« Last Edit: 10 Dec 2009, 16:30:53 by Trexian »
Sic semper tyrannosauro.

Offline i0n0s

  • Former Staff
  • ****
Re: deriving array of "car"s from config
« Reply #1 on: 10 Dec 2009, 16:17:40 »
Use str (_carGroup select ...) or getText (...)
If you use the array often, you should convert it once into a new array.

Offline Trexian

  • Members
  • *
Re: deriving array of "car"s from config
« Reply #2 on: 10 Dec 2009, 16:42:29 »
Ah, ok.  I do have a loop for the count of whatever I got from the config.

So, something like:
Code: [Select]
_carGroup = configFile >> cfgVehicles >> "car"
_carCount = count _carGroup
for [{_z=0}, {_z < (_carCount - 1)}, {_z = _z +1}] do
{
_car = str (_carGroup select _z);
diag_log text format ["car = %1", _car];
_carArray = _carArray + [_car];

};

Will give that a try!  Thanks!

Edit:
Hey mate,

My dense head just can't sort this out.

This code:
Code: [Select]
_carGroup = _cfgPath >> "car";
_carCount = count _carGroup;
diag_log text format ["car count = %1", _carCount];

for [{_z=0}, {_z < (_carCount - 1)}, {_z = _z +1}] do
{
_car = str (_carGroup select _z);

diag_log text format ["car = %1", _car];
//_carArray = _carArray + [_car];

};

Basically gives me a list of variables for the class "car".  Like:
Quote
car count = 91
car = bin\config.bin/CfgVehicles/Car/mapSize
car = bin\config.bin/CfgVehicles/Car/icon
car = bin\config.bin/CfgVehicles/Car/displayName
car = bin\config.bin/CfgVehicles/Car/accuracy
car = bin\config.bin/CfgVehicles/Car/cost
...

And, I can get it to recognize when it finds "displayname", but I can't sort out how to loop it to check every "car" class vehicle?
« Last Edit: 11 Dec 2009, 05:14:13 by Trexian »
Sic semper tyrannosauro.