Skip to content

Instantly share code, notes, and snippets.

@SpaceBeeGaming
Created November 1, 2018 11:08
Show Gist options
  • Select an option

  • Save SpaceBeeGaming/337af5ecbeb16325c4aa9347812acfa8 to your computer and use it in GitHub Desktop.

Select an option

Save SpaceBeeGaming/337af5ecbeb16325c4aa9347812acfa8 to your computer and use it in GitHub Desktop.
Table saver/loader for OpenComputers Minecraft mod.
local serialization = require("serialization")
local tableToFile = {}
function tableToFile.load(location)
--returns a table stored in a file.
local tableFile = assert(io.open(location))
return serialization.unserialize(tableFile:read("*all"))
end
function tableToFile.save(table, location)
--saves a table to a file
local tableFile = assert(io.open(location, "w"))
tableFile:write(serialization.serialize(table))
tableFile:close()
end
return tableToFile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment