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

bios:339: [string "q"]:37: '<eof>' expected

Started by Waffy, 12 April 2014 - 04:55 PM
Waffy #1
Posted 12 April 2014 - 06:55 PM
My program has two seperate functions that sometimes when i use one input it completes that function and does the next one without any seperate input. but when i use end twice i get a bios 339.
my code is here http://pastebin.com/mceNvrY2
Bomb Bloke #2
Posted 13 April 2014 - 12:03 AM
The first "end" in your script probably shouldn't be located where it is.

Here's a bit of a re-write, which tries not to ditch your original structure entirely. Note how the indendation makes it very easy to see where each block ("if" / "for" / "elseif") starts and ends. You can hopefully see how you might trim it down further.

Spoiler
print("Please enter square size:")
local size = tonumber(read())

print("\"q\" for a walkway, \"r\" to just dig:")
local input = read()

turtle.select(1)

if input == "q" then
	for j=1,4 do
		for i = 1,size do
			turtle.dig()
			turtle.forward()
			turtle.digDown()
			turtle.placeDown()
		end

		turtle.turnRight()
		if j == 2 then turtle.select(2) end
	end
elseif input == "r" then
	for j=1,4 do
		for i = 1,size do
			turtle.dig()
			turtle.forward()
			turtle.digDown()
		end

		turtle.turnRight()
		if j == 2 then turtle.select(2) end
	end
end

print("You're Welcome")
Waffy #3
Posted 13 April 2014 - 01:12 AM
Thank you so much. Im new to lua and was wondering if you could put sidenotes next to the commands with the small explanation so I can understand the full code and implement that into later projects.