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

Attempt to Call Nil Error

Started by Icyboom15, 22 December 2012 - 03:48 AM
Icyboom15 #1
Posted 22 December 2012 - 04:48 AM
Keep getting an "Attempt to Call Nil" error in line 6. Nothing I seem to do fixes it, though..



g = 0

print("Welcome to MineHall 2.0")

print("How long would you like the tunnel:")

len = tonumber(read())

turtle.select(1)

turtle.refuel()

while g < len do

turtle.dig()

turtle.forward()

turtle.digUp()

turtle.digDown()

g = g+1

end

print("Finished mining.")

Any and all help is appreciated. :)/>
anonimo182 #2
Posted 22 December 2012 - 05:05 AM
You need to select the quantity to refuel in turtle.refuel(), like: turtle.refuel(1) will refuel with 1 unit from selected slot
Icyboom15 #3
Posted 22 December 2012 - 05:13 AM
But if left blank, it refuels with the entire stack, no?

EDIT: Tried with (1) in the spot, still a nil value.
remiX #4
Posted 22 December 2012 - 05:20 AM
But if left blank, it refuels with the entire stack, no?

EDIT: Tried with (1) in the spot, still a nil value.

Yes.

What version of CC are you using, and have you maybe changed the settings for turtles to NOT use fuel.
Icyboom15 #5
Posted 22 December 2012 - 05:25 AM
I am using 1.3, as it is on a tekkit server, and although i am looking up how to, I have not altered the settings.

EDIT: Oh wait.. You don't even need fuel in 1.3, right? Or is that in both 1.3 and 1.4?
OmegaVest #6
Posted 22 December 2012 - 05:27 AM
You don't need fuel in 1.3.
Icyboom15 #7
Posted 22 December 2012 - 05:28 AM
Wow. What an idiot.. Thanks guys! Hahaha..
OmegaVest #8
Posted 22 December 2012 - 05:31 AM
Also, a good way to test whether a function exists is to fulfill its parameters (such as putting fuel in the selected slot, in this case), and then using it in an if statement. Most functions return true if they fire.
ChunLing #9
Posted 22 December 2012 - 12:23 PM
Just check if turtle.refuel then or print(type(turtle.refuel)).

But yeah, no refuel function in 1.3.