|
| 16 Jul 2013 06:54 PM |
How would I make a string into a table?
local string = "0,1,2,3,4,5,6,7,8,9"
local table = {}
I'm trying to make it do this:
local table = {0,1,2,3,4,5,6,7,8,9} |
|
|
| Report Abuse |
|
|
noah
|
  |
| Joined: 11 Sep 2006 |
| Total Posts: 18977 |
|
|
| 16 Jul 2013 06:56 PM |
| table.insert(table, string) |
|
|
| Report Abuse |
|
|
|
| 16 Jul 2013 06:56 PM |
No that's not what he meant.
I would use string.find to find all of the commas and separate the values between them and add them separately to the table. |
|
|
| Report Abuse |
|
|
|
| 16 Jul 2013 07:08 PM |
No, no, no.
LoadLibrary('RbxUtility').EncodeJSON({1, 2, 3})
>"[1:"1",2:"2",3:"3"]"
LoadLibrary('RbxUtility').DecodeJSON("[1:"1",2:"2",3:"3"]")
>{1, 2, 3} |
|
|
| Report Abuse |
|
|
|
| 16 Jul 2013 07:09 PM |
| That's a good idea Roy. Thanks. |
|
|
| Report Abuse |
|
|
|
| 16 Jul 2013 07:10 PM |
| Not I'll also check that out. Thanks. |
|
|
| Report Abuse |
|
|
noah
|
  |
| Joined: 11 Sep 2006 |
| Total Posts: 18977 |
|
|
| 16 Jul 2013 07:16 PM |
I used table.concat;
numbers = {} string = {"1", "2", "3", "4", "5", "6", "7", "8", "9"} table.insert(numbers, table.concat(string, ",")) for i,v in pairs (numbers) do print(v) end |
|
|
| Report Abuse |
|
|
oxcool1
|
  |
| Joined: 05 Nov 2009 |
| Total Posts: 15444 |
|
|
| 16 Jul 2013 07:59 PM |
local stri = "0,1,2,3,4,5,6,7,8,9"
local tab = loadstring("return "..stri)()
|
|
|
| Report Abuse |
|
|