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

Error Calling Function

Started by DragonDonut, 25 February 2012 - 05:40 PM
DragonDonut #1
Posted 25 February 2012 - 06:40 PM
Hi, I am testing around a little with the turtle and get a nil error when i try to call a function

thx for the help DragonDonut

Code:

local num1 = 0
local num2 = 0
mine()

local function mine()
if not turtle.detect() then
turtle.digDown()
turtle.down()
while num1 ~= 5 do
turtle.dig()
turtle.forward()
num1 = num1 + 1
end
if num1 == 5 and num2 ~= 1 then
turtle.turnLeft()
turtle.dig()
turtle.forward()
turtle.turnLeft()
num1 = 0
num2 = 1
elseif num1 == 5 and num2~=0 then
turtle.turnRight()
turtle.dig()
turtle.forward()
turtle.turnRight()
num1 = 0
num2 = 0
end
end
end
Espen #2
Posted 25 February 2012 - 06:43 PM
You're trying to call mine() before it has been defined.
Call it after its definition and the you should be ok.
DragonDonut #3
Posted 25 February 2012 - 06:46 PM
Thx, I should have read the codex of error slaying first…