|
| 23 Sep 2016 10:54 AM |
| is there a fast and easy way to convert a table to a string? I now made a for loop that concatenates the elements with eachother, but it gets very laggy and crashes when the table is big(which my table definatly is). |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 23 Sep 2016 10:55 AM |
are you trying to save the table
and why would u want to convert to a string
|
|
|
| Report Abuse |
|
|
JoshRBX
|
  |
| Joined: 19 May 2012 |
| Total Posts: 8778 |
|
|
| 23 Sep 2016 10:57 AM |
game:GetService("RunService").RenderStepped:connect(function() --Code end) This can act as your for loop It will process 60 parts of the table every second |
|
|
| Report Abuse |
|
|
|
| 23 Sep 2016 11:02 AM |
| It's not something I want to do while in game. I'm in studio right now and I created something with smooth terrain. I want to save that with ReadVoxels(which returns a 3D table). Copy the string and put it in a ModuleScript so I can load it in while in game using WriteVoxels. |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 23 Sep 2016 11:04 AM |
just save it to a datastore
|
|
|
| Report Abuse |
|
|
|
| 23 Sep 2016 11:07 AM |
| I have already put a great toll on DataStores... I just really need it in studio... |
|
|
| Report Abuse |
|
|
OzzyFin
|
  |
| Joined: 07 Jun 2011 |
| Total Posts: 3600 |
|
|
| 23 Sep 2016 11:09 AM |
| game:GetService("HttpService"):JSONEncode(table) |
|
|
| Report Abuse |
|
|
Dr_Doge
|
  |
| Joined: 07 Dec 2011 |
| Total Posts: 645 |
|
|
| 23 Sep 2016 11:09 AM |
-- Well its easy to store simple tables, but tables within tables are another story.
Table = ["Hi","lol","What up"]
TableString = "hehehew"
for i,v in pairs(Table) do TableString = TableString..","..v end
print(TableString)
-- You probs already know this but yeah... |
|
|
| Report Abuse |
|
|
|
| 23 Sep 2016 11:13 AM |
Do tables work with [] as well? I alway use {} And, I now have a recursive function that works for tables within tables, but the table has like 300*300*100 elements, so it just crashes if I don't put a wait() and if I do put a wait(), I'll be here for ages lol. |
|
|
| Report Abuse |
|
|
JoshRBX
|
  |
| Joined: 19 May 2012 |
| Total Posts: 8778 |
|
| |
|
iIikeyou
|
  |
| Joined: 07 Mar 2012 |
| Total Posts: 1659 |
|
|
| 23 Sep 2016 11:16 AM |
you can convert non-userdata values from a table to a string and back pretty easily
youd need to define the properties of userdata and compile them into a string, that can then be added to a new value when made later though. little more complicated (especially with instances, since theres so many types) |
|
|
| Report Abuse |
|
|
|
| 23 Sep 2016 11:16 AM |
@Josh Python can either be {} or [] -- they mean something different though -- whereas in Lua it can only be {}.
( ͡• ◡ ͡•) -=[ RAP: 412,583 || DurstAuric; the narb of ROBLOX ]=- ( ͡• ◡ ͡•) |
|
|
| Report Abuse |
|
|
iIikeyou
|
  |
| Joined: 07 Mar 2012 |
| Total Posts: 1659 |
|
|
| 23 Sep 2016 11:18 AM |
brackets are used to call an index from a table
local t={ [1]='pie'; pie=5; ['pie2']=6; [true]=false }
print(t[1]) print(t.pie) print(t.pie2) |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 23 Sep 2016 11:19 AM |
@harry just save the place file and reload it when you want to work with it again
|
|
|
| Report Abuse |
|
|
|
| 23 Sep 2016 11:23 AM |
| Why not use JSon encode and then decide the string on runtime |
|
|
| Report Abuse |
|
|
iIikeyou
|
  |
| Joined: 07 Mar 2012 |
| Total Posts: 1659 |
|
|
| 23 Sep 2016 11:23 AM |
| ###################################################################################################################################################################################################################################################################################################################################################################################################################################################################### |
|
|
| Report Abuse |
|
|
iIikeyou
|
  |
| Joined: 07 Mar 2012 |
| Total Posts: 1659 |
|
|
| 23 Sep 2016 11:24 AM |
local t={1,'hi','5',false,nomnom='cake!'} local function findtype(value) if type(value)=='string'then return'\''..value..'\'' elseif tonumber(value)or type(value)=='boolean'then return value elseif type(value)=='userdata'then print'sorry too much work' end end local string='return{' for i,v in next,t do string=string..'['..findtype(i)..']='..findtype(v)..',' end string=string:match'(.+),'..'}'
then you could just call loadstring on that string to get the table back |
|
|
| Report Abuse |
|
|
Dr_Doge
|
  |
| Joined: 07 Dec 2011 |
| Total Posts: 645 |
|
|
| 03 Oct 2016 10:45 AM |
Oh yeah sorry about that. I got it mixed up. |
|
|
| Report Abuse |
|
|