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

Error with my house code :/

Started by Kasea, 16 January 2014 - 09:23 AM
Kasea #1
Posted 16 January 2014 - 10:23 AM
http://pastebin.com/mrjiYKjU

This is my code, and i get the following error message - eof expected at the line.

please help :D/>
LBPHacker #2
Posted 16 January 2014 - 11:14 AM
At which line? And by the way, what are those {base things?
Kasea #3
Posted 16 January 2014 - 11:20 AM
The last line, it is the things that are copied, it's basically the part where it places a block under it, moves forward etc
LBPHacker #4
Posted 16 January 2014 - 11:30 AM
Oh, in that case, the last end causes the problems. Just remove it.
CometWolf #5
Posted 16 January 2014 - 11:42 AM
Running this script just throws errors on the }base things right away…. Anyways, if they were not present you would get an Eof error at the end on the last line, as there is no block for it to close. In other words, you have too many "end"s, just remove the bottom one. And another quick thing, for the love of god read up on functions! Instead of doing the same code over and over and over again, define it as a function.

local turtle.placeDownBackup = turtle.placeDown
local function turtle.placeDown()
  for i = 1, 16 do
    if turtle.getItemCount(i) > 0 then -- check slot for items
	  turtle.select(i) -- note that i corrected this for you, like we said you should have in the original thread....
	  break --ends loop if item in slot
    end
  end
  turtle.placeDownBackup()
end
This will redefine turtle.placeDown() so it will always check it's inv prior to placing the block. but before you try this, PLEASE READ THIS!
http://computercraft.info/wiki/Function_%28type%29
MudkipTheEpic #6
Posted 16 January 2014 - 10:49 PM
Running this script just throws errors on the }base things right away…. Anyways, if they were not present you would get an Eof error at the end on the last line, as there is no block for it to close. In other words, you have too many "end"s, just remove the bottom one. And another quick thing, for the love of god read up on functions! Instead of doing the same code over and over and over again, define it as a function.

local turtle.placeDownBackup = turtle.placeDown
local function turtle.placeDown()
  for i = 1, 16 do
    if turtle.getItemCount(i) > 0 then -- check slot for items
	  turtle.select(i) -- note that i corrected this for you, like we said you should have in the original thread....
	  break --ends loop if item in slot
    end
  end
  turtle.placeDownBackup()
end
This will redefine turtle.placeDown() so it will always check it's inv prior to placing the block. but before you try this, PLEASE READ THIS!
http://computercraft.info/wiki/Function_%28type%29

Change line 1 to turtle.placeDownBackup=turtle.down, you cannot create a local entry to a table.

Also change line 2 to turtle.placeDown.
Edited on 16 January 2014 - 09:49 PM
CometWolf #7
Posted 17 January 2014 - 02:39 AM
Right you are, thats what i get for not running the code :P/>