Posted 21 July 2013 - 07:07 AM
Hello. I want to add the turtle to go up and down. So I changed this code a bit, but it didn't work. Can you tell me what is wrong ?
Computer
Turtle
Computer works fine, but turtle gives error. bios:338: [string "console"]:30: '=' expected
I never coded before, so I don't understand what is wrong.
Computer
function RCmaster()
while true do
local sEvent, param = os.pullEvent("key")
if(sEvent == "key") then
if(param == 200) then
rednet.broadcast("TS Forward")
elseif (param == 208) then
rednet.broadcast("TS Backward")
elseif (param == 203) then
rednet.broadcast("TS TurnLeft")
elseif (param == 205) then
rednet.broadcast("TS TurnRight")
elseif (param == 28) then
rednet.broadcast("TS PlaceBlock")
elseif (param == 72) then
rednet.broadcast("TS Up")
elseif (param == 80) then
rednet.broadcast("TS Down")
end
end
end
end
print("What side is your modem on?")
local modem = read()
rednet.open(modem)
term.clear()
textutils.slowPrint("TurtleControl Initiated.")
print ("Use arrow keys to move and Enter to place blocks.")
RCmaster()
Turtle
function RCslave()
while true do
local scrap, message = rednet.receive()
if message == "TS Forward" then
print("Forward")
if turtle.detect() == true then
turtle.dig()
end
turtle.forward()
elseif message == "TS Backward" then
print("Backward")
turtle.back()
elseif message == "TS TurnLeft" then
print("Turn Left")
turtle.turnLeft()
elseif message == "TS TurnRight" then
print("Turn Right")
turtle.turnRight()
elseif message == "TS PlaceBlock" then
if turtle.detect() == true then
print("Block Present")
else
print("Place Block")
turtle.place()
end
elseif message == "TS Up" then
print("Up")
elseif turtle.detectUp == true then
turtle.digUp
end
turtle.up()
elseif message == "TS Down" then
print("Down")
if turtle.detectDown() == true then
turtle.digDown()
end
turtle.down()
end
end
end
rednet.open("right")
textutils.slowPrint("TurtleReceive Initiated.")
RCslave()
Computer works fine, but turtle gives error. bios:338: [string "console"]:30: '=' expected
I never coded before, so I don't understand what is wrong.