Posted 03 March 2018 - 11:06 PM
Hello!
I'm trying to create a silo launch system. I want to have a master computer(controller) send a signal to the slave computers(silos) of weather or not they are armed. I also want the master computer to send a launch(for all silos to launch) or a launch[Number](for the one silo to launch) command to the slaves to launch them. I set it up how I think is most efficient but, I keep getting a rednet:109: Expected number. I am stuck and don't know what to do.
Slave:
The master computer works fine but I figured I'd give you an idea what is going on inside of it…
Master:
Thank you in advance!
I'm trying to create a silo launch system. I want to have a master computer(controller) send a signal to the slave computers(silos) of weather or not they are armed. I also want the master computer to send a launch(for all silos to launch) or a launch[Number](for the one silo to launch) command to the slaves to launch them. I set it up how I think is most efficient but, I keep getting a rednet:109: Expected number. I am stuck and don't know what to do.
Slave:
rednet.open("right")
local armed = "false"
local silonum = 2
function fire()
if armed == "true" then
rs.setOutput("back", true)
rs.setOutput("left", true)
sleep(5)
rs.setOutput("back", false)
rs.setOutput("left", false)
else
print("Deactivated")
end
end
while true do
id, msg = rednet.receive(id, msg)
if id == 28 and msg == "armed" then
rs.setOutput("front", false)
armed = "true"
elseif id == 28 and msg == "unarmed" then
rs.setOutput("front", true)
armed = "false"
elseif id == 28 and msg == "launch" then
fire()
elseif id == 28 and msg == "launch2" then
fire()
end
end
The master computer works fine but I figured I'd give you an idea what is going on inside of it…
Master:
--This is only the code for one of the slave computers in this case 2
local silo2 = "Deactivated"
while true do
input2 = read()
if input2 == "/launch" then --sends to all active
rednet.broadcast("launch")
if input2 == "/launch2" then --sends to specific silo (2)
rednet.send(siloID, "launch2")
if input2 == "/activate Silo #2" then
print("Silo #2 now Activated")
silo2 = "Activated"
rednet.send(siloID, "armed")
if input2 == "/deactivate Silo #2" then
print("Silo #2 Deactivated")
silo2 = "Deactivated"
rednet.send(siloID, "unarmed")
-- Down here would be to launch and all that, this part works
Thank you in advance!