Posted 06 December 2014 - 02:27 AM
Im doing an AppleOS rewrite, and it loads files so you can save preferences, like passwords and background colors, and the background color loader doesn't work, but it does at first.
It loads the background color when it first starts up, but when you change it using my GUI, then it just crashed, but when you reboot then the color is changed to what you want. It errors exactly:
window:57: Expected number
Press any key to continue
Its really weird, works at first but errors when changed.
Heres the code for the background color loader.
And this time, im not using the code block because its small and not that easy to read so:
CODE:
function prefLoader()
prefDefiner = fs.open("prefs","r")
bColor = prefDefiner:readLine(1)
if(bColor == "lime") then
bColor = colors.lime
elseif(bColor == "blue") then
bColor = colors.blue
elseif(bColor == "red") then
bColor = colors.red
end
prefDefiner:close()
end
Now heres the code for the color changer
if(X == 13 and Y ==5) then
prefs = fs.open("prefs","w")
file.write("lime")
prefLoader()
elseif(X == 14 and Y==5) then
prefs = fs.open("prefs","w")
prefs.write("red")
prefLoader()
end
And yes I tried adding the prefs.close() or the prefs:close(), cant tell the diff so I added both but still an error.
And the only time it errors is when I call term.clear() when I do term.setBackgroundColor(bColor) before it.
Could someone help pls?
Thanks!
-bluebird
It loads the background color when it first starts up, but when you change it using my GUI, then it just crashed, but when you reboot then the color is changed to what you want. It errors exactly:
window:57: Expected number
Press any key to continue
Its really weird, works at first but errors when changed.
Heres the code for the background color loader.
And this time, im not using the code block because its small and not that easy to read so:
CODE:
function prefLoader()
prefDefiner = fs.open("prefs","r")
bColor = prefDefiner:readLine(1)
if(bColor == "lime") then
bColor = colors.lime
elseif(bColor == "blue") then
bColor = colors.blue
elseif(bColor == "red") then
bColor = colors.red
end
prefDefiner:close()
end
Now heres the code for the color changer
if(X == 13 and Y ==5) then
prefs = fs.open("prefs","w")
file.write("lime")
prefLoader()
elseif(X == 14 and Y==5) then
prefs = fs.open("prefs","w")
prefs.write("red")
prefLoader()
end
And yes I tried adding the prefs.close() or the prefs:close(), cant tell the diff so I added both but still an error.
And the only time it errors is when I call term.clear() when I do term.setBackgroundColor(bColor) before it.
Could someone help pls?
Thanks!
-bluebird
Edited on 06 December 2014 - 01:29 AM