Posted 16 May 2018 - 06:04 AM
Ok so I'm new to using lua and all I'm trying to do is make a simple program that wirelessly enables and disables the lights. The only problem is how stupidly complex rednet is rednet won't work. Every time I tell it to turn on or off, computer 1 shows the appropriate response to my inputs while computer 2 is still waiting for input from computer 1. I tried searching for examples and stuff online and the wiki to no avail so this is my last resort. Am I doing something wrong or have I discovered a bug?
Computer 1's code (Sender):
–Computer id is 1
print("Lamp on or off?")
print("1=On 0=Off")
rednet.open("back") –modem is indeed here and within range
ans = io.read() – ans is what the user requested
if ans == ("1") then
rednet.send(1, "1")
print("Turned it on!")
elseif ans == ("0") then
rednet.send(1, "0")
print("Turned it off!")
else
print("Invalid Input")
end
Computer 2's code (Receiver):
–Computer id is 4
rednet.open("back") –modem is indeed here and within range
ans = rednet.receive()
if ans == ("1") then
redstone.setOutput("left", true) –Lamp is indeed here
elseif ans == ("0") then
redstone.setOutput("left", false) –Lamp is indeed here
else
print("Invalid Input!")
end
Computer 1's code (Sender):
–Computer id is 1
print("Lamp on or off?")
print("1=On 0=Off")
rednet.open("back") –modem is indeed here and within range
ans = io.read() – ans is what the user requested
if ans == ("1") then
rednet.send(1, "1")
print("Turned it on!")
elseif ans == ("0") then
rednet.send(1, "0")
print("Turned it off!")
else
print("Invalid Input")
end
Computer 2's code (Receiver):
–Computer id is 4
rednet.open("back") –modem is indeed here and within range
ans = rednet.receive()
if ans == ("1") then
redstone.setOutput("left", true) –Lamp is indeed here
elseif ans == ("0") then
redstone.setOutput("left", false) –Lamp is indeed here
else
print("Invalid Input!")
end