generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: convert table to string

Previous Thread :: Next Thread 
HarrySnotte is not online. HarrySnotte
Joined: 27 Jun 2011
Total Posts: 2854
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 is not online. 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 is not online. 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
HarrySnotte is not online. HarrySnotte
Joined: 27 Jun 2011
Total Posts: 2854
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 is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
23 Sep 2016 11:04 AM
just save it to a datastore


Report Abuse
HarrySnotte is not online. HarrySnotte
Joined: 27 Jun 2011
Total Posts: 2854
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 is not online. OzzyFin
Joined: 07 Jun 2011
Total Posts: 3600
23 Sep 2016 11:09 AM
game:GetService("HttpService"):JSONEncode(table)
Report Abuse
Dr_Doge is not online. 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
HarrySnotte is not online. HarrySnotte
Joined: 27 Jun 2011
Total Posts: 2854
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 is not online. JoshRBX
Joined: 19 May 2012
Total Posts: 8778
23 Sep 2016 11:14 AM
I thought [] was Python
Report Abuse
iIikeyou is not online. 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
DurstAuric is not online. DurstAuric
Joined: 12 May 2009
Total Posts: 8066
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 is not online. 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 is not online. 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
ScripterJohn13 is not online. ScripterJohn13
Joined: 01 Jan 2010
Total Posts: 5658
23 Sep 2016 11:23 AM
Why not use JSon encode and then decide the string on runtime
Report Abuse
iIikeyou is not online. iIikeyou
Joined: 07 Mar 2012
Total Posts: 1659
23 Sep 2016 11:23 AM
######################################################################################################################################################################################################################################################################################################################################################################################################################################################################
Report Abuse
iIikeyou is not online. 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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image