Posted 27 June 2013 - 10:16 AM
Here is the functioning part of the code. I have no idea why it is not looping, it seems to me like it should but it does not. Any help would be appreciated.
If you think it might be the functions causing the problems, though I think they are fine, here they are.
Note: It does not give me errors, The program simply ends after it chops down the tree and posts up the stats.
if not (bm == y) or (bm == n) then
term.clear()
write("would you like to enable bonemeal refueling? (y/n): ")
local bm = read()
chop = 1
else
end
if chop == 1 then
while true do
if fe1 == 0 then
fe = turtle.getFuelLevel()
else
end
sleep(0)
if turtle.getItemCount(1) < 2 then
fg()
else
end
sleep(0)
if turtle.getFuelLevel() < 60 then
rf()
else
end
sleep(0)
if (bm == y) and (turtle.getItemCount(16) < 1) then
rb()
else
end
sleep(0)
if (z == 0) and (x == 0) and (finished == 0) and turtle.detect() then
df()
end
while (finished == 0) and (z == 1) and turtle.detectUp() do
du()
end
while (finished == 0) and (z == 1) and (x > 0) and not turtle.detectUp() and not turtle.detectDown() do
turtle.down()
end
if (finished == 0) and (z == 1) and (x > 0) and not turtle.detectUp() and turtle.detectDown() then
ft()
end
end
end
If you think it might be the functions causing the problems, though I think they are fine, here they are.
Spoiler
local function rf()
turtle.select(1)
turtle.refuel(1)
f = f + 1
end
local function rb()
turtle.select(16)
turtle.suckUp(5)
end
local function fg()
turtle.select(1)
turtle.turnLeft()
turtle.suck(31)
if false then
term.clear()
print("no charcoal available in fuel chest")
else
end
turtle.turnRight()
end
local function df()
turtle.select(2)
turtle.dig()
if true then
turtle.forward()
if true then
z = (z+1)
end
end
end
local function du()
turtle.digUp()
if true then
turtle.up()
if true then
x = (x+1)
end
end
end
local function rn()
turtle.back()
if true then
z = (z-1)
if true then
finished = 1
end
end
end
local function w()
while w == 1 do
turtle.select(15)
sleep(60)
if not turtle.compare() then
w = 0
end
end
end
local function ft()
rn()
t = t + 1
term.clear()
print("".. t .. " tree(s) removed")
tw = (tw + turtle.getItemCount(2))
print("" .. tw .. " blocks of wood collected")
print("" .. f .. " piece(s) of coal used")
-- efficiency math
ie = ((((tw/5)/5)*80)+ turtle.getFuelLevel())/(fe1 - turtle.getFuelLevel())
if t == 1 then
e = ie
else
e = ((((tw/5)/5)*80)+ turtle.getFuelLevel())/(fe1 + f - turtle.getFuelLevel())
end
-- end efficiency math
print("reported efficiency rating of " .. e .. "")
turtle.turnRight()
turtle.select(2)
turtle.drop(64)
turtle.turnLeft()
finished = 0
turtle.select(15)
turtle.place()
turtle.select(16)
if turtle.getItemCount(16) == 0 then
w = 1
w()
else
turtle.place()
end
end
Note: It does not give me errors, The program simply ends after it chops down the tree and posts up the stats.