Posted 01 January 2016 - 08:04 AM
I have gotten back into Feed The Beast Ultimate again and wrote a program to mine a 16x16 hole. I sorted out all the errors that were thrown and finally started the program, nothing happened. I was hoping that someone could help me with it.
My goal for this code was for the turtle to go forward 16 blocks while mining 3 blocks every time it moves forward, when it reaches the end of the 16 blocks it is supposed to turn, mine 3 blocks, move in the 3 blocks and then turn around and go back the way it came along the tunnel it just created.
The turtle would run until it ran out of chests to store the items in, which it would place every time the inventory filled to the max. It would do this by doing a 180 and placing the chest, and depositing all but the stored coal and chests in positions 1 and 2 respectively. The turtle would then turn back around the rest of the 360 and continue on mining. When the turtle finished it's 16x16x3 it would turn left to continue the pattern it had followed on the layer above and begin to go down 3 blocks to start a new layer of mining.
For now I have it refueling every time one of the functions is executed, I hope to make this a bit more efficient in the future.
I am also not sure if the turtle.suck method is being used properly and if it is actually needed at all, if someone could tell me whether or not the turtle automatically picks up the item, that would be appreciated.
I would appreciate any help and/ or tips concerning my code considering I have just started coding lua!
Here is the code:
My goal for this code was for the turtle to go forward 16 blocks while mining 3 blocks every time it moves forward, when it reaches the end of the 16 blocks it is supposed to turn, mine 3 blocks, move in the 3 blocks and then turn around and go back the way it came along the tunnel it just created.
The turtle would run until it ran out of chests to store the items in, which it would place every time the inventory filled to the max. It would do this by doing a 180 and placing the chest, and depositing all but the stored coal and chests in positions 1 and 2 respectively. The turtle would then turn back around the rest of the 360 and continue on mining. When the turtle finished it's 16x16x3 it would turn left to continue the pattern it had followed on the layer above and begin to go down 3 blocks to start a new layer of mining.
For now I have it refueling every time one of the functions is executed, I hope to make this a bit more efficient in the future.
I am also not sure if the turtle.suck method is being used properly and if it is actually needed at all, if someone could tell me whether or not the turtle automatically picks up the item, that would be appreciated.
I would appreciate any help and/ or tips concerning my code considering I have just started coding lua!
Here is the code:
function placeChest()
local firstItem = 3
local lastItem = 16
turtle.refuel()
turtle.turnLeft()
turtle.turnLeft()
if turtle.detect then
turtle.dig()
end
turtle.place(2)
for i = firstItem,lastItem do
turtle.select(i)
turtle.drop(64)
end
turtle.turnLeft()
turtle.turnLeft()
end
function digSixteenBlocks()
local fullInv
for x = 1,16,1 do
turtle.refuel()
if turtle.detect then
turtle.dig()
turtle.suck()
fullInv = turtle.suck()
if fullInv == false then
placeChest()
turtle.suck()
end
turtle.forward()
else
turtle.forward()
end
if turtle.detectUp then
turtle.digUp()
turtle.suckUp()
fullInv = turtle.suckUp()
if fullInv == false then
placeChest()
turtle.suckUp()
end
end
if turtle.detectDown then
turtle.digDown()
turtle.suckDown()
fullInv = turtle.suckDown()
if fullInv == false then
placeChest()
turtle.suckDown()
end
end
end
end
function turnAround()
local fullInv
turtle.refuel()
turtle.turnLeft()
if turtle.detect then
turtle.dig()
turtle.suck()
fullInv = turtle.suck()
if fullInv == false then
placeChest()
end
turtle.forward()
else
turtle.forward()
end
if turtle.detectUp then
turtle.digUp()
turtle.suckUp()
fullInv = turtle.suckUp()
if fullInv == false then
placeChest()
end
end
if turtle.detectDown then
turtle.digDonw()
turtle.suckDown()
fullInv = turtle.suckDown()
if fullInv == false then
placeChest()
end
end
turtle.turnLeft()
end
function goDown()
local fullInv
turtle.refuel()
for x = 0,2,1 do
if turtle.detectDown then
turtle.digDown()
turtle.suckDown()
fullInv = turtle.suckDown()
if fullInv == false then
placeChest()
end
turtle.down()
end
end
turtle.turnLeft()
end
chestCount = turtle.getItemCount(2)
while not chestCount == 1 do
for i = 1,16,1 do
digSixteenBlocks()
turnAround()
turtle.turnLeft()
end
goDown()
end