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

How to send a pulse of redstone to flip the switch

Started by dranasshinternal, 18 October 2012 - 11:06 PM
dranasshinternal #1
Posted 19 October 2012 - 01:06 AM
I am using a computer to be able to turn on my forcefield and tesla coil killing field. Below is the programs i am using. What i need to do is have it send a pulse of redstone after it is turned off so it can flip the latch switch by the generators to the off posistion.

edit startup
print("type shield to power the shield or to power it off")
print("type tesla to turn on or off the tesla coils")

edit shield :
print("type on to power the shield") print("type off to power off shield")
text = read()
if text == "on" then redstone.setOutput("bottom", true) end
if text == "off" then redstone.setOutput("bottom", false) end

edit tesla :
print("type on to turn the tesla coils on") print("type off to turn the tesla coils off")
text = read()
if text == "on" then redstone.setOutput("top", true) end
if text == "off" then redstone.setOutput("top", false) end
EmTeaKay #2
Posted 19 October 2012 - 01:38 AM
Use this code:

shell.run("redpulse", "side", "time", "amount of pulses you want")
Or, another way to do this using a function is:

function rdpls(side, time, pulse)
 shell.run("redpulse", side, time, pulse)
end
dranasshinternal #3
Posted 19 October 2012 - 02:46 AM
thanks, that worked like a charm, was bashing my head into the wall trying to get it to work.
Doyle3694 #4
Posted 19 October 2012 - 09:00 AM
or you can do

function redpulse(side, time, times)
for i=1,times do
rs.setOutput(side, true)
sleep(time)
rs.setOutput(side, false)
sleep(time)
end
end
You know how arguements work in functions?