This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
LewisTehMinerz's profile picture

Table > String

Started by LewisTehMinerz, 14 November 2014 - 04:18 PM
LewisTehMinerz #1
Posted 14 November 2014 - 05:18 PM
I have a table in a different file that shows like this:

{
"Testing Tables",
}

How do I convert it into a string?
Dragon53535 #2
Posted 14 November 2014 - 05:20 PM
local tableString = textutils.serialize(tbl)
Turns tbl into a string
local tbl = textutils.unserialize(tableString)
back into a table.
Edited on 14 November 2014 - 04:22 PM
LewisTehMinerz #3
Posted 14 November 2014 - 05:25 PM
Cheers! :)/> I asked this because I'm making a package manager for my OS (in testing) that when it gets a defined argument (-pkg) it will load up the .pkg file (aka a table with all the links in it so the manager can download the correct files) and install the program

EDIT: How can I make it so if it fails to load it because it's not a table, it prints an error?
Edited on 14 November 2014 - 04:26 PM
KingofGamesYami #4
Posted 14 November 2014 - 06:18 PM
Add this in after

if type( tbl ) ~= "table" then
  error( "Your custom error message", 0 )
end
LewisTehMinerz #5
Posted 18 November 2014 - 04:07 PM
@Dragon53535 & @KingofGamesYami would you like to join the FrostOS team? The package manager is part of this OS and you can join the community if you want. Get Github if you want to join. I'd be so happy if you'd join! ;)/> (Also, I'll put you into the Owners)