Jump to content




Zeitschaltung:24: Attempt To Compare __Lt On Nil And Number


  • You cannot reply to this topic
5 replies to this topic

#1 BKamorC

  • New Members
  • 2 posts

Posted 25 July 2013 - 11:55 AM

Hey Guys, I need some help with my program here
-- 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

#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 25 July 2013 - 12:59 PM

Split into new topic.

#3 MR_nesquick

  • Members
  • 106 posts
  • LocationNorway

Posted 25 July 2013 - 01:17 PM

function _ftime()
   nHour	= math.floor(os.time())
   nMinute  = nHour*60
   stime	= nHour..nMinute
  return stime
end
---------------------

edit: are you trying to send a redstone pulse when it's night time?

#4 Apfeldstrudel

  • Members
  • 161 posts

Posted 25 July 2013 - 05:05 PM

Its all in german and there is no specific problem?

#5 BKamorC

  • New Members
  • 2 posts

Posted 26 July 2013 - 03:12 AM

Yeah MR_nesquick :)

#6 MR_nesquick

  • Members
  • 106 posts
  • LocationNorway

Posted 26 July 2013 - 11:29 AM

starter code!. it will pulse a redstone signal at night

while true do
mTime = os.time()
if mTime >= 19 and mTime <= 24 or mTime >= 0 and mTime <= 6 then
rs.setOutput("right", true)
sleep(.5)
rs.setOutput("right", false)
sleep(.5)
else
rs.setOutput("right", false)
sleep(1)
end
end






2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users