View difference between Paste ID: 7K7wB3BM and 3Q7whUZh
SHOW: | | - or go back to the newest paste.
1
-- Here's an extremely basic timer program
2
-- version 2013.09.20
3
4
--[[ use these two variables to specify which 
5
       side the redstone signal comes IN and 
6
       which sideyou want to pulse for OUT
7
       valid options are "left", "right","up",
8
       "down","front", or "back"
9
     notice how we use them later in the code
10
       so we only have to change them once
11
       at the top of the code instead of each
12
       time throughout the code.
13
14
   to install, make a computer and run the following command
15
	pastebin get 5pC0Njha startup
16
   then hold CTRL+R to reboot the computer and start the timer!
17
   hold CTRL+T to terminate the timer and type
18
        edit startup
19
   to be able to edit this timer program
20
   ]]--
21
22-
local INPUT_SIDE = "top" -- change based on where your lever is  
22+
23-
local OUTPUT_SIDE = "back" -- change based on where your output side is
23+
local args = { ... }
24-
local IDLE_TIME = 30 -- time (in sec) for cc to wait, rec 30, allows timer to survive reboot
24+
local PHASE_LENGTH = 90  -- Standardlaenge je Phase an bzw aus
25
if #args > 0 then
26-
local PHASE_LENGTH = 90  -- time per each phase on - off
26+
	PHASE_LENGTH = 0 + args[1]
27
end
28
if PHASE_LENGTH > 300 then 
29
	PHASE_LENGTH = 300 -- 5 min bzw 300 sec Limit
30
end
31
32
local INPUT_SIDE = "top"     -- change based on where your lever is  
33
local OUTPUT_SIDE = "back"   -- change based on where your output side is
34-
  while rs.getInput(INPUT_SIDE) do--while lever is ON
34+
local IDLE_TIME = 30         -- time (in sec) for cc to wait, rec 30, allows timer to survive reboot
35
36-
    rs.setOutput(OUTPUT_SIDE,true)--turn output on
36+
37
--hold CTRL+T to stop the program
38-
    rs.setOutput(OUTPUT_SIDE,false)--turn output off
38+
39
  --wait for lever to be thrown, or check if red is already active after IDLE_TIME
40
  parallel.waitForAny(function() e = os.pullEvent("redstone"); return true end, function() sleep(IDLE_TIME); return true end)
41
  --pulse the output
42
  while rs.getInput(INPUT_SIDE) do  --while lever is ON
43
    write(".")  --print a dot each time we pulse
44
    rs.setOutput(OUTPUT_SIDE,true)  --turn output on
45
    sleep(PHASE_LENGTH)
46
    rs.setOutput(OUTPUT_SIDE,false)  --turn output off
47
    sleep(PHASE_LENGTH)
48
  end
49
end