--Script by victorqyu aka. sol
--7/8/13
--For Computercraft for Minecraft
--For solar mining turtle.
--running arguments are x,y,z where;
--x = Number of cycles to move forward. (A cycle consists of 3 blocks on the axis of facing where the turtle occupies the central block) eg 10 cycles = 30 blocks
--y = the number of lines to mine to the left of the turtle.
--z = The starting height of the turtle (Used to calculate the fuel cost per cycle)
--
--Enderchest to store items in must be placed in the turtle's last inventory slot
--
local tArgs = { ... }
if #tArgs ~= 3 then --If number of args does not equal this, print useage scirpt
print( "Usage: mineAll <# cycles forwrd)> <# lines to the left> <fuel buffer(depth)>" )
return --Ends the program
end
-- VAR DEC's
local fwdCycleTarget = tonumber(tArgs[1]) --retrieve blocks to dig forward of turtle
local lftCycleTarget = tonumber(tArgs[2]) --retrieve blocks to dig left of turtle
local fuelBuffer = tonumber(tArgs[3]) --retrieve starting height.
local enoughFuel = false
local keepDigging = true
local oddRowNum = false
local miningComplete = false
local yCurPos = 0
local fwdCycleCurrent = 0
local lftCyclePos = 0
-- VAR DEC's
function waitForFuel() --wait for turtle to have enough fuel to complete a cycle.
print("Checking fuel level...")
enoughFuel = false
while enoughFuel == false do
if turtle.getFuelLevel() > (fuelBuffer*2) then
enoughFuel = true
else
print("Waiting for fuel...")
print("Fuel level is: "..turtle.getFuelLevel())
sleep(5)
end
end
end
function dumpInvToChest() --place all items in inv into enderchest (retrieved from inv slot 16)
print("Clearning inventory...")
turtle.dig()
turtle.select(16)
turtle.place()
sleep(1)
for i = 1,15 do
turtle.select(i)
turtle.drop()
end
turtle.select(16)
turtle.dig()
end
function digCycle() --Dig one cycle & move into pos for next & dump inv to enderchest
print("Begining dig cycle...")
keepDigging = true
yCurPos = 1000 --Arbitrary value so we dont deal with negatives
--Diging part of cycle
while keepDigging == true do
turtle.digDown()
turtle.dig()
if turtle.down() == false then
keepDigging = false
end
if keepDigging == true then
yCurPos = yCurPos-1 --If turtle moved down, lower the Y height var by 1
end
end
--Return part of cycle
turtle.turnLeft()
turtle.turnLeft()
while yCurPos < 1000 do
turtle.dig()
turtle.digUp()
turtle.up()
yCurPos = yCurPos+1
end
--call the dump to enderchest func. to clear inv.
turtle.turnLeft()
turtle.turnLeft()
dumpInvToChest()
end
function movePos() --Move into the next position
print("Moving position...")
if fwdCycleCurrent+1 < fwdCycleTarget then --move up if we haven't met cycle count
turtle.forward()
turtle.forward()
turtle.forward()
fwdCycleCurrent=fwdCycleCurrent+1
elseif lftCyclePos+1 < lftCycleTarget and oddRowNum == false then --Get into pos for return line
turtle.forward()
turtle.turnLeft()
turtle.forward()
turtle.turnLeft()
turtle.forward()
lftCyclePos = lftCyclePos+1
fwdCycleCurrent = 0
oddRowNum = true
elseif lftCyclePos+1 < lftCycleTarget and oddRowNum == true then --this part is for the return line
turtle.forward()
turtle.turnRight()
turtle.forward()
turtle.turnRight()
turtle.forward()
lftCyclePos = lftCyclePos+1
fwdCycleCurrent = 0
oddRowNum = false
else
miningComplete = true
print("Mining Complete.")
end
end
shell.run("refuel all")
while miningComplete == false do
waitForFuel()
digCycle()
movePos()
end
--7/8/13
--For Computercraft for Minecraft
--For solar mining turtle.
--running arguments are x,y,z where;
--x = Number of cycles to move forward. (A cycle consists of 3 blocks on the axis of facing where the turtle occupies the central block) eg 10 cycles = 30 blocks
--y = the number of lines to mine to the left of the turtle.
--z = The starting height of the turtle (Used to calculate the fuel cost per cycle)
--
--Enderchest to store items in must be placed in the turtle's last inventory slot
--
local tArgs = { ... }
if #tArgs ~= 3 then --If number of args does not equal this, print useage scirpt
print( "Usage: mineAll <# cycles forwrd)> <# lines to the left> <fuel buffer(depth)>" )
return --Ends the program
end
-- VAR DEC's
local fwdCycleTarget = tonumber(tArgs[1]) --retrieve blocks to dig forward of turtle
local lftCycleTarget = tonumber(tArgs[2]) --retrieve blocks to dig left of turtle
local fuelBuffer = tonumber(tArgs[3]) --retrieve starting height.
local enoughFuel = false
local keepDigging = true
local oddRowNum = false
local miningComplete = false
local yCurPos = 0
local fwdCycleCurrent = 0
local lftCyclePos = 0
-- VAR DEC's
function waitForFuel() --wait for turtle to have enough fuel to complete a cycle.
print("Checking fuel level...")
enoughFuel = false
while enoughFuel == false do
if turtle.getFuelLevel() > (fuelBuffer*2) then
enoughFuel = true
else
print("Waiting for fuel...")
print("Fuel level is: "..turtle.getFuelLevel())
sleep(5)
end
end
end
function dumpInvToChest() --place all items in inv into enderchest (retrieved from inv slot 16)
print("Clearning inventory...")
turtle.dig()
turtle.select(16)
turtle.place()
sleep(1)
for i = 1,15 do
turtle.select(i)
turtle.drop()
end
turtle.select(16)
turtle.dig()
end
function digCycle() --Dig one cycle & move into pos for next & dump inv to enderchest
print("Begining dig cycle...")
keepDigging = true
yCurPos = 1000 --Arbitrary value so we dont deal with negatives
--Diging part of cycle
while keepDigging == true do
turtle.digDown()
turtle.dig()
if turtle.down() == false then
keepDigging = false
end
if keepDigging == true then
yCurPos = yCurPos-1 --If turtle moved down, lower the Y height var by 1
end
end
--Return part of cycle
turtle.turnLeft()
turtle.turnLeft()
while yCurPos < 1000 do
turtle.dig()
turtle.digUp()
turtle.up()
yCurPos = yCurPos+1
end
--call the dump to enderchest func. to clear inv.
turtle.turnLeft()
turtle.turnLeft()
dumpInvToChest()
end
function movePos() --Move into the next position
print("Moving position...")
if fwdCycleCurrent+1 < fwdCycleTarget then --move up if we haven't met cycle count
turtle.forward()
turtle.forward()
turtle.forward()
fwdCycleCurrent=fwdCycleCurrent+1
elseif lftCyclePos+1 < lftCycleTarget and oddRowNum == false then --Get into pos for return line
turtle.forward()
turtle.turnLeft()
turtle.forward()
turtle.turnLeft()
turtle.forward()
lftCyclePos = lftCyclePos+1
fwdCycleCurrent = 0
oddRowNum = true
elseif lftCyclePos+1 < lftCycleTarget and oddRowNum == true then --this part is for the return line
turtle.forward()
turtle.turnRight()
turtle.forward()
turtle.turnRight()
turtle.forward()
lftCyclePos = lftCyclePos+1
fwdCycleCurrent = 0
oddRowNum = false
else
miningComplete = true
print("Mining Complete.")
end
end
shell.run("refuel all")
while miningComplete == false do
waitForFuel()
digCycle()
movePos()
end
No comments:
Post a Comment