Results 1 to 5 of 5

Thread: Is there a "split()" function? (In LUA)

                  
   
  1. #1
    PSP User
    Join Date
    Jun 2006
    Location
    Under your bed (H)
    Posts
    377
    Rep Power
    68

    Default Is there a "split()" function? (In LUA)

    Hi, I was wandering if there was a command to split all of a string into arrays for my game that uses text files to show the level. It is in the format:
    0,0,0,0,2,2,2,2,2,2,2,2,2,2,2,
    0,0,0,0,2,1,1,1,1,1,1,1,1,1,2,
    0,0,0,0,2,1,1,1,1,1,1,1,1,1,2,
    0,0,0,0,0,1,1,1,1,1,1,1,1,1,2,
    0,0,0,0,2,1,1,1,1,1,1,1,1,1,2,
    0,0,0,0,2,2,2,2,2,2,2,2,2,2,2
    which "0" is blackness, "1" is wooden flooring and "2" is the wall.

  2. #2
    GP2X Coder/Moderator
    Join Date
    Jan 2006
    Posts
    1,678
    Rep Power
    85

    Default

    Try the string library: http://lua-users.org/wiki/StringLibraryTutorial

    You should be able to get away with using the byte function and iterating through the string.

  3. #3
    PSP User
    Join Date
    Jun 2006
    Location
    Under your bed (H)
    Posts
    377
    Rep Power
    68

    Default

    trying it now

  4. #4
    GP2X Coder/Moderator
    Join Date
    Jan 2006
    Posts
    1,678
    Rep Power
    85

    Default

    I was just wondering, why not use a two dimensional array of numbers/integers instead of strings? It be quicker to process and manage.

  5. #5
    PSP User
    Join Date
    Jun 2006
    Location
    Under your bed (H)
    Posts
    377
    Rep Power
    68

    Default

    ah yes, i could put it into another lua file like level1.lua and have it as an array and use dofile() to get it. hmmm..

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •