I'm trying to run a program on a pc on another pc using rednet.
If I type start on the "master computer", the other computer will run a program called light which basically randomly creates redstone signals to redstone lamps.But I also want the pc to run startup if i type stop on the "master computer" and again wait until i write start. But it just wont work. :(/>
This is the code I've written:
"master pc":
while true do
print("start?")
input = read()
if input == "start" then
rednet.open("right")
rednet.broadcast("light")
rednet.close("right")
if input == "stop" then
rednet.open("right")
rednet.broadcast("startup")
rednet.close("right")
end
end
end
on the other computer I have two programs:
--startup
rednet.open()
message = rednet.receive()
rednet.receive()
shell.run(message)
and
--light
while true do
local side = {"right", "left", "top", "bottom", "front", "back"}
local random_side = side[math.random(1, #side)]
rs.setOutput(random_side, true)
sleep(math.random(0.5, 1))
rs.setOutput(random_side, false)
sleep(math.random(0, 0.5))
message = rednet.receive()
rednet.receive()
if message == "stop" then
shell.run(message)
end