PDA

View Full Version : PlayInfo.AddSetting and arrays?



Xyx
09-24-2005, 01:08 PM
I have the following bit of code in my mutator:

PlayInfo.AddSetting(default.RulesGroup, "XSVehicleClassName0", default.ReplacementLabelText0, 0, 1, "Select", VehicleOptions);
PlayInfo.AddSetting(default.RulesGroup, "XSVehicleClassName1", default.ReplacementLabelText1, 0, 1, "Select", VehicleOptions);
PlayInfo.AddSetting(default.RulesGroup, "XSVehicleClassName2", default.ReplacementLabelText2, 0, 1, "Select", VehicleOptions);
It works, but it's not really maintenance friendly. I'd like it to be more like so:

for(i = 0; i < default.XSVehicleClassName.length; i++)
{
PlayInfo.AddSetting(default.RulesGroup, "XSVehicleClassName(" $ i $ ")", default.ReplacementLabelText[i], 0, 1, "Select", VehicleOptions);
}

But that won't work, because the resulting "XSVehicleClassName(0)" is not recognized as a valid property.

Anybody know how I can use PlayInfo.AddSetting to set array properties?

elmuerte
09-24-2005, 01:19 PM
You can't, specially not when using the standard display thingies (e.g. webadmin's default rules and the ingame settings widget).

In my UsUnit project I started on a proper PlayInfo to HTML converter thingy for which I did add support for arrays (not completely finished though).

Xyx
09-24-2005, 01:33 PM
Getting the compiler to recognize that the PropName contains an array name with index is the problem. I'm not sure if that's related to the "display thingies", unless you mean the display thingy can't parse the index part.

elmuerte
09-24-2005, 02:40 PM
It's not the compiler that is complaining, it's the code of PlayInfo.

But still SomeArray is a property, SomeArray[0] is not a property. And you can only add properties.

The code of PlayInfo contains some initial support for arrays and structs but it was never finished (and on top of that there are a few bugs that make it even worse).

Xyx
09-24-2005, 02:47 PM
That makes sense. Guess I'll have to stick to the "ugly" way then. :sour:

Thanks for the explanation! :)