Posted 01 August 2014 - 12:41 AM
Title: Rednet Conversation
Hey, all you people with spectacularly more knowledge about Lua and Computercraft
I am Finished (finally) writing my turtle program.
Anyway, instead of having to write the computer 'id' it will be talking to. Into every rednet.send() and receive command
I made a function that asks the user to input the computers id here:
And yes, i did, kinda originally take the outlay from a much more talented person. But he had such good ideas!
The thing is if i put a tonumber in the above like this
To
Gives me an error like "calling nil"
And so i put the tonumber() in the rednet.send(). Only problem is that now the turtle doesn't recognize an incoming signal
Code for the turtle when it is waiting for the signal:
Oh and also. Can i use the turtles label as an id? Like: rednet.send(Digger1, "start")
Hey, all you people with spectacularly more knowledge about Lua and Computercraft
I am Finished (finally) writing my turtle program.
Anyway, instead of having to write the computer 'id' it will be talking to. Into every rednet.send() and receive command
I made a function that asks the user to input the computers id here:
function Startup()
term.clear()
term.setCursorPos (1,1)
print (" this turtle's id: ", os.getComputerID())
print (" Set this turtle's label:")
print (" +--------------------------+ ")
print (" | ")
print (" +--------------------------+ ")
print ()
print (" Set The Computer Terminal's ID")
print (" +--------------------------+ ")
print (" | ")
print (" +--------------------------+ ")
term.setCursorPos(5,4)
local IgnLabel = read()
os.setComputerLabel(IgnLabel)
term.setCursorPos(5,4)
print ("Label successful")
term.setCursorPos(5,9)
local CompId = read()
term.setCursorPos(5,9)
print ("ID Set")
sleep(0.5)
Middle()
sleep(2)
end
And yes, i did, kinda originally take the outlay from a much more talented person. But he had such good ideas!
The thing is if i put a tonumber in the above like this
local CompId = read()
To
local CompId = tonumber(read())
Gives me an error like "calling nil"
And so i put the tonumber() in the rednet.send(). Only problem is that now the turtle doesn't recognize an incoming signal
Code for the turtle when it is waiting for the signal:
function RednetStasis()
term.clear()
term.setCursorPos (1,1)
print ("turtle is in receive mode")
print ("go to your terminal to start a dig cycle")
while true do
rednet.open("right")
id, message = rednet.receive()
if id == CompId and message == "start" then
rednet.close("right")
Sixcolumnstr()
break
end
end
end
Oh and also. Can i use the turtles label as an id? Like: rednet.send(Digger1, "start")