Navigation

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

    2-D string array with more columns than rows issue

    Bug Reporting (FUZE 4 Nintendo Switch)
    array
    6
    10
    630
    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.
    • spikey
      spikey F last edited by spikey

      I am working an game, based on text characters and run into this. Blame me, if its just not the approach how to use an array. I probably better switch to a 1-D array of strings ;-)
      ID: LXK738YWK8

      a = [ [".", ".", ".", "."], [".", ".", ".", "."], [".", ".", ".", "."] ]
      print(len(a), "x", len(a[0]))
      print()
      a[0][3] = "X" // should not change the amount of rows, just the 3rd element in the first row
      print(len(a), "x", len(a[0]))
      

      output:

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

        They start off at 0. By setting a[0][3] to ”x”, you’re adding a 4th element. I think it’s fine...

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

          @toxibunny Thanks for reading, but I am not convinced yet. print(a) at the end, returns Unknown type: 4. print() with an array should always return that array, I guess.

          1 Reply Last reply Reply Quote 0
          • PB____
            PB____ last edited by PB____

            I agree with @spikey that this is a bug.

            If you print a[0] a[1] and a[2] individually, you do see [".", ".", ".", "X"], [".", ".", ".", "."], [".", ".", ".", "."], but len(a) indicates that there is an a[3], which is not the case and trying to read it, does throw an error.

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

              Oh yeah. Sorry, my mistake.

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

                @spikey said in 2-D string array with more columns than rows issue:

                a = [ [".", ".", ".", "."], [".", ".", ".", "."], [".", ".", ".", "."] ]

                Do you get the same issue if you initialise a like this instead:

                a = [ "....",  "....", "...." ]
                
                1 Reply Last reply Reply Quote 0
                • spikey
                  spikey F last edited by spikey

                  @vinicity interesting, this works for reading form a[0][3] but not writing to it. To write you can only access the whole string then, like a[0]='...X'.
                  My workaround right now, is just to define the row numbers as fix and not use len(a) to determine it.

                  1 Reply Last reply Reply Quote 1
                  • vinicity
                    vinicity F last edited by

                    Great that you have a workaround. Also, I’m really curious about your new game!

                    1 Reply Last reply Reply Quote 1
                    • Starshine Vixen
                      Starshine Vixen last edited by

                      Hello guys

                      I have a similar problem. I don't understand code very well yet to say whether it is identical to the problem described here or has something to do with it.

                      This code works very well

                      myArray = [
                      [0,0,0,0,0],
                      [0,0,0,0,0],
                      [0,0,0,0,0]
                      ]
                      
                      myArray[1][2] = 1
                      
                      print[myArray]
                      

                      Returns:

                      [ [0,0,0,0,0], [0,0,1,0,0], [0,0,0,0,0] ]
                      

                      But this code ... :

                      myArray = [
                      [0,0,0,0,0],
                      [0,0,0,0,0],
                      [0,0,0,0,0]
                      ]
                      
                      myArray[1][3] = 1
                      
                      print[myArray]
                      

                      Returns a ---Error--- : Unknown type: 4


                      My workaround is to add twice as many rows:

                      myArray = [
                      [0,0,0,0,0],
                      [0,0,0,0,0],
                      [0,0,0,0,0],
                      [0,0,0,0,0]
                      ]
                      
                      myArray[1][3] = 1
                      
                      print[myArray]
                      

                      Returns:

                      [ [0,0,0,0,0], [0,0,0,1,0], [0,0,0,0,0] ]
                      

                      Is that a bug in Fuze4 ???

                      pianofire 1 Reply Last reply Reply Quote 2
                      • pianofire
                        pianofire Fuze Team @Starshine Vixen last edited by pianofire

                        @Starshine-Vixen Yes this seems to be a bug. I have tried it with the latest patch (which should be out soon) and it works as expected

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