Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Here's an extremely basic timer program
- -- version 2013.09.20
- --[[ use these two variables to specify which
- side the redstone signal comes IN and
- which sideyou want to pulse for OUT
- valid options are "left", "right","up",
- "down","front", or "back"
- notice how we use them later in the code
- so we only have to change them once
- at the top of the code instead of each
- time throughout the code.
- to install, make a computer and run the following command
- pastebin get 5pC0Njha startup
- then hold CTRL+R to reboot the computer and start the timer!
- hold CTRL+T to terminate the timer and type
- edit startup
- to be able to edit this timer program
- ]]--
- local args = { ... }
- local PHASE_LENGTH = 90 -- Standardlaenge je Phase an bzw aus
- if #args > 0 then
- PHASE_LENGTH = 0 + args[1]
- end
- if PHASE_LENGTH > 300 then
- PHASE_LENGTH = 300 -- 5 min bzw 300 sec Limit
- end
- local INPUT_SIDE = "top" -- change based on where your lever is
- local OUTPUT_SIDE = "back" -- change based on where your output side is
- local IDLE_TIME = 30 -- time (in sec) for cc to wait, rec 30, allows timer to survive reboot
- --start an infini8te loop
- --hold CTRL+T to stop the program
- while true do
- --wait for lever to be thrown, or check if red is already active after IDLE_TIME
- parallel.waitForAny(function() e = os.pullEvent("redstone"); return true end, function() sleep(IDLE_TIME); return true end)
- --pulse the output
- while rs.getInput(INPUT_SIDE) do --while lever is ON
- write(".") --print a dot each time we pulse
- rs.setOutput(OUTPUT_SIDE,true) --turn output on
- sleep(PHASE_LENGTH)
- rs.setOutput(OUTPUT_SIDE,false) --turn output off
- sleep(PHASE_LENGTH)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement