loading txt information in a 2d array form?


    Nov 25 2011 | 12:27 pm
    HI all, i'm trying to load the information for a simple maze architecture from a text file. The text file is in the form
    010
    101
    001
    where "0" are empty blocks (streets) and "1" are building blocks.
    What is the best way to do that? then i have to access it to build a jitter GL plan of it for exploration. I used a text object but it's not so easy. Maybe there is a matrix text loader or something. Any suggestion on how to proceed?
    A

    • Nov 25 2011 | 3:39 pm
      Break apart any line like
      010
      into
      0 1 0
      by using [iter].
      Then you have rows of 0 or 1 values, which you can load into a [jit.matrix] by using [jit.fill] per line.
      Or, try and load the whole file into a matrix at once using [jit.textfile]. When I tried it, the matrix was ASCII characters: so 010 became 48 49 48. That could be used the same as 0 1 0 but you'd just need a different [sel] at the point you're using it: [sel 48 49] versus [sel 0 1]. Either way, you can then tell [jit.sketch] to make a building or not :)
    • Nov 25 2011 | 4:37 pm
      I think you want jit.textfile.
      Test the patch below on a textmaze.txt file such as this:
      10010011
      00011001
      10101110
      01101011
      11010101
      10010001
      00011101
      10101110
    • Nov 25 2011 | 9:25 pm
      Thanx guys, it's exactly what i needed.
      A