Posted 13 May 2012 - 04:23 AM
I think there should be a command for a short pulse of on and off of redstone power, both normal power and Redpower power.
redstone.setOutput(side,true)
os.sleep(1) -- sleep one second
redstone.setOutput(side,false)
Redpower can work with pulses of one tick length, that is getting a bit difficult, as you can't sleep that precise. But you can also pass values <1 to sleep().well, for normal redstone you could just sayRedpower can work with pulses of one tick length, that is getting a bit difficult, as you can't sleep that precise. But you can also pass values <1 to sleep().redstone.setOutput(side,true) os.sleep(1) -- sleep one second redstone.setOutput(side,false)
function pulse( _nSide, _nTime )
redstone.setOutput( _nSide, true)
sleep(_nTime)
redstone.setOutput( _nSide, false)
end
pulse("back", 1) -- pulse for 1 second on the back of the pc
Try to run it. It would say: "Attempt to write to global". Create a new API if you want, but with a new name (remove the rs. from the function name), and load it with os.loadAPI.well, for normal redstone you could just sayRedpower can work with pulses of one tick length, that is getting a bit difficult, as you can't sleep that precise. But you can also pass values <1 to sleep().redstone.setOutput(side,true) os.sleep(1) -- sleep one second redstone.setOutput(side,false)
Or make it a APIfunction rs.pulse( _nSide, _nTime ) redstone.setOutput( _nSide, true) sleep(_nTime) redstone.setOutput( _nSide, false) end pulse("back", 1) -- pulse for 1 second on the back of the pc
Try to run it. It would say: "Attempt to write to global". Create a new API if you want, but with a new name (remove the rs. from the function name), and load it with os.loadAPI.well, for normal redstone you could just sayRedpower can work with pulses of one tick length, that is getting a bit difficult, as you can't sleep that precise. But you can also pass values <1 to sleep().redstone.setOutput(side,true) os.sleep(1) -- sleep one second redstone.setOutput(side,false)
Or make it a APIfunction rs.pulse( _nSide, _nTime ) redstone.setOutput( _nSide, true) sleep(_nTime) redstone.setOutput( _nSide, false) end pulse("back", 1) -- pulse for 1 second on the back of the pc