Posted 25 October 2012 - 09:00 PM
Hello everyone, I am new to coding in lua, I'm sorry if my code is .
I made this code to tell the last time was a shift on redstone signal, and save the time.
but wen i added the saving and loading it keeps on giving me this message:
"on2:52: attempt to concatenate nil and string"
i have be troubleshooting now for 2 hours and can not find what wrong.
Hops someone can help me. ^_^/>/>
I made this code to tell the last time was a shift on redstone signal, and save the time.
but wen i added the saving and loading it keeps on giving me this message:
"on2:52: attempt to concatenate nil and string"
i have be troubleshooting now for 2 hours and can not find what wrong.
Hops someone can help me. ^_^/>/>
local S = 0 M = 0 ST = 0 Y = 0
local load = io.open("data/On2_data", "r")
local save = io.open("data/On2_data", "w")
S = load:read()
M = load:read()
Y = load:read()
load:close()
while true do
local x = (redstone.getInput ("left"))
if x==False then
if Y == 0 then
ocal S = 0 M = 0 Y = 1
end
term.clear()
term.setCursorPos(1,1)
term.clear()
term.setCursorPos(1,1)
print ("The alarm is OFF")
print (" Is "..S.." seconds")
print ("and "..M.." minues")
print ("since last error")
os.sleep(1)
S = S + 1
local x = (redstone.getInput ("left"))
if S == 60 then
S = S-60
M = M+1
end
ST = ST + 1
if ST == 15 then
ST = ST - 15
save:write(S.."\n")
save:write(M.."\n")
save:write(Y)
save:close()
end
else
if Y == 1 then
local S = 0 M = 0 Y = 0
end
term.clear()
term.setCursorPos(1,1)
print("The alarm is ON")
print (" Is "..S.."seconds")
print ("and "..M.."minues")
print("since an error occured" )
local x = (redstone.getInput ("left"))
shell.run ("redpulse", "right", "1", "1")
S = S+1
if S == 60 then
S = S-60
M = M+1
end
if ST == 15 then
ST = ST - 15
save:write(S.."\n")
save:write(M.."\n")
save:write(Y)
save:close()
end
end
end