Announcement

Collapse
No announcement yet.

How to store array variables in config file?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to store array variables in config file?

    I recently ran into a bug where upon a crash, my default variables for an array keep being reset. It's getting annoying and it isn't going to get better with scale. The variable is an array of static meshes that can be used for the actor. I'd like to store these in a config file instead as an option until this bug is resolved.

    Does anyone know how to do this?

    I only really know where the config goes in defaultEngine.ini and to set it up like this, but the representation of an array in a config file is unknown to me. Can anyone help?:
    [Game/Hexagons/TileClasses/hex_standard_basic.hex_standard_basic_C]
    componentMesh=Game/Hexagons/Meshes/hex_Standard_tile.fbx
    Last edited by Skifree; 12-23-2016, 05:29 PM.

    #2
    Make an UObject and on its declaration add "config = Game" (or any other .ini name);
    On your TArray declararion add "config" to its UFUNCTION() macro.
    Unreal will always load CDO with default values from that ini; then just get the values using GetMutableDefault<UYourUObject>() function.

    Oh, I mean, in C++...
    Last edited by BrUnO XaVIeR; 12-23-2016, 05:47 PM.
    | Savior | USQLite | FSM | Object Pool | Sound Occlusion | Property Transfer | Magic Nodes | MORE |

    Comment


      #3
      can this be done without C++ via blueprint? For instance, how would I represent the array in the config file? I know how to set an integer variable in int config as Myvariable=2 but I don't know how to represent an array of Meshes.
      Last edited by Skifree; 12-23-2016, 06:06 PM.

      Comment


        #4
        The thing I told there was to add ini values automatically; doing that you won't edit any ini by hand, Unreal will build the array itself line by line and read it back when game loads. I don't think you can do that with blueprints, no.
        | Savior | USQLite | FSM | Object Pool | Sound Occlusion | Property Transfer | Magic Nodes | MORE |

        Comment


          #5
          Originally posted by BrUnO XaVIeR View Post
          The thing I told there was to add ini values automatically; doing that you won't edit any ini by hand, Unreal will build the array itself line by line and read it back when game loads. I don't think you can do that with blueprints, no.
          Editing by hand is easy and the intention here.

          For instance:

          This loads array item 1:
          UniqueComponentMesh=StaticMesh '/Game/hexagons/Meshes/hex_standard_tile_20CM.hex_standard_tile_20CM'

          But I can't figure out the syntax to load more than 1 array item into UniqueComponentMesh.
          StaticMesh'/Game/hexagons/Meshes/hex_component_1.hex_component_1')

          Comment


            #6
            I believe you have each on separate lines with "+" before it, so for example a mesh array called Meshes with two elements would be:

            +Meshes=StaticMesh'/Game/StarterContent/Shapes/Shape_Cylinder.Shape_Cylinder'
            +Meshes=StaticMesh'/Game/StarterContent/Shapes/Shape_Cone.Shape_Cone'

            Also, if you create the array in blueprints first, then right click and copy, you can paste it somewhere so you don't have type out all the paths individuallt.

            Comment


              #7
              Originally posted by Mosel3y View Post
              I believe you have each on separate lines with "+" before it, so for example a mesh array called Meshes with two elements would be:

              +Meshes=StaticMesh'/Game/StarterContent/Shapes/Shape_Cylinder.Shape_Cylinder'
              +Meshes=StaticMesh'/Game/StarterContent/Shapes/Shape_Cone.Shape_Cone'

              Also, if you create the array in blueprints first, then right click and copy, you can paste it somewhere so you don't have type out all the paths individuallt.
              *PERFECT*

              This is what ended up working for me.

              UniqueComponentMesh=StaticMesh'/Game/hexagons/Meshes/hex_standard_tile_20CM.hex_standard_tile_20CM'
              +UniqueComponentMesh=StaticMesh'/Game/hexagons/Meshes/hex_component_1.hex_component_1'
              +UniqueComponentMesh=StaticMesh'/Game/hexagons/Meshes/hex_component_2.hex_component_2'
              +UniqueComponentMesh=StaticMesh'/Game/hexagons/Meshes/hex_component_3.hex_component_3'
              +UniqueComponentMesh=StaticMesh'/Game/hexagons/Meshes/hex_component_4.hex_component_4'
              +UniqueComponentMesh=StaticMesh'/Game/hexagons/Meshes/hex_component_5.hex_component_5'
              +UniqueComponentMesh=StaticMesh'/Game/hexagons/Meshes/hex_component_6.hex_component_6'
              +UniqueComponentMesh=StaticMesh'/Game/hexagons/Meshes/hex_component_7.hex_component_7'
              +UniqueComponentMesh=StaticMesh'/Game/hexagons/Meshes/hex_component_8.hex_component_8'

              Does anyone know in what order the config files load compared to the rest of the level?
              Last edited by Skifree; 12-23-2016, 06:43 PM.

              Comment


                #8
                You don't have to use the "+" sign though;

                I took a look at one auto generated ini Unreal makes for my plugin and it just look like this:

                [/Script/Savior.SaviorSettings]
                DefaultSlotsList=Slot-1
                DefaultSlotsList=Slot-2
                DefaultSlotsList=Slot-3
                DefaultSlotsList=Slot-4
                DefaultSlotsList=Slot-5
                DefaultSlotsList=Slot-6
                DefaultSlotsList=Slot-7
                DefaultSlotsList=Slot-8
                DefaultSlotsList=Slot-9
                DefaultSlotsList=Slot-10
                | Savior | USQLite | FSM | Object Pool | Sound Occlusion | Property Transfer | Magic Nodes | MORE |

                Comment


                  #9
                  Originally posted by BrUnO XaVIeR View Post
                  You don't have to use the "+" sign though;

                  I took a look at one auto generated ini Unreal makes for my plugin and it just look like this:
                  I had tried that without the + but the array item at index 0 was just overwritten by the next one. Your plugin may treat the config differently.

                  Comment


                    #10
                    lol so weird; it should be the same for both Blueprints or C++ classes
                    | Savior | USQLite | FSM | Object Pool | Sound Occlusion | Property Transfer | Magic Nodes | MORE |

                    Comment


                      #11
                      Excuse me for replaying the old post, but I found that
                      in Saved/Config/XX/YY.ini, you don't have to add '+',
                      while in Proj/Config/DefaultYY.ini, you have to add '+'

                      Comment

                      Working...
                      X