Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- lzLights v0.1
- (C) LayZee 2013
- --]]
- local times = {
- sunset = 12,
- sunrise = 24
- }
- local function waitFor (time)
- local alarm = os.setAlarm(time)
- repeat
- local _, id = os.pullEvent("alarm")
- until id == alarm
- end
- local function lightsOnAtSunset ()
- waitFor(times.sunset)
- --Turn lights on
- --rs.setOutput("back", true) --or something
- end
- local function lightsOffAtSunrise ()
- waitFor(times.sunrise)
- --Turn lights off
- --rs.setOutput("back", false) --or something
- end
- --Main program
- while true do
- parallel.waitForAny(lightsOffAtSunrise, lightsOnAtSunset)
- end
Advertisement
Add Comment
Please, Sign In to add comment