Jump to content




bios 338 help


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

#1 jakemg

  • Members
  • 88 posts

Posted 05 April 2013 - 08: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


#2 Telokis

  • Members
  • 88 posts
  • LocationToulouse, France

Posted 05 April 2013 - 08:30 AM

View Postjakemg, on 05 April 2013 - 08:28 AM, said:

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.

#3 jakemg

  • Members
  • 88 posts

Posted 05 April 2013 - 08:32 AM

what ends am i missing??

#4 Telokis

  • Members
  • 88 posts
  • LocationToulouse, France

Posted 05 April 2013 - 08: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... :/

#5 Kingdaro

    The Doctor

  • Members
  • 1,636 posts
  • Location'MURICA

Posted 05 April 2013 - 08: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
-- ???


#6 jakemg

  • Members
  • 88 posts

Posted 05 April 2013 - 08: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)>15then

#7 Telokis

  • Members
  • 88 posts
  • LocationToulouse, France

Posted 05 April 2013 - 08:41 AM

View Postjakemg, on 05 April 2013 - 08:39 AM, said:

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 ?

#8 jakemg

  • Members
  • 88 posts

Posted 05 April 2013 - 08:42 AM

Okay so I used your function Doctor but now im getting error

":37: 'end' expected (to close for at line 3)"

#9 Telokis

  • Members
  • 88 posts
  • LocationToulouse, France

Posted 05 April 2013 - 08:44 AM

He isn't correcting you, he just shows you where the "end" is missing. You have to add it in his code.

#10 jakemg

  • Members
  • 88 posts

Posted 05 April 2013 - 08:45 AM

I did add it but i got that error

#11 jakemg

  • Members
  • 88 posts

Posted 05 April 2013 - 08: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


#12 Telokis

  • Members
  • 88 posts
  • LocationToulouse, France

Posted 05 April 2013 - 08:50 AM

You create functions but you never call them !
To call the empty function, you have to write "empty()".

#13 LBPHacker

  • Members
  • 766 posts
  • LocationBudapest, Hungary

Posted 05 April 2013 - 08:50 AM

View Postjakemg, on 05 April 2013 - 08:46 AM, said:

-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

#14 jakemg

  • Members
  • 88 posts

Posted 05 April 2013 - 08:53 AM

Oh my god im an idiot :unsure: sorry for wasting your guys's time lol





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users