Posted 19 January 2016 - 10:46 PM
Hi guys, I'm new to the forum, and kinda new with LUA and Computercraft in general (familiarized with other languages)
I have a problem. I have 2 Computers with modems and the idea is that Computer one sends an order to computer 2 via wireless modem, I need Computer 2 (There will be many others listening too) to output a redstone signal if the order sent matches what its waiting for to be true.
Here is what I have so far (Totally raw code) the idea will be making it more complex and with a GUI on an interface, but I'm testing so far.
Computer 1:
Computer 2:
I'm almost sure that my error is on Computer 2, where I check for the argument to be true and even when I sleep on computer 1 and send a different message, that if statement on computer 2 remains true and that's why the redstone signal keep active.
How should I fix this?
Thanks a lot.
I have a problem. I have 2 Computers with modems and the idea is that Computer one sends an order to computer 2 via wireless modem, I need Computer 2 (There will be many others listening too) to output a redstone signal if the order sent matches what its waiting for to be true.
Here is what I have so far (Totally raw code) the idea will be making it more complex and with a GUI on an interface, but I'm testing so far.
Computer 1:
local modem = peripheral.wrap("top")
local orderChannel = 55
modem.open(orderChannel)
modem.transmit(orderChannel, orderChannel, "TTT")
sleep(1.5)
modem.transmit(orderChannel, orderChannel, "Clear")
Computer 2:
local modem = peripheral.wrap("top")
local orderChannel = 55
local terminal = "TTT"
modem.open(orderChannel)
local messageArguments = {os.pullEvent("modem_message")}
while true do
if terminal==messageArguments[5] then
redstone.setOutput("back", true)
sleep(1)
redstone.setOutput("back", false)
print("We receive 1 order")
else
redstone.setOutput("back", false)
end
sleep(0.1)
end
I'm almost sure that my error is on Computer 2, where I check for the argument to be true and even when I sleep on computer 1 and send a different message, that if statement on computer 2 remains true and that's why the redstone signal keep active.
How should I fix this?
Thanks a lot.