This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
xxx's profile picture

Please delete

Started by xxx, 08 September 2012 - 02:48 PM
xxx #1
Posted 08 September 2012 - 04:48 PM
Please delete
Edited on 27 December 2013 - 03:44 PM
GopherAtl #2
Posted 08 September 2012 - 05:35 PM
I'm confused by what you're trying to do; what you seem to be describing in the post sounds like a repeater, not a clock.
xxx #3
Posted 08 September 2012 - 05:44 PM
Please delete
Edited on 27 December 2013 - 03:43 PM
Mrawesomecookie #4
Posted 08 September 2012 - 05:49 PM
use a repeat loop?
xxx #5
Posted 08 September 2012 - 06:02 PM
Please delete
Edited on 27 December 2013 - 03:43 PM
Mtdj2 #6
Posted 08 September 2012 - 06:12 PM
Simple (I think.)

while true do
if rs.getInput("top") then
rs.setOutput("bottom",true)
else
rs.setOutput("bottom",false)
end
end
[CODE]
It should work.
MysticT #7
Posted 08 September 2012 - 06:16 PM
This should work:

while true do
  rs.setOutput("bottom", rs.getInput("top"))
  os.pullEvent("redstone") -- waits for a redstone change
end
xxx #8
Posted 08 September 2012 - 06:30 PM
Please delete
Edited on 27 December 2013 - 03:43 PM
MysticT #9
Posted 08 September 2012 - 06:43 PM
Oh, ok. Try with this:

local nPulseDuration = 1 -- duration of the pulse in seconds
local sInputSide = "top"
local sOutputSide = "bottom"

local bPulseOn = rs.getInput(sInputSide)
local timer

if bPulseOn then
  rs.setOutput(sOutputSide, true)
  timer = os.startTimer(nPulseDuration)
end

while true do
  local evt, arg = os.pullEvent()
  if evt == "timer" then
    if bPulseOn then
	  rs.setOutput(sOutputSide, not rs.getOutput(sOutputSide))
	  timer = os.startTimer(nPulseDuration)
    end
  elseif evt == "redstone" then
    local input = rs.getInput("top")
    if input ~= bPulseOn then
	  bPulseOn = input
	  if bPulseOn then
	    timer = os.startTimer(nPulseDuration)
	  else
	    rs.setOutput(sOutputSide, false)
	  end
    end
  end
end
Not tested, but it should work.
GopherAtl #10
Posted 08 September 2012 - 07:00 PM
Oh, sorry, you DID mean a clock after all, I just wasn't groking your explanation. At a glance MysticT's code looks good. :D/>/>
xxx #11
Posted 08 September 2012 - 07:16 PM
Please delete
Edited on 27 December 2013 - 03:43 PM
xxx #12
Posted 08 September 2012 - 07:28 PM
Please delete
Edited on 27 December 2013 - 03:43 PM