Posted 01 May 2014 - 12:01 PM
hi all i am writing a program that sends commands to my mining turtles. how the setup works is the turtle in charge will always idle and look for a redstone signal with a specific id and message. once the message has been received it should relay that message to another turtle and start digging
terminal that sends the signal:
and here is the turtle function supposed to pickup the signals:
i managed to make the terminal program actually send the redstone signal. however, the turtle never does anything with it which makes me think the "if" statements that are supposed to check id's and messages never validates anything.
any suggestions?
terminal that sends the signal:
local function one()
term.clear()
term.setCursorPos(1,1)
print ("Welcome to DigNet")
print ("sending dig commands")
print ("waiting for response...")
sleep(1)
rednet.open("right")
rednet.send(17, "startdig") -- sends the "startdig" message to the turtle
id, message = rednet.receive(10) -- waits 10 seconds for a response
if id == "17" and message == "digging" then
term.clear()
term.setCursorPos(1,1)
print ("Welcome to DigNet")
print ("robots are digging!")
rednet.close("right")
sleep(2)
Mainmenu()
else
term.clear()
term.setCursorPos(1,1)
print ("Welcome to DigNet")
print ("could not get response from digger after 10 seconds")
print ("you should probably check on them")
sleep(2)
rednet.close("right")
Mainmenu() -- loops the program back to the Mainmenu()
end
end
and here is the turtle function supposed to pickup the signals:
local function diggers()
rednet.open("right") -- turtle starts by idling until a rednet signal is received
id, message = rednet.receive()
if id == "20" and message == "startdig" then -- recognizes only id 20 and message startdig
rednet.send(20, "digging")
rednet.send(18, "digging") -- send the dig command to the other mining turtle turtle
rednet.close()
for i=1,10 do -- for loop when it is actually digging
tunnel()
end
diggers()
elseif id == "20" and message "comeback" then -- another alternative command that should make the turtle go back to where it started
rednet.send(20, "comingback")
rednet.send(18, "comingback")
rednet.close()
turtle.back(tostring(diggings))
sleep(0.5)
diggers()
end
end
i managed to make the terminal program actually send the redstone signal. however, the turtle never does anything with it which makes me think the "if" statements that are supposed to check id's and messages never validates anything.
any suggestions?