This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
MonsterKiLL's profile picture

Turtle up and down

Started by MonsterKiLL, 21 July 2013 - 05:07 AM
MonsterKiLL #1
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

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.
Lyqyd #2
Posted 21 July 2013 - 04:10 PM
Split into new topic.
Grim Reaper #3
Posted 21 July 2013 - 04:28 PM
On line 29 or 30, I'm not sure which one it is :P/> You have

turtle.digUp
without parenthesis.

The interpreter thinks you're trying to assign turtle.digUp a value, but I think that you're really trying to call it as a function.
You should have

turtle.digUp()
instead. Functions require that you have (…) after their name. The … is just a way of abbreviating parameters, so you don't actually have to have anything there :)/>
MonsterKiLL #4
Posted 22 July 2013 - 03:32 AM
Oh, like I said I never coded such thing before :D/> But I see what is wrong now, and I'll try that asap. Thanks! :)/>