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

Code error - '<eof>' expected

Started by Tea, 04 January 2013 - 04:17 AM
Tea #1
Posted 04 January 2013 - 05:17 AM
Having issues with a basic script I'm using to learn LUA:


distance = 0
while true do
  turtle.getFuelLevel()
end
while turtle.getFuelLevel() > 100 do
  if turtle.detect() == true then
	turtle.dig()
	turtle.up()
	turtle.dig()
	turtle.forward()
	turtle.down()
  end
end
	elseif turtle.detect() == false then
  turtle.up()
  if turtle.detect() == true then
   turtle.dig()
   turtle.forward()
   turtle.down()
  end
  elseif turtle.detect() == false then
   turtle.forward()
   turtle.down()
  end
end

This is the error:


bios:338: [string "a1"]:14: '<eof>' expected
remiX #2
Posted 04 January 2013 - 05:22 AM
This usually means you have one extra end, but you have two.


distance = 0
-- The while loop that was here was not doing anything
while turtle.getFuelLevel() > 100 do
    if turtle.detect() then -- This is the same as == true
	    turtle.dig()
	    turtle.up()
	    turtle.dig()
	    turtle.forward()
	    turtle.down()
    else
        turtle.up()
        if turtle.detect() then
            turtle.dig()
            turtle.forward()
            turtle.down()
            -- If you're using if and elseif, you only need one end for the whole if statement/block
        else -- You're using a turtle command which returns true or false, so you do not need an elseif, just use else
           turtle.forward()
           turtle.down()
        end
    end
end
-- No needed if here
Tea #3
Posted 04 January 2013 - 05:28 AM
Edit: Nevermind