Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function table2str(t)
- local function serialize(tbl)
- local tmp = {}
- for k, v in pairs(tbl) do
- local k_type = type(k)
- local v_type = type(v)
- local key = (k_type == "string" and "[\"" .. k .. "\"]=") or (k_type == "number" and "")
- local value = (v_type == "table" and serialize(v)) or (v_type == "boolean" and tostring(v)) or (v_type == "string" and "\"" .. v .. "\"") or (v_type == "number" and v)
- tmp[#tmp + 1] = key and value and tostring(key) .. tostring(value) or nil
- end
- if table.maxn(tbl) == 0 then
- return "\n[\"\"] = {" .. table.concat(tmp, ",") .. "},"
- else
- return "[" .. table.concat(tmp, "") .. "\n]"
- end
- end
- assert(type(t) == "table")
- return serialize(t)
- end
- dev = peripheral.find("focal_port")
- d = dev.readIota()
- str = table2str(d)
- f = io.open("data","w")
- f.write(f,str)
- f.close(f)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement