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

I'm new to computercraft please help.

Started by chardo440, 07 October 2012 - 01:12 AM
chardo440 #1
Posted 07 October 2012 - 03:12 AM

function dig()
   for i=1, 75 do
   turtle.dig()
   turtle.digUp()
   turtle.forward()
end
function refuel()
   turtle.select(1)
   turtle.refuel(5)
end
function turn()
   turtle.left()
   turtle.left()
end
function back()
   for i=1, 75 do
   turtle.forward()
end
function torch()
   for i=1, 7 do
   turtle.select(2)
   turtle.placeDown(2)
end
function cleartext()
   term.clear()
   holder("My Miner ", 1,1
   term.setCursorPos(1,3)
end
function holder(string, columnVar,rowVar)
   term.setCursorPos(columnVar, rowVar)
   write (string)
end
end
end
end
cleartext()
print("Welcome to this unworking program! ")
sleep(1)
cleartext()
print("Lets get started")
sleep(1)
print("Starting...")





It tells me that I'm trying to call nil or something when it's supposed to start it's cleartext() function? what did I do wrong?
chiloxsan #2
Posted 07 October 2012 - 03:37 AM

function dig()
   for i=1, 75 do
    turtle.dig()
    turtle.digUp()
    turtle.forward()
   end
end
function refuel()
   turtle.select(1)
   turtle.refuel(5)
end
function turn()
   turtle.left()
   turtle.left()
end
function back()
   for i=1, 75 do
    turtle.forward()
   end
end
function torch()
   for i=1, 7 do
    turtle.select(2)
    turtle.placeDown(2)
   end
end
function cleartext()
   term.clear()
   holder("My Miner ", 1,1)
   term.setCursorPos(1,3)
end
function holder(string, columnVar,rowVar)
   term.setCursorPos(columnVar, rowVar)
   write(string)
end
cleartext()
print("Welcome to this unworking program! ")
sleep(1)
cleartext()
print("Lets get started")
sleep(1)
print("Starting...")

I have detected that you do not close off your for loops. When calling any type of loop, make sure you close off the block you want to repeat with an end statement.
Since you did not close off your for loops, the Lua interpreter did not define your cleartext() function. Also, you forgot the closing bracket on your call to holder in the cleartext() function.
chardo440 #3
Posted 07 October 2012 - 03:48 AM
I got it working thank you so much.