Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function update(var,value)
- if not fs.exists("saveData") then
- local h = fs.open("saveData", "w")
- h.close()
- end
- if type(value) == "number" then
- value = tostring(value)
- elseif type(value) == "table" then
- local v = "{"
- for i = 1, #value-1 do
- v = v .. tostring(value[i]) .. ","
- end
- v = v .. tostring(value[#value]) .. "}"
- value = v
- elseif type(value) == "string" then
- value = "\""..value.."\""
- end
- local str = fs.open("saveData","r").readAll()
- if str:find(var) then
- str = str:gsub(var.."%=.-%;",var.."="..value..";")
- else
- str = str .."\n"..var.."="..value..";"
- end
- local h = fs.open("saveData","w")
- h.write(str)
- h.close()
- end
- update("a", 1)
- update("b", "frog")
- update("c", 4)
- local test = {1, 2, 3}
- update("test", test)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement