Posted 16 February 2020 - 02:42 AM
I am working on a turtle program that's supposed to build 4 walls. For some reason, I am getting the error "Expected number". The code from the line that the error is thrown from is code that I've used before(turtle.refuel(1) in other programs so I'm kind of confused right now. Forgive my ignorance on the subject, I have little experience with Lua. I'll point out in the code where the error is.
write("How wide should the room be?")
local x = tonumber(read())
write("How long should the room be?")
local y = tonumber(read())
write("How tall should the room be?")
local z = tonumber(read())
write("Place fuel in slot 1 and whatever building block you want to use in the rest and press enter to continue")
read()
function go()
turtle.forward()
slot = checkSlots()
turtle.select(slot)
turtle.placeUp()
checkFuel()
end
function checkFuel()
if turtle.getFuelLevel() == 0 then
turtle.refuel(1) [b] --Error happens here[/b]
end
end
function checkSlots()
for s=2,16,1 do
if turtle.getItemCount(s) > 0 then break end
end
return s
end
for h=0,z,1 do
for i=0,1,1 do
for w=0,y,1 do
go()
end
turtle.turnRight()
for l=0,x,1 do
go()
end
turtle.turnRight()
end
turtle.digDown()
turtle.down()
end