Wrote this function to handle refueling.
function juice() turtle.select(1) if turtle.getitemCount(1) < 1 then print ("Feed Me") repeat sleep (5) until turtle.getitemCount(1) > 10 end if turtle.getFuelLevel() < 5 then repeat print ("Fueling Standby") turtle.select(1) turtle.refuel(1) until turtle.getFuelLevel() > 50 end end
I am getting an "attemp to call nil" error on the first "if" statement. (should be coloured red) My problem is that I wrote the bottom "If" statement (coloured blue) for my first program and it works just fine. My question is do i have a problem with the lua syntax or the Turtle (api) or something else entirely.
I've put the whole program below for anyone who would like to look and see. Please keep in mind till a week ago i had no idea lua or computercraft existed. The blue text is my notes to myself while trying to learn this stuff. I've also never got this program to run past the error reprorted above so bugs, random capital letters, and other assorted screwups are still to be found therein.
P.S. If you know how to keep the formatting for text pasted into a post you could tack that on to your answer as well..
Spoiler
Edited by Lyqyd, 20 December 2012 - 07:02 PM.
added code tags