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

bios 338 help

Started by jakemg, 05 April 2013 - 07:28 AM
jakemg #1
Posted 05 April 2013 - 09:28 AM
Im getting error ":38: end expected (to close function at line 29)



local args = {...}
local times = tonumber(args[1]) -- this is how many times we want
for i=1, times do
function dig()
turtle.select(1)
turtle.dig()
turtle.forward()
turtle.digUp()
turtle.up()
turtle.turnRight()
turtle.dig()
turtle.forward()
turtle.digDown()
turtle.down()
turtle.turnLeft()
turtle.dig()
turtle.forward()
turtle.digUp()
turtle.up()
turtle.turnLeft()
turtle.dig()
turtle.forward()
turtle.turnRight()
turtle.digDown()
turtle.down()
end
function empty()
  if turtle.getItemCount(16) > 15 then
    turtle.digUp()
    turtle.placeUp(1)
    for i=1,16 do
    turtle.dropUp(i)
    turtle.select(1)
    end
  turtle.digUp()
end
Telokis #2
Posted 05 April 2013 - 09:30 AM
Im getting error ":38: end expected (to close function at line 29)



local args = {...}
local times = tonumber(args[1]) -- this is how many times we want
for i=1, times do
function dig()
turtle.select(1)
turtle.dig()
turtle.forward()
turtle.digUp()
turtle.up()
turtle.turnRight()
turtle.dig()
turtle.forward()
turtle.digDown()
turtle.down()
turtle.turnLeft()
turtle.dig()
turtle.forward()
turtle.digUp()
turtle.up()
turtle.turnLeft()
turtle.dig()
turtle.forward()
turtle.turnRight()
turtle.digDown()
turtle.down()
end
function empty()
  if turtle.getItemCount(16) > 15 then
    turtle.digUp()
    turtle.placeUp(1)
    for i=1,16 do
    turtle.dropUp(i)
    turtle.select(1)
    end
  turtle.digUp()
end

Hi !
If you indent your code, you can see there are 2 "end" missing. You don't close your "empty" function and you don't close your "for" statement.
I really recommend you to always indent your code.
jakemg #3
Posted 05 April 2013 - 09:32 AM
what ends am i missing??
Telokis #4
Posted 05 April 2013 - 09:35 AM
Here is your indented code :


local args = {...}
local times = tonumber(args[1]) -- this is how many times we want
for i=1, times do
function dig()
  turtle.select(1)
  turtle.dig()
  turtle.forward()
  turtle.digUp()
  turtle.up()
  turtle.turnRight()
  turtle.dig()
  turtle.forward()
  turtle.digDown()
  turtle.down()
  turtle.turnLeft()
  turtle.dig()
  turtle.forward()
  turtle.digUp()
  turtle.up()
  turtle.turnLeft()
  turtle.dig()
  turtle.forward()
  turtle.turnRight()
  turtle.digDown()
  turtle.down()
end
function empty()
    if turtle.getItemCount(16) > 15 then
	  turtle.digUp()
	  turtle.placeUp(1)
	  for i=1,16 do
	   turtle.dropUp(i)
	   turtle.select(1)
	  end
	 turtle.digUp()
  end

What do you think about it ?

Edit:
Well… I can't indent your code without correct it… :/
Kingdaro #5
Posted 05 April 2013 - 09:37 AM
The last function is missing an end.


function empty()
  if turtle.getItemCount(16) > 15 then
    turtle.digUp()
    turtle.placeUp(1)
    for i=1,16 do
      turtle.dropUp(i)
      turtle.select(1)
    end -- ending the for
    turtle.digUp()
  end -- ending the if
-- ???
jakemg #6
Posted 05 April 2013 - 09:39 AM
theres an error in your code i tried to run it but i got then expected at line 28
—->(this is line 28) if turtle.getItemCount(16) > 15 then
Telokis #7
Posted 05 April 2013 - 09:41 AM
theres an error in your code i tried to run it but i got then expected at line 28 —->(this is line 28) if turtle.getItemCount(16)>15then

I didn't correct your code, I just shew you you were missing some end statements.
"end" is used to close functions, "if" statements and "for" statements. You understand ?
jakemg #8
Posted 05 April 2013 - 09:42 AM
Okay so I used your function Doctor but now im getting error

":37: 'end' expected (to close for at line 3)"
Telokis #9
Posted 05 April 2013 - 09:44 AM
He isn't correcting you, he just shows you where the "end" is missing. You have to add it in his code.
jakemg #10
Posted 05 April 2013 - 09:45 AM
I did add it but i got that error
jakemg #11
Posted 05 April 2013 - 09:46 AM
Edit i fixed my problem but know i have another problem my turtle isnt running my code at all EX:i type "test 10" but it doesn't do anything


local args = {...}
local times = tonumber(args[1]) -- this is how many times we want
for i=1, times do
  function dig()
	turtle.select(1)
	turtle.dig()
	turtle.forward()
	turtle.digUp()
	turtle.up()
	turtle.turnRight()
	turtle.dig()
	turtle.forward()
	turtle.digDown()
	turtle.down()
	turtle.turnLeft()
	turtle.dig()
	turtle.forward()
	turtle.digUp()
	turtle.up()
	turtle.turnLeft()
	turtle.dig()
	turtle.forward()
	turtle.turnRight()
	turtle.digDown()
	turtle.down()
	end
  end
  function empty()
	if turtle.getItemCount(16) > 15 then
	  turtle.digUp()
	  turtle.placeUp(1)
	  for i=1,16 do
		turtle.dropUp(i)
		turtle.select(1)
	  end -- ending the for
	  turtle.digUp()
	end -- ending the if
end
Telokis #12
Posted 05 April 2013 - 09:50 AM
You create functions but you never call them !
To call the empty function, you have to write "empty()".
LBPHacker #13
Posted 05 April 2013 - 09:50 AM
-snip-
You've declared your function "times" times, but you didn't actually call them.

Declare the functions outside the for loop and call the function with dig() and empty(). I mean…



function empty()
	if turtle.getItemCount(16) > 15 then
		turtle.digUp()
		turtle.placeUp(1)
		for i=1,16 do
			turtle.dropUp(i)
			turtle.select(1)
		end -- ending the for
		turtle.digUp()
	end -- ending the if
end

function dig()
	turtle.select(1)
	turtle.dig()
	turtle.forward()
	turtle.digUp()
	turtle.up()
	turtle.turnRight()
	turtle.dig()
	turtle.forward()
	turtle.digDown()
	turtle.down()
	turtle.turnLeft()
	turtle.dig()
	turtle.forward()
	turtle.digUp()
	turtle.up()
	turtle.turnLeft()
	turtle.dig()
	turtle.forward()
	turtle.turnRight()
	turtle.digDown()
	turtle.down()
end

local args = {...}
local times = tonumber(args[1]) -- this is how many times we want

empty()

for i=1, times do
	dig()
end

EDIT: Yay ninja'd :D/>
jakemg #14
Posted 05 April 2013 - 09:53 AM
Oh my god im an idiot :unsure:/> sorry for wasting your guys's time lol