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

Turtle mining program

Started by HurdeHack, 26 December 2013 - 02:33 PM
HurdeHack #1
Posted 26 December 2013 - 03:33 PM
Hi
i wanted to make my first lua script ever on an turtle here it is :


local DIGDOWN = turtle.digDown()
local DIGUP = turtle.digUp()
local TURNLEFT = turtle.turnLeft()
local TURNRIGHT = turtle.turnRight()
local VOORUIT = turtle.forward()
function TUNNEL()
  DIGDOWN()
  TURNRIGHT()
  VOORUIT()
  TURNLEFT()
  DIGDOWN()
  VOORUIT()
  DIGDOWN()
  TURNLEFT()
  VOORUIT()
  DIGDOWN()
  VOORUIT()
  DIGDOWN()
  TURNLEFT()
  VOORUIT()
  DIGDOWN()
  VOORUIT()
  DIGDOWN()
  TURNLEFT()
  VOORUIT()
  DIGDOWN()
  VOORUIT()
  DIGDOWN()
  VOORUIT()
  TURNLEFT()
  VOORUIT()
  TURNRIGHT()
end
TUNNEL()

but it doesn't works
it says -tunneldown:8: attempt to call boolean
i dont know what's wrong ?
any idea what it could be ?
enforcer4100 #2
Posted 26 December 2013 - 04:20 PM
You are storing a variable. You need to make a function.

function digdown()
turtle.digdown()
end

Also you might want to use a loop instead of that tunnel function/
 
while true do
digdown() -- this is the function you wrote above
digup() --- etc etc
end

Note that this will cause your turtle to dig endlessly long so you may want to add a detect function in there.
Edited on 26 December 2013 - 03:26 PM
MudkipTheEpic #3
Posted 26 December 2013 - 04:25 PM
Instead of assigning DIGDOWN, DIGUP, etc. to the functions, you are calling the functions themselves and assigning the variables to the success of the functions. Hence, you get attempt to call boolean. (A boolean is true/false.) The solution would be to change
local DIGDOWN = turtle.digDown()
to
local DIGDOWN = turtle.digDown
to store the functions instead of their success. Do the same for the rest of the declarations.

You are storing a variable. You need to make a function.

function digdown()
turtle.digdown()
end

That would error attempt to call nil on line 2.
Edited on 26 December 2013 - 03:26 PM
HurdeHack #4
Posted 26 December 2013 - 04:42 PM
That Fixed the whole programs i've changed it to

local DIGDOWN = turtle.digDown
local DIGUP = turtle.digUp
local TURNLEFT = turtle.turnLeft
local TURNRIGHT = turtle.turnRight
local VOORUIT = turtle.forward
function TUNNEL()
  turtle.digDown()
  turtle.turnRight()
  turtle.forward()
  turtle.turnLeft()
  turtle.digDown()
  turtle.forward()
  turtle.digDown()
  turtle.turnLeft()
  turtle.forward()
  turtle.digDown()
  turtle.forward()
  turtle.digDown()
  turtle.turnLeft()
  turtle.forward()
  turtle.digDown()
  turtle.forward()
  turtle.digDown()
  turtle.turnLeft()
  turtle.forward()
  turtle.digDown()
  turtle.forward()
  turtle.digDown()
  turtle.forward()
  turtle.turnLeft()
  turtle.forward()
  turtle.turnRight()
  turtle.down()
end
while true do
TUNNEL()
end

And now it works Thank you guy's Very much
i only need to remove the things above and then its complete
Edited on 26 December 2013 - 03:43 PM