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

I need help with a refuel code for my mining turtle

Started by junkmortha, 18 February 2013 - 04:23 PM
junkmortha #1
Posted 18 February 2013 - 05:23 PM
Title: I need help with a refuel code for my mining turtle

So here is my code

print "CheckingFuel…"

if turtle.getFuelLevel() < 200 then
turtle.refuel(1)
print "Refuelling.."
else
print "Enough fuel"
end

ok so i saved it then exited.
I typed the codes folder name thingy whi is "test"
so i typed in "test" then i got the error

CheckingFuel…
test:3: attempt to call nil
remiX #2
Posted 19 February 2013 - 04:36 AM
it's saying that turtle.getFuelLevel is not a valid function… hmm
Try restarting the computer and start the program, if not type in lua in the console and type turtle and tell us the outcome
nLgzHungryHiPPo #3
Posted 20 February 2013 - 02:57 PM
You need parentheses () around the print statement.
print ("like this")
print "this won't work"
immibis #4
Posted 20 February 2013 - 03:05 PM
You need parentheses () around the print statement.
print ("like this")
print "this won't work"
Actually you don't. But only if you're printing a single string - anything else needs the parentheses.

junkmortha, chances are you mistyped getFuelLevel in your program, but you typed it correctly when you made your post.