Jump to content




Need help Debugging EOF


  • You cannot reply to this topic
3 replies to this topic

#1 loganic

  • New Members
  • 1 posts

Posted 30 June 2013 - 05:30 PM

I understand eof typically means I have one too many 'end', I dont think it does, so one of my functions doesn't seem to be reading then. I've done my best to format it to help make it easier.

Some background. I'm building a HS railroad, which every 6th block, has a powered track, and adjacent redstone torch + regular torch.
I plan on arranging brick slots 1-8, regular track 9-13, powered track 14, redstone torch 15, and regular torch 16.

I also bastardized some code from a platform script a friend wrote. Because of that I understand it's not really optimized.
The turtle should lay bricks, and then go up and put tracks & torchs.
Can someone help me find it?

[/size][/font]local fulllength = 6
local partiallength = fulllength -1
local crosslength = 3

local blockslot = 1
local trackslot = 9
local poweredslot = 14
local rstorchslot = 15
local torchslot =16
local slot = 1
local continue = true
turtle.select(blockslot)


turtle.dig()

turtle.forward()

while 
continue == true do
for j = 1, fulllength, 1 do


slot = blockslot
if turtle.getItemCount(slot) == 0 then
slot = slot + 1

blockslot = blockslot +1
turtle.select(slot)

if turtle.getItemCount(slot) == 0 then
continue = false
end
turtle.digDown()
turtle.placeDown()

else
turtle.digDown()

turtle.placeDown()

end

if j < fulllength then

turtle.dig()

turtle.forward()

end

end

turtle.back()
turtle.turnRight()
turtle.forward()
if turtle.getItemCount(slot) == 0 then
slot = slot + 1

blockslot = blockslot +1
turtle.select(slot)

if turtle.getItemCount(slot) == 0 then
continue = false
end
turtle.digDown()
turtle.placeDown()

else
turtle.digDown()

turtle.placeDown()

end

turtle.back()
turtle.back()
if turtle.getItemCount(slot) == 0 then
slot = slot + 1

blockslot = slot
turtle.select(slot)

if turtle.getItemCount(slot) == 0 then
continue = false
end
turtle.digDown()
turtle.placeDown()

else
turtle.digDown()

turtle.placeDown()

end

turtle.forward()
turtle.turnLeft()
turtle.up()
for j = 1, fulllength, 1 do
turtle.back()
end
for j = 1, partiallength, 1 do


slot = trackslot
if turtle.getItemCount(slot) == 0 then
slot = slot + 1

trackslot = slot
turtle.select(slot)

if turtle.getItemCount(slot) == 0 then
continue = false
end
turtle.digDown()
turtle.placeDown()

else
turtle.digDown()

turtle.placeDown()

end

if j < partiallength then

turtle.dig()

turtle.forward()

end

end



turtle.turnRight()
turtle.forward()
slot = rstorchslot
turtle.select(slot)

if turtle.getItemCount(slot) == 0 then
continue = false
else
turtle.digDown()

turtle.placeDown()

end

turtle.back()
turtle.back()
slot = torchslot
turtle.select(slot)

if turtle.getItemCount(slot) == 0 then
continue = false
else
turtle.digDown()

turtle.placeDown()

end
turtle.forward()
turtle.turnLeft()
turtle.down()
turtle.forward()
end

end[font=arial, sans-serif][size=3]


#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 01 July 2013 - 01:01 PM

Split into new topic.

Proper indentation is the biggest way to help prevent end expected and eof expected errors. For every block you open that requires an end, indent one level. When you put an end, un-indent one level (so the end is on the level of the statement it matches). It's easy to visually see where you have two ends on one level, or and end trying to dive off the left side of the document, etc.

#3 albrat

  • Members
  • 162 posts
  • LocationA Chair

Posted 02 July 2013 - 04:13 AM

I suggest to everyone who wants to debug a script with errors... Please get a copy of Notepad ++ :D/> great free tool that has language translations built into it. This colours and sorts code into blocks ( puts a + by every opening statement ) so you can visually see where each if / while / for statement opens and closes...

I am finding it difficult to read the program so I started to re-write it with indentations, comments.. (opening and closing comments for each end statement)

did you copy and paste some code for this ? You seem to have ended the while .. do loop in the middle of the program. Approx line 74 is the end of the program.

I marked the point where I think you have an extra end statement in your code. ( I think you could call some of the empty slot checks as a function. This would reduce your code length and make it much neater. )
Spoiler

function code I made for the check.
Spoiler


#4 albrat

  • Members
  • 162 posts
  • LocationA Chair

Posted 02 July 2013 - 05:46 AM

Btw to use the above function at any time ... type the following command :-

"empty, c = checkturt(maxslot)"

this will automatically end the program if the return is true. (which means the turtle is out of items)
Also if you call this after every action the turtle will always place items at the right times





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users