Posted 08 July 2012 - 06:59 PM
I'm having a problem while working on my turtle remote program.
Here's the code:
Computer (Master):
Turtle (Slave):
The error:
Here's the code:
Computer (Master):
local function RCmaster(tid)
while true do
local sEvent, param = os.pullEvent("key")
if(sEvent == "key") then
if(param == 200) then
rednet.send(tid,"TRM:FORWARD")
elseif (param == 208) then
rednet.send(tid,"TRM:BACKWARD")
elseif (param == 203) then
rednet.send(tid,"TRM:TURNLEFT")
elseif (param == 205) then
rednet.send(tid,"TRM:TURNRIGHT")
elseif (param == 28) then
rednet.send(tid,"TRM:PLACEBLOCK")
elseif (param == 30) then
rednet.send(tid,"TRM:UP")
elseif (param == 44) then
rednet.send(tid,"TRM:DOWN")
end
end
end
end
local function init()
print("What side is your modem on?")
local modem = read()
rednet.open(modem)
print("What is the ID of the slave turtle?")
local tid = tonumber(read())
term.clear()
textutils.slowPrint("TurtleRemote Initiated.")
end
init()
print ("Arrow keys = Move, Enter = Place block, A = Move up, Z = Move down.")
RCmaster(tid)
Turtle (Slave):
local function init()
rednet.open("right")
term.clear()
textutils.slowPrint("TurtleRemoteSlave Initiated.")
end
local function RCslave()
while true do
local id, msg = rednet.receive()
if(msg == "TRM:FORWARD") then
print("Forward")
if(turtle.detect() == true) then
print("Block Detected. Digging.")
turtle.dig()
end
turtle.forward()
elseif(msg == "TRM:BACKWARD") then
print("Backward")
turtle.back()
elseif(msg == "TRM:TURNLEFT") then
print("Turn Left")
turtle.turnLeft()
elseif(msg == "TRM:TURNRIGHT") then
print("Turn Right")
turtle.turnRight()
elseif(msg == "TRM:PLACEBLOCK") then
if(turtle.detect() == true) then
print("ERROR:Block Present")
else
print("Place Block")
turtle.place()
end
elseif(msg == "TRM:UP") then
if(turtle.detectUp() == true) then
print("Block Detected. Digging.")
turtle.digUp()
print("Up")
turtle.up()
end
elseif(msg == "TRM:DOWN") then
if(turtle.detectDown == true) then
print("Block Detected. Digging.")
turtle.digDown()
end
print("Down")
turtle.down()
end
end
end
end
init()
RCslave()
The error:
"bios:206: [string"turtleremoteslave"]:49: '<eof>' expected"
when I try to run the turtle-side program, TurtleRemoteSlave.