Posted 25 July 2013 - 12:55 PM
Hey Guys, I need some help with my program here
If possible and if you want, correct all my errors please
Thanks
-- CC programmierbarer Timer/Zeitschaltuhr/Nachtlicht by BKamorC 25/07/2013
-- HINWEIS!! Zeitspannen, welche ?ber Mitternacht (Ingame) hinaus gehen, m?ssen
-- geteilt angegebne werden zB. 19:00 bis 6:15 wird dann so geschrieben:
-- zeiten[1] = {1900,2359}
-- zeiten[2] = {0000,0615}
local lout = ("right") --Steuerausgang / Output
local onoff = ("top") --Aus-Aus Schalter
local refresh = 0.8 --Time to Refresh (100ms-800ms; 0.1 = fastest, 0.8 = slower)
zeiten = {}
zeiten[1] = {1900,2359}
zeiten[2] = {0000,0600}
------------------------------------------------------------------------------------
local varfill = 0
function _fill(varfill) -- "9" -> "09"
if varfill < 10 then varfill = "0" ..varfill end
return varfill
end
function _ftime()
nHour = math.floor(os.time())
nMinute = math.floor((os.time() -nHour)*60)
stime = _fill(nHour) .._filll(nMinute)
return stime
end
function _akttime()
pzeit = os.time()
pzeit = textutils.formatTime(pzeit, true)
return pzeit
end
function _testtime(zeiten,lout,onoff,refresh)
for i = 1, #zeiten, 1 do
lstart = zeiten[i][1]
lstop = zeiten[i][2]
while tonumber(_ftime()) >= lstart and tonumber(_ftime()) <=lstop do
shell.run("clear")
print(_akttime().." | "..lstart.." : "..lstop)
if rs.getInput(onoff) == false then
rs.setOutput(lout, true)
else
rs.setOutput(lout, false)
end
sleep(refresh)
end
rs.setOutput(lout, false)
end
end
while true do
shell.run("clear")
print("aktuelle Zeit: ".._akttime())
_testtime(zeiten,lout,onoff,refresh)
sleep(refresh)
end
If possible and if you want, correct all my errors please
Thanks