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

Help With '=' Expected Error In Simple Program (Noob :d)

Started by boongfoot, 28 July 2013 - 02:15 PM
boongfoot #1
Posted 28 July 2013 - 04:15 PM
I've been staring at this simple peice of code with a simple error message for too long now not being able to work out whats up (bare in mind im very new to lua and this is my first real attempt at a script :)/> )

I'm getting bios:338: [string "test"]:1: '=' expected on this code below


-- function for harvesting
local function harvest()
turtle.dig()
turtle.forward()
end
-- detecting left and right functions
local function detectLeft()
turtle.turnLeft()
turtle.detect()
end
local function detectRight()
turtle.turnRight()
turtle.turnRight()
turtle.detect()
end
-- quick check for position in rows
local function check()
if detectLeft() and detectRight() then
  print("RAG")
elseif detectLeft() and not detectRight() then
  turtle.forward()
  turtle.forward()
  turtle.turnRight()
  turtle.up()
else
  turtle.turnLeft()
  turtle.turnLeft()
  turtle.forward()
  turtle.forward()
  turtle.turnLeft()
  turtle.up()
end
end
end
--main loop
while true do
harvest()
if turtle.down() then
  check()
else
  harvest()
end
end
end

would anyone be able to point me in the right direction please? :)/>

thanks in advance.
LBPHacker #2
Posted 28 July 2013 - 04:19 PM
The "end" on line 34 shouldn't be there.
EDIT: Nor should the one on line 44.
boongfoot #3
Posted 28 July 2013 - 04:21 PM
The "end" on line 34 shouldn't be there.
EDIT: Nor should the one on line 44.

Thank you sir, now I just have to work out why the turtle wants to do circles instead of turn right! :P/>
Have a good day.
MR_nesquick #4
Posted 28 July 2013 - 04:24 PM
i get error code is "bios:388: [string "test"]:34: '<eof>' expected"
and you got a end to much on line 34 and 44

Edit: damn it. too slow *sadface*
Yevano #5
Posted 28 July 2013 - 04:26 PM
Thank you sir, now I just have to work out why the turtle wants to do circles instead of turn right! :P/>

In your detectRight function, you are calling turtle.turnRight twice. Then in detectLeft, you call tutle.turnLeft once.
boongfoot #6
Posted 28 July 2013 - 04:55 PM
Thank you sir, now I just have to work out why the turtle wants to do circles instead of turn right! :P/>

In your detectRight function, you are calling turtle.turnRight twice. Then in detectLeft, you call tutle.turnLeft once.

Thanks, I was trying to save myself by just having it do a 180 with the double turtle.turnRight() but I think it might be better to give it a forward position first then execute the turtle.turnRight()