Posted 18 November 2014 - 10:10 PM
I cant find it. It is probably simple. Can anyone help.
Error: " bios:366: [string "miner"]:157: 'end' expected (to close 'for' at line 125) "
Code:
Error: " bios:366: [string "miner"]:157: 'end' expected (to close 'for' at line 125) "
Code:
-- before running program, be sure...
-- coal is in slot 16
-- cobble in slot 15
-- put an actual chest ABOVE the turtle that will be on the mission (empty) (for the loot)
-- put an actual chest BEHIND the turtle that will be on the mission (with more coal in it)
ypos = 0 -- This tracks how far down turtle is from its starting position
facing = 0 -- This tracks direction turtle is facing 0=original-front 1=left 2=right 3=back
mission = 1 -- Current status of mission.
-- 0 means mission completed
-- 1 means operational mission, still running.
-- 2 means that it is time to drop off stuff then return to where u left off
-- 3 means that it is time to refuel
while mission ~= 0 do
FuelLeft = turtle.getFuelLevel() + 1
if FuelLeft < 65 then -- if there is less than 65 fuel in the turtle...
mission = 3
if turtle.getItemCount(16) > 0 then -- if there is at least 1 item in coal-slot 16...
turtle.select(16) -- choose slot 16 on turtle
turtle.refuel(1) -- refuel turtle with 1 item from slot 16
turtle.select(1) -- choose slot 1 on turtle (default?)
mission = 1
else
-- coal slot is empty so go back and get more fuel into slot 16
yrem = ypos -- remember ypos before returning for fuel
facrem = facing -- remember facing before returning for fuel
if ypos == 0 then -- you are back at start
-- get turtle facing the chest (backwards from original direction
if facing == 0 then -- facing forward
turtle.turnLeft() -- turn left
turtle.turnLeft() -- turn left
facing = 3
end
if facing == 1 then -- facing left
turtle.turnLeft() -- turn left
facing = 3
end
if facing == 2 then -- facing right
turtle.turnRight() -- turn right
facing = 3
end
-- see if fuel chest is empty or not and get more fuel
turtle.select(16) -- choose slot 16 on turtle
turtle.suck() -- suck fuel out of chest into slot 16 if possible
turtle.turnRight() -- turning turtle back towards facing the front
facing = 1
turtle.turnRight() -- finishing turning turtle to facing the front
facing = 0
turtle.refuel(1) -- refuel turtle with 1 item from slot 16
turtle.select(1) -- choose slot 1 on turtle (default?)
FuelLeft = turtle.getFuelLevel() + 1
if FuelLeft < 65 then -- still less than 65 fuel after refueling attempt
print "Not enough fuel to continue mission."
else
-- RETURN TO POSITION PRIOR TO NEEDING FUEL IF NECESSARY
while yrem ~= ypos do
turtle.down()
ypos = ypos - 1
end
while facrem ~= facing do
turtle.turnRight()
if facing == 0 then -- 0=original-front 1=left 2=right 3=back
facing = 2
else
if facing == 1 then
facing = 0
else
if facing == 2 then
facing = 3
else
-- facing = 3
facing = 1
end
end
end
end
mission = 1
end
else
-- move back up to start
while ypos<0 and ypos~=0 do
turtle.up()
ypos = ypos + 1
end
end
end
else -- if there is NOT less than 65 fuel in the turtle...
if turtle.down() then -- it was able to move down
ypos = ypos - 1
else -- it cannot move down
-- find out what is below it and act accordingly
local b,t = turtle.inspectDown()
local x = data.name
if x == "minecraft:chest" then
turtle.suckDown()
turtle.select(15)
turtle.placeDown()
turtle.select(1)
mission = 2 -- drop off all new stuff after grabbing a rare chest
else
if x == "minecraft:bedrock" then -- bottom of the world
mission = 0
while ypos ~= 0 do
turtle.up()
ypos = ypos + 1
turtle.select(15)
turtle.placeDown()
turtle.select(1)
end
else
turtle.digDown()
turtle.down()
ypos = ypos - 1
-- turtle.select(15) Decided not to fill hole above turtle when going down
-- turtle.placeUp()
-- turtle.select(1)
end
end
end
if mission ~= 2 then
-- seal any holes around this location (main concern: lava)
for i = 1, 4 do
if turtle.detect()=="false" then
-- there is a hole
turtle.select(15)
turtle.place()
turtle.select(1)
turtle.turnLeft()
end
-- look around for goodies
flag = 0
for i = 1, 4 do
local b,t = turtle.inspect()
local x = data.name
if x == "minecraft:stone" then
flag = 1
end
if x == "minecraft:cobblestone" then
flag = 1
end
if x == "minecraft:dirt" then
flag = 1
end
-- if the flag is still zero, it may be valuable
-- and just get rid of gravel
if flag == 0 then
turtle.dig()
turtle.select(15)
turtle.place()
turtle.select(1)
end
turtle.turnLeft()
end
else
-- mission = 2 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-- 2 means that it is time to drop off stuff then return to where u left off
-- there is a chest ABOVE the turtle start position for the loot
yrem = ypos -- remember ypos before returning for fuel
while ypos ~= 0 do
turtle.up()
ypos = ypos + 1
end
for i = 1, 14 do
turtle.select(i)
turtle.dropUp()
end
turtle.select(1)
while yrem ~= ypos do
turtle.down()
ypos = ypos - 1
end
end
end
end