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

Need help with a turtle program.

Started by Mac, 28 July 2015 - 09:50 AM
Mac #1
Posted 28 July 2015 - 11:50 AM
Hello, I would like some help as i have being trying to make a remote control turtle.

Error Message:
bios:367: [string "controlled"]:18: '=' expected

Controlled is the name of the program.

Program:
while true do
event, senderId, message, distance = os.pullEvent("rednet_message")
print (message)
if message == "backwards" then
turtle.back()
end
if message == "forwards" then
turtle.forward()
end
if message == "left" then
turtle.turnLeft()
end
if message == "right" then
turtle.turnRight()
end
if message == "down" then
turtle.down()
end
if message == "up" then
turtle.up()
end
if message == "attack" then
turtle.attack()
end
if message == "attackup" then
turtle.attackup()
end
if message == "attackdown" then
turtle.attackdown()
end
if message == "dig" then
turtle.dig()
end
if message == "digup" then
turtle.digUp()
end
if message == "digdown" then
turtle.digDown()
end
if message == "refuel20" then
turtle.refuel(20)
end
if message == "refuel64" then
turtle.refuel(64)
end
end


Thanks for any help
HPWebcamAble #2
Posted 29 July 2015 - 02:34 AM
I don't see a place where that error might occur.
Besides your lack of indentation, it looks fine.


That could happen if you forgot the () for the function call, or you only put one '=' in the if statement, but you didn't do either of those.


Maybe you should check that the computer's code is the same as what you posted?
Mac #3
Posted 29 July 2015 - 07:46 AM
Hi, It turns out i forgot one () and the capital attack(UP) etc. now im having problems with this code. On my computer i made a program and the turtle will not respond to its commands.

Program:
rednet.broadcast("up")
sleep(3)
rednet.broadcast("right")
sleep(3)
rednet.broadcast("left")
sleep(3)
rednet.broadcast("left")
sleep(3)
rednet.broadcast("right")
sleep(3)
rednet.broadcast("right")
rednet.broadcast("dig")
sleep(3)
rednet.broadcast("forwards")
sleep(3)
rednet.broadcast("digup")
sleep(3)
rednet.broadcast("up")
sleep(3)
rednet.broadcast("digup")
sleep(3)
end


EDIT: I just relised this doesn't match the program above. edited backward and forward etc.
Edit: Everythink seems to work now.
Thanks for the help!
jerimo #4
Posted 29 July 2015 - 07:53 AM
Don't see the error either, but you may want to look into using elseif in your code, as its more widely supported as tuenway to chain of checking the same variable for a different result
LuckyLuke #5
Posted 29 July 2015 - 08:10 AM
Is this your hole code? I cannot find any error.
LeDark Lua #6
Posted 29 July 2015 - 03:26 PM
Your error might be in the 18 line of the code. You are showing us your while loop, we dont see what hapends before it.

Edit: Error: attackup must be attackUp and attackdown must be attackDown.
Edited on 29 July 2015 - 01:28 PM