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

Custom Mining Program Won't Work

Started by JustDylan14, 09 February 2013 - 10:23 AM
JustDylan14 #1
Posted 09 February 2013 - 11:23 AM
Title: Custom Mining Program Won't Work

Here is my code-

--Variables

t = ("turtle")
local Args = {...}
local level = tonumber (Args[1])
local counter = 0

--Functions

function minedown()
   while counter ~= level do
	  t.dig()
	  t.turnLeft()
	  t.dig()
	  t. turnLeft
	  t.dig()
	  t.turnLeft()
	  t.dig()
	  t.turnLeft()
	  t.digUp()
	  t.up()
	  counter = counter - 1
   end
end

function mineup()
   while counter ~= 0 do

	  t.dig()
	  t.turnLeft()
	  t.dig()
	  t. turnLeft
	  t.dig()
	  t.turnLeft()
	  t.dig()
	  t.turnLeft()
	  t.digDown()
	  t.down()
	  counter = counter + 1
   end
   print("-Finished-")
end

--Code

if counter < level then
   print("Mining to level ", level)
end
if counter >= level then
   t.forward()
   t.dig()
   t.forward()
   t.dig()
   t.forward()
   mineup()
else
   minedown()
end
—————–
The error i get is ":12: attempt to call nil" when i run it.
I've squashed several other bugs, but this one has had me stumped for a few days now.
Any idea?
Edited by
Cranium #2
Posted 09 February 2013 - 01:22 PM
Split to new post. For future reference, use
 tags to add a code box to your post.
Kingdaro #3
Posted 09 February 2013 - 01:31 PM
This line:

t = ("turtle")

should be this:

t = turtle

Before, you were just setting it to a string with the text "turtle" instead of the actual turtle object.
JustDylan14 #4
Posted 09 February 2013 - 01:53 PM
Oh my goodness, can't believe it was that simple. Thanks alot Lua Maniac.