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

[Error][string "Cyl"]:76: '<eof>' expected First Program Need a bit of Help.

Started by TechManDylan, 28 March 2013 - 05:28 AM
TechManDylan #1
Posted 28 March 2013 - 06:28 AM
So this is my first attempt at making a program for my turtle. I plan on making a Cylinder but for now i'm starting with a circle for now until i get everything working but i'm stuck here I can't seem to figure out whats wrong. This is what I have got so far

Code

Spoiler

if turtle.getFuelLevel() < 1000 then
turtle.select(16)
turtle.refuel(64)
end
function AntiObstruct()
if turtle.detectDown() then
  turtle.digDown()
end
end
function PlaceBlock()
turtle.placeDown()
turtle.forward()
end
function roundCorner()
turtle.forward()
turtle.turnRight()
turtle.forward()
turtle.turnLeft()
end
function BuildCylinder()
local BuildLength = 0
local getItem = tonumber(turtle.getItemCount(1))
if (getItem < 1) then
print("Place materials in slot 1 to start building.")
else
turtle.select(1)
end
if (BuildLength < 10) then
AntiObstruct()
PlaceBlock()
BuildLength = BuildLength + 1
else
roundCorner()
BuildLength = BuildLength - 10
end
if (BuildLength < 2) then
AntiObstruct()
PlaceBlock()
BuildLength = BuildLength + 1
else
roundCorner()
BuildLength = BuildLength - 2
end
if (BuildLength < 1) then
AntiObstruct()
PlaceBlock()
BuildLength = BuildLength + 1
else
roundCorner()
BuildLength = BuildLength - 1
end
if (BuildLength < 2) then
AntiObstruct()
PlaceBlock()
BuildLength = BuildLength + 1
else
roundCorner()
BuildLength = BuildLength - 2
end
if (BuildLength < 10) then
AntiObstruct()
PlaceBlock()
BuildLength = BuildLength + 1
else
roundCorner()
BuildLength = BuildLength - 10
end
end
term.clear()
BuildCylinder()
end
end

And a screen shot


CCJJSax #2
Posted 28 March 2013 - 06:35 AM
simply put, take off the two ends at the end


if turtle.getFuelLevel() < 1000 then
  turtle.select(16)
  turtle.refuel(64)
  end

function AntiObstruct()
  if turtle.detectDown() then
    turtle.digDown()
  end
end

function PlaceBlock()
  turtle.placeDown()
  turtle.forward()
end

function roundCorner()
  turtle.forward()
  turtle.turnRight()
  turtle.forward()
  turtle.turnLeft()
end

function BuildCylinder()
  local BuildLength = 0
  local getItem = tonumber(turtle.getItemCount(1))
    if (getItem < 1) then
      print("Place materials in slot 1 to start building.")
    else
    turtle.select(1)
    end
  if (BuildLength < 10) then
    AntiObstruct()
    PlaceBlock()
    BuildLength = BuildLength + 1
  else
    roundCorner()
    BuildLength = BuildLength - 10
  end
  if (BuildLength < 2) then
    AntiObstruct()
    PlaceBlock()
    BuildLength = BuildLength + 1
  else
    roundCorner()
    BuildLength = BuildLength - 2
  end
  if (BuildLength < 1) then
    AntiObstruct()
    PlaceBlock()
    BuildLength = BuildLength + 1
  else
    roundCorner()
    BuildLength = BuildLength - 1
  end
  if (BuildLength < 2) then
    AntiObstruct()
    PlaceBlock()
    BuildLength = BuildLength + 1
  else
    roundCorner()
    BuildLength = BuildLength - 2
  end
  if (BuildLength < 10) then
    AntiObstruct()
    PlaceBlock()
    BuildLength = BuildLength + 1
  else
    roundCorner()
    BuildLength = BuildLength - 10
  end
end

term.clear()
BuildCylinder()

edit: I also indented the correct lines.
remiX #3
Posted 28 March 2013 - 06:42 AM
To expand on what CCJJSax said, <eof> indicates that you have too many ends in your program.

I also suggest you to indent your code and this can be seen easily:
Spoiler
if turtle.getFuelLevel() < 1000 then
	turtle.select(16)
	turtle.refuel(64)
end

function AntiObstruct()
	if turtle.detectDown() then
		turtle.digDown()
	end
end

function PlaceBlock()
	turtle.placeDown()
	turtle.forward()
end
function roundCorner()
	turtle.forward()
	turtle.turnRight()
	turtle.forward()
	turtle.turnLeft()
end

function BuildCylinder()
	local BuildLength = 0
	local getItem = tonumber(turtle.getItemCount(1))
	if (getItem < 1) then
		print("Place materials in slot 1 to start building.")
	else
		turtle.select(1)
	end
	if (BuildLength < 10) then
		AntiObstruct()
		PlaceBlock()
		BuildLength = BuildLength + 1
	else
		roundCorner()
		BuildLength = BuildLength - 10
	end
	if (BuildLength < 2) then
		AntiObstruct()
		PlaceBlock()
		BuildLength = BuildLength + 1
	else
		roundCorner()
		BuildLength = BuildLength - 2
	end
	if (BuildLength < 1) then
		AntiObstruct()
		PlaceBlock()
		BuildLength = BuildLength + 1
	else
		roundCorner()
		BuildLength = BuildLength - 1
	end
	if (BuildLength < 2) then
		AntiObstruct()
		PlaceBlock()
		BuildLength = BuildLength + 1
	else
		roundCorner()
		BuildLength = BuildLength - 2
	end
	if (BuildLength < 10) then
		AntiObstruct()
		PlaceBlock()
		BuildLength = BuildLength + 1
	else
		roundCorner()
		BuildLength = BuildLength - 10
	end
end
term.clear()
BuildCylinder()
end -- here
end -- here
TechManDylan #4
Posted 28 March 2013 - 06:44 AM
Wow how easy thanks a lot maybe I will finish my program soon lol
Edit: Oh and thanks for pointing that out remiX I will indent it from now on
remiX #5
Posted 28 March 2013 - 06:47 AM
Wow how easy thanks a lot maybe I will finish my program soon lol
Edit: Oh and thanks for pointing that out remiX I will indent it from now on

Yeah, most of the time the errors you get are so simple to fix!

Sure :)/> It isn't a must but it just makes it easier for the reader to see what's going on.