No announcement yet.

PlayInfo.AddSetting and arrays?

  • Filter
  • Time
  • Show
Clear All
new posts

    PlayInfo.AddSetting and arrays?

    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?

    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).


      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.


        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).


          That makes sense. Guess I'll have to stick to the "ugly" way then. :sour:

          Thanks for the explanation!