Posted 24 November 2014 - 02:46 AM
I am having a problem with making a setting update portion. I made a small program to test this before importing it.
I get it to read the file and save it, but seems to not change any of the settings.
could I get some help on that?
here is what I have
I get it to read the file and save it, but seems to not change any of the settings.
could I get some help on that?
here is what I have
function load(dest) --This loads the information located at "dest".
local file = fs.open(dest,"r")
local data = file.readAll()
file.close()
return textutils.unserialize(data)
end
function save(table,dest) --This saves the table to file dest.
if fs.exists(dest) == true then
fs.delete(dest)
end
local file = fs.open(dest,"w")
file.write(textutils.serialize(table))
file.close()
end
local infoTable = load("info")
term.clear()
term.setCursorPos(1,1)
newTable = {username = infoTable["username"],pwd = infoTable["pwd"],APIv = infoTable["APIv"]}
print("username: "..newTable["username"])
print("password: "..newTable["pwd"])
write("?: ")
input = read()
if input == "username" then
term.clear()
term.setCursorPos(1,1)
write("?: ")
input = read()
newTable["username"] = input
elseif input == "password" then
term.clear()
term.setCursorPos(1,1)
write("?: ")
input = read()
newTable["pwd"] = input
save(newTable,"info")
end
term.clear()
term.setCursorPos(1,1)
print("Info has been changed")