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

Unserializing tables doesn't work

Started by Windows10User, 04 October 2018 - 04:19 PM
Windows10User #1
Posted 04 October 2018 - 06:19 PM
So, right now I have this code:



local tmp = fs.open("filesystem.ufs", "r")
local ufs = textutils.unserialize(tmp.readAll())
tmp.close()


It runs "fine". However, when I try to use the ufs table, it seems to be nil.

I have CC build 5 1.12.2 from http://cc.crzd.me

Why does this happen?
SquidDev #2
Posted 04 October 2018 - 07:06 PM
Without knowing what the file looks like, we can't say for sure. However, at a guess it's not a valid table - double check that everything looks correct within filesystem.ufs.
Windows10User #3
Posted 04 October 2018 - 07:30 PM
Without knowing what the file looks like, we can't say for sure. However, at a guess it's not a valid table - double check that everything looks correct within filesystem.ufs.

This is the table:

{
    "myfile.lua" = {
	    name = "myfile.lua",
	    type = "file",
	    contentloc = "90285",
    },

    filecontent = {
	    "90285" = "print(\"Hello!\")",
    },
}

Everything looks correct to me.
EveryOS #4
Posted 04 October 2018 - 07:56 PM
Try this:

{
   ["myfile.lua"] = {
                    name = "myfile.lua",
                    type = "file",
                    contentloc = "90285"
    },
    filecontent = {
                    ["90285"] = "print(\"Hello!\")"
    }
}
Edited on 04 October 2018 - 05:59 PM
Windows10User #5
Posted 05 October 2018 - 12:04 PM
Try this:

{
   ["myfile.lua"] = {
					name = "myfile.lua",
					type = "file",
					contentloc = "90285"
	},
	filecontent = {
					["90285"] = "print(\"Hello!\")"
	}
}

Did that, fixed a few bugs I just found and it works! Thanks for the help, brotha.