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

How to make flashing light if redstone signal is applied

Started by Lord, 15 July 2012 - 10:51 AM
Lord #1
Posted 15 July 2012 - 12:51 PM
So guys, the title is not that right, the thing i wan to ask to you is a bit tricky.
First, here's my code. It's basically a GUI on the computer to lightup/shut down my quarries and another program running on the monitor on top telling me if the Quarries are running or not by checking the redstone signal that the pipes send if items are passing trough (Buildcraft Gates). I putted 2 row of lamps at the sides of my giant screen and i connected them to the computer and i want that if the a quarry is not running the computer sends a redstone pulse to the lamps, but i cannot figure out how to do this. I know that i can use if and then but i don't know where to put 'em (i use parallels to running a program on the pc and another on the monitor). So guys, how to do that?
Thanks! :P/>/>
P.s. I'm not english, so if there are errors (i hope not) don't beat me D:
P.p.s. The formattation of the code is a little f*cked up because i ctrl+c ctrl+v from notepad++


function1 = function()
-- Quarries Menu
term.clear()
term.setCursorPos(1, 1)
print("				   Main Menu	  ")		  
print("#################################################")
print("#											   #")
print("#											   #")
print("#											   #")
print("#											   #")
print("#											   #")
print("#			  1: Quarries On				   #")
print("#											   #")
print("#			  2: Quarries Off				  #")
print("#											   #")
print("#											   #")
print("#											   #")
print("#											   #")
print("#											   #")	
print("#		   Please select option:			   #")
print("#################################################")

term.setCursorPos(35, 16)write("")
answer = read()
if answer == "1"
then shell.run("quarrieson", true)
elseif answer == "2"
then shell.run("quarriesoff", true)
else term.setCursorPos(15, 16)
term.clearLine()
print("Not a valid command")
end

sleep (2)
shell.run("startup", true)

end
function2 = function()
-- Quarries status
while true do
mon = peripheral.wrap("top")
mon.clear()
mon.setCursorPos(1, 1)
mon.write("				  Quarries status	  ")		  
mon.setCursorPos(1, 2)
mon.write("###############################################")
mon.setCursorPos(1, 3)
mon.write("#											 #")
mon.setCursorPos(1, 4)
mon.write("#											 #")
mon.setCursorPos(1, 5)
mon.write("#		  Quarry 1 Status:				   #")
mon.setCursorPos(1, 6)
mon.write("#											 #")
mon.setCursorPos(1, 7)
mon.write("#											 #")
mon.setCursorPos(1, 8)
mon.write("#		  Quarry 2 Status:				   #")
mon.setCursorPos(1, 9)
mon.write("#											 #")
mon.setCursorPos(1, 10)
mon.write("#											 #")
mon.setCursorPos(1, 11)
mon.write("#		  Quarry 3 Status:				   #")
mon.setCursorPos(1, 12)
mon.write("#											 #")
mon.setCursorPos(1, 13)
mon.write("#											 #")
mon.setCursorPos(1, 14)
mon.write("#		  Quarry 4 Status:				   #")
mon.setCursorPos(1, 15)
mon.write("#											 #")
mon.setCursorPos(1, 16)
mon.write("#											 #")
mon.setCursorPos(1, 17)
mon.write("###############################################")

-- Quarries status check

sleep(0.5)
if rs.testBundledInput("left", colors.white) == false
then mon.setCursorPos (29, 5) mon.write("Not Running")
end

sleep(0.5)
if rs.testBundledInput("left", colors.white) == true
then mon.setCursorPos (29, 5) mon.write("Running")
end

sleep(0.5)
if rs.testBundledInput("left", colors.orange) == false
then mon.setCursorPos (29, 8) mon.write("Not Running")
end

sleep(0.5)
if rs.testBundledInput("left", colors.orange) == true
then mon.setCursorPos (29, 8) mon.write("Running")
end

sleep(0.5)
if rs.testBundledInput("left", colors.magenta) == false
then mon.setCursorPos (29, 11) mon.write("Not Running")
end

sleep(0.5)
if rs.testBundledInput("left", colors.magenta) == true
then mon.setCursorPos (29, 11) mon.write("Not Running")
end

sleep(0.5)
if rs.testBundledInput("left", colors.lightBlue) == false
then mon.setCursorPos (29, 14) mon.write("Not Running")
end

sleep(0.5)
if rs.testBundledInput("left", colors.lightBlue) == true
then mon.setCursorPos (29, 14) mon.write("Running")
end

sleep(2)

end
end
parallel.waitForAny (function1, function2)

flaminsnowman99 #2
Posted 15 July 2012 - 01:34 PM
This is one thing you could do

bCable = 0
sleep(0.5)
if rs.testBundledInput("left", colors.white) == true
bCable = colors.combine(bCable, colors.yellow) -- color will be whatever colors are sent to your lamps
bCable = colors.subtract(bCable, colors.purple) -- This will turn a colors off. I put it just in case
rs.setBundledOutput("left", bCable)
end
Lord #3
Posted 15 July 2012 - 03:15 PM
Sorry, it doesn't work :P/>/> I tried adding it in every method (another parallel adding into the second parallel or in the first) But nothing worked D:
Someone else?
Lord #4
Posted 15 July 2012 - 03:36 PM
OK guys, i solved :P/>/> But i have another problem, opening a new thread :)/>/>