Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    Putting an array in a struct.

    Advanced
    6
    12
    868
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • PickleCatStars
      PickleCatStars F last edited by PickleCatStars

      I’m trying to tidy up some code. So instead of having Separate variables ’map1’, ’colourmap1’, ’map1name’, ’map1size’ etc, I want to put them all in a struct. I’m trying this:

      struct map
          String name
          Array grid
          Array colourmap
          Int size
          Terrain terrain
      Endstruct
      

      When I do this, I get ’syntax error, unexpected array, expecting left bracket’ on line 3.

      I’ve tried putting some brackets in and doing various stuff, but I keep on getting syntax errors. How am I supposed to go about this please? Or am I just way off-base..?

      pianofire P 2 Replies Last reply Reply Quote 0
      • pianofire
        pianofire Fuze Team @PickleCatStars last edited by pianofire

        @toxibunny It seems to be expecting a size on the array declaration. I am not sure why as arrays are generally dynamic.

        struct
            string name
            array grid[8][8]
        endstruct
        
        M 1 Reply Last reply Reply Quote 2
        • PickleCatStars
          PickleCatStars F last edited by

          Okay, thanks!

          1 Reply Last reply Reply Quote 0
          • M
            Mechanical @pianofire last edited by

            @pianofire so will that be a change soon?

            1 Reply Last reply Reply Quote 0
            • P
              petermeisenstein F @PickleCatStars last edited by

              @toxibunny what happens if you declare your stract the short way.

              1 Reply Last reply Reply Quote 0
              • PickleCatStars
                PickleCatStars F last edited by

                I dunno, I’ve never done it!

                P 1 Reply Last reply Reply Quote 0
                • P
                  petermeisenstein F @PickleCatStars last edited by

                  @toxibunny Try it

                  1 Reply Last reply Reply Quote 0
                  • M
                    Mechanical last edited by

                    Ive tried that before and it seems you can't assign arrays to structs if you do it with clamps. Only with Arrays you've Initialised before.

                    1 Reply Last reply Reply Quote 0
                    • F
                      faz808 F last edited by

                      Sorry to butt in, but with reference to arrays what's a clamp?

                      waldron M 2 Replies Last reply Reply Quote 0
                      • waldron
                        waldron F @faz808 last edited by

                        @faz808 I think clamp is a fixed value so you can use it to make a rotation stop at certain angles as one example

                        1 Reply Last reply Reply Quote 0
                        • pianofire
                          pianofire Fuze Team last edited by

                          Yes clamp keeps a value between a maximum and a minimum https://fuzearena.com/help/view/clamp Not sure how this applies to assigning arrays to structs though

                          1 Reply Last reply Reply Quote 0
                          • F
                            faz808 F last edited by

                            You worry about your programming knowledge when you come across a term you've not seen before. I'm from the old school - bits, bytes nibbles, words etc . Love em !

                            P 1 Reply Last reply Reply Quote 1
                            • First post
                              Last post