Posted 27 February 2015 - 11:19 AM
Hey, i just wrote turtle program to build bridges, and after entering numbers in first part of program (just after start) i keep getting: bb:21: attempt to compare function with number error. Please how do I fix it! I only know that it is line 21!
http://pastebin.com/Ae3YheHg
fuel = turtle.getFuelLevel()
term.clear()
turtle.select(1)
term.setCursorPos(2, 6)
textutils.slowPrint("Enter how long should the bridge be?")
term.setCursorPos(2, 7)
textutils.slowPrint("DO NOT ENTER LETTERS OR I WILL CRASH")
term.setCursorPos(19, 8)
long = read()
if tonumber(long) > 20 then
term.clear()
term.setCursorPos(15, 6)
textutils.slowPrint("Too long")
sleep(5)
term.clear()
term.setCursorPos(1, 1)
return
end
should = tonumber(long)*3
is = turtle.getItemCount
if is == should or is > should then
for i= 1, tonumber(long) do
if fuel > 1000 then
sleep(2)
term.clear()
term.setCursorPos(1, 1)
print("Enugh fuel. Working")
term.setCursorPos(1, 2)
print(i)
turtle.back()
turtle.place()
turtle.turnLeft()
turtle.forward()
turtle.turnRight()
turtle.place()
turtle.turnRight()
turtle.forward()
turtle.forward()
turtle.turnLeft()
turtle.place()
turtle.turnLeft()
turtle.forward()
turtle.turnRight()
else
term.clear()
term.setCursorPos(1, 1)
term.print("Not enugh fuel")
break
end
end
else
term.clear()
term.setCursorPos(1, 1)
textutils.slowPrint("Sorry. Not enugh items in slot 1!")
sleep(5)
term.clear()
term.setCursorPos(1, 1)
return
end
Pastebin:http://pastebin.com/Ae3YheHg