Posted 14 February 2014 - 10:24 AM
Hey guys.
I've made a system where there are 3+ computers. Each one of them can toggle a redstone output.
The redstone output makes some sticky pistons go up, allowing some Sentry Turrets from FTB Unleashed to shoot.
However, for some reason, the computers that can toggle the pistons work and all, but none of them send messages to each other. I'm using rednet.broadcast to send a message to every computer. However, the computer that sent the broadcast can only receive a message from the mother computer (the one that sends out the redstone output)
Computer1 and Computer2 are supposed to receive these two messages, but the one who broadcasted to the mother computer is the only one to receive the message.
Can someone help?
Here's the code for Computer1 and Computer2:
Here's the code for the Mother Computer:
I've made a system where there are 3+ computers. Each one of them can toggle a redstone output.
The redstone output makes some sticky pistons go up, allowing some Sentry Turrets from FTB Unleashed to shoot.
However, for some reason, the computers that can toggle the pistons work and all, but none of them send messages to each other. I'm using rednet.broadcast to send a message to every computer. However, the computer that sent the broadcast can only receive a message from the mother computer (the one that sends out the redstone output)
Computer1 - Computer 2
|
Broadcasts 'turretToggle'
to Mother
computer
|
--------|---------
Mother computer sends redstone output
|
Mother computer broadcasts 'turreton' or 'turretoff'
Computer1 and Computer2 are supposed to receive these two messages, but the one who broadcasted to the mother computer is the only one to receive the message.
Can someone help?
Here's the code for Computer1 and Computer2:
side = "right"
rednet.open(side)
function clear()
term.clear()
term.setCursorPos(1,1)
end
clear()
print("Press X to toggle the turrets!")
xxx,key = os.pullEvent("char")
id,msg,dist = os.pullEvent("rednet_message")
function rednetxx()
id,msg,dist = os.pullEvent("rednet_message")
if msg == "turreton" then
clear()
print("Turrets are off!")
elseif msg == "turretoff" then
clear()
print("Turrets are on!")
end
end
function keysxx()
xxx,key = os.pullEvent("char")
if key == "x" then
key = ""
rednet.broadcast("toggleTurret")
end
end
while true do
parallel.waitForAny(rednetxx,keysxx)
end
Here's the code for the Mother Computer:
rednet.open("top")
ev,id,msg,dist = os.pullEvent("rednet_message")
output = false
while true do
os.pullEvent("rednet_message")
if ev == "rednet_message" then
if msg == "toggleTurret" then
output = not output
if output == true then
rednet.broadcast("turreton")
redstone.setOutput("left",true)
redstone.setOutput("right",true)
elseif output == false then
rednet.broadcast("turretoff")
redstone.setOutput("left",false)
redstone.setOutput("right",false)
end
end
end
end