Posted 22 January 2013 - 02:58 PM
I can't figure out what's wrong with this. getItemCount() returns an integer according to the wiki. Please help.
Error message says:
Refering to the line
The (incomplete) program:
Thanks for the help. I have a lot to learn for sure!
Error message says:
pad:19: Expected number
Refering to the line
count = count + turtle.getItemCount()
function checkInv()
turtle.select(1)
local count = 0
for i = 1, 16 do
turtle.select(i)
count = count + turtle.getItemCount()
end
if count >= totalblocks then
return true
else
return false
end
end
The (incomplete) program:
Spoiler
-- START VARIABLES --
local width = 0
local length = 0
local totalblocks = 0
local fuellevel = 0
local xpos = 0
local ypos = 0
local invslot
-- END VARIABLES --
-- START FUNCTIONS --
function checkInv()
turtle.select(1)
local count = 0
for i = 1, 16 do
turtle.select(i)
count = count + turtle.getItemCount()
end
if count >= totalblocks then
return true
else
return false
end
end
function placeX(width)
if turtle.detect() then
turtle.dig()
turtle.forward()
xpos = xpos + 1
turtle.placeDown()
end
end
-- END FUNCTIONS --
print("Welcome to the pad builder!")
print("---------------------------")
print("How wide should the pad be?")
width = io.read()
print("Width " .. width)
print("How long should the pad be?")
length = io.read()
print("Width " .. width)
print("Length " .. length)
totalblocks = width * length
print("You need " .. totalblocks .. " blocks to accomplish this.")
fuellevel = turtle.getFuelLevel()
print("You have " .. fuellevel .. " fuel.")
print("You need " .. totalblocks .. " fuel.")
if fuellevel < totalblocks then
print("Not enough fuel to perform this action. Exiting.")
sleep(5)
shell.exit()
end
if not checkInv() then
print("Not enough blocks")
end
Thanks for the help. I have a lot to learn for sure!