1

Hey y'all first time using lua in years, and highly inexperienced in it in the first place.
I wrote this program to go down a BuildCraft Quarry hole in the nether and remove lava as it finds it, but as I'm inexperienced, I'm getting issues and need help.
Code:

local left = true
local descended = false

local function refuel()
    if turtle.getFuelLevel() ~= "unlimited" and turtle.getFuelLeve() < 2 then
        turtle.refuel(1)
    end
end

local function forward()
    while(turtle.forward()) do
        turtle.suck()
        refuel()
    end
end

local function turn()
    if left then
        turtle.turnLeft()
    else
        turtle.turnRight()
    end
    turtle.suck()
    refuel()
    if not turtle.forward() then
        descend()
    end
    if left then
        turtle.turnLeft()
    else
        turtle.turnRight()
    end
    if not descended then 
        left = not left
    else
        descended = false
    end
end

local function descend()
    turtle.suckDown()
    refuel()
    while turtle.detectDown() do end
    turtle.down()
    descnded = true
end


while true do
    forward()
    turn()
end

Current Error: Line:46: attempt to call global 'forward' (a nil value)
Line in question:

while true do
    forward()   <--------
    turn()
end
pppery
  • 3,731
  • 22
  • 33
  • 46
Yawrf
  • 71
  • 1
  • 7
  • I just ran that script in a standalone lua demo https://www.lua.org/cgi-bin/demo and removed the bits specifically calling turtles, and it ran fine. That makes me think something with the turtle api itself is unhappy. – Rapitor Jan 28 '20 at 20:58

0 Answers0