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

[Lua][Error] end of function error after Repeat loop

Started by kelevra.1337, 13 October 2012 - 03:21 PM
kelevra.1337 #1
Posted 13 October 2012 - 05:21 PM
Hi guys,
Im trying to make a little program wich caves out a stairway into the ground, and to deal with the unlikely case of sand/gravel dropping on the turtle i made a repeat loop to break the sand/gravel but when i start the skript it gives me a eof error on line 32
("bios:206: [string "tunnel"]:32: 'eof' expected")
No matter what i do i cant get it to work properly,

My computercraft version is 1.4 with ccSensors installed.

I would really appreciate if someone can give me the solutuion to this little but really annoying problem.

The code:
Spoiler

local max=0
function iniPosDig()
  while true do
	if not turtle.detectDown() then
	  turtle.down()
	else
	  return false
	end
  end
end
function moveDown()
  max=0
  turtle.forward()
  turtle.digDown()
  turtle.down()
  turtle.dig()
	while not turtle.forward() do
	  turtle.dig()
	  turtle.dig()
	  turtle.dig()
	  turtle.dig()				  
	end
  turtle.forward()
  turtle.digUp()
	repeat
	  turtle.digUp()
	
	until
	  turtle.detectUp()==false
	  
	end
  end	  
end
function turtleFull()
  if turtle.getItemCount(15) > 1 then
  return true
  end
end

term.clear()
term.setCursorPos(1,1)
print("How deep down should this tunnel go?")
local IN = read()
for i=1,IN do
  if i == 1 then
	iniPosDig()
  end
  moveDown()
end
Kazimir #2
Posted 13 October 2012 - 05:28 PM
Delete of the line 32 and 31 "end"
kelevra.1337 #3
Posted 13 October 2012 - 05:37 PM
Thank you for the fast answer.
Now i feel like im retarded because i did everything other than that.
Lettuce #4
Posted 13 October 2012 - 05:39 PM
Well, it could also be the fact that you have the turtle.detectUp()==false on a different line than until, but you certainly need to delete that end like Kazimir said. Until ends repeat loops, not end. Unless you use say

print "Mwa"
repeat(3)
print "ha"
end
That would work, and display

Mwa
ha
ha
ha
.
Hope that helps.

–Lettuce
kelevra.1337 #5
Posted 13 October 2012 - 07:04 PM
yeah^^ now its acutally working (thank you), im kinda new to programming and not really familiar to the syntax so even for things like this i need help sometimes.