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
This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
bios 338 help
Started by jakemg, 05 April 2013 - 07:28 AMPosted 05 April 2013 - 09:28 AM
Im getting error ":38: end expected (to close function at line 29)
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.
Posted 05 April 2013 - 09:32 AM
what ends am i missing??
Posted 05 April 2013 - 09:35 AM
Here is your indented code :
What do you think about it ?
Edit:
Well… I can't indent your code without correct it… :/
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… :/
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
-- ???
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
—->(this is line 28) if turtle.getItemCount(16) > 15 then
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 ?
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)"
":37: 'end' expected (to close for at line 3)"
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.
Posted 05 April 2013 - 09:45 AM
I did add it but i got that error
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
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()".
To call the empty function, you have to write "empty()".
Posted 05 April 2013 - 09:50 AM
You've declared your function "times" times, but you didn't actually call them.-snip-
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/>
Posted 05 April 2013 - 09:53 AM
Oh my god im an idiot :unsure:/> sorry for wasting your guys's time lol