Compare commits
17 Commits
e68905578f
...
master
Author | SHA1 | Date | |
---|---|---|---|
8a3bd602c8 | |||
da931b0e3d | |||
7d6f7a4085 | |||
f988e1fd10 | |||
4b2201e544 | |||
55ef03625a | |||
d7226d2cac | |||
e8d03a1211 | |||
21b3cce893 | |||
591b06aa19 | |||
58f282e0bf | |||
a1a3673536 | |||
69e0a4555a | |||
8e92de7a16 | |||
d6e6f6b850 | |||
68fa543ca7 | |||
df7f7bbb7e |
103
Mining_Things/digtunnel.lua
Normal file
103
Mining_Things/digtunnel.lua
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
--[[digtunnel program from Sascha
|
||||||
|
Dig a tunnel until bedrock]]
|
||||||
|
|
||||||
|
os.loadAPI('hare')
|
||||||
|
isBedrock = false
|
||||||
|
level = 0
|
||||||
|
|
||||||
|
function comming_back(distance)
|
||||||
|
for i = 1, distance do
|
||||||
|
turtle.up()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function dig_around()
|
||||||
|
if is_bedrock() then
|
||||||
|
print('Found Bedrock. Comming back')
|
||||||
|
comming_back(level)
|
||||||
|
error('Done')
|
||||||
|
end
|
||||||
|
turtle.dig()
|
||||||
|
turtle.turnLeft()
|
||||||
|
if is_bedrock() == true then
|
||||||
|
print('Found Bedrock. Comming back')
|
||||||
|
comming_back(level)
|
||||||
|
error('Done')
|
||||||
|
end
|
||||||
|
turtle.dig()
|
||||||
|
turtle.turnRight()
|
||||||
|
turtle.turnRight()
|
||||||
|
if is_bedrock() then
|
||||||
|
print('Found Bedrock comming back')
|
||||||
|
comming_back(level)
|
||||||
|
error('done')
|
||||||
|
end
|
||||||
|
turtle.dig()
|
||||||
|
turtle.turnLeft()
|
||||||
|
end
|
||||||
|
|
||||||
|
function is_bedrock()
|
||||||
|
-- Check if we have Bedrock in Front
|
||||||
|
-- or underneath of us
|
||||||
|
local success, item = turtle.inspect()
|
||||||
|
if success == true and item['name'] == 'minecraft:bedrock' then
|
||||||
|
isBedrock = true
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
local success, item = turtle.inspectDown()
|
||||||
|
if success == true and item['name'] == 'minecraft;bedrock' then
|
||||||
|
isBedrock = true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
while isBedrock == false do
|
||||||
|
-- Dig one level down
|
||||||
|
if is_bedrock() then
|
||||||
|
print('Found Bedrock. Comming back')
|
||||||
|
comming_back(level)
|
||||||
|
error('Done')
|
||||||
|
end
|
||||||
|
turtle.digDown()
|
||||||
|
turtle.down()
|
||||||
|
level = level + 1
|
||||||
|
|
||||||
|
-- Dig a 3x3 Tunnel
|
||||||
|
dig_around()
|
||||||
|
turtle.forward()
|
||||||
|
dig_around()
|
||||||
|
turtle.forward()
|
||||||
|
turtle.turnLeft()
|
||||||
|
if is_bedrock() then
|
||||||
|
print('Found Bedrock. Comming back')
|
||||||
|
comming_back(level)
|
||||||
|
error('Done')
|
||||||
|
end
|
||||||
|
turtle.dig()
|
||||||
|
turtle.turnRight()
|
||||||
|
turtle.turnRight()
|
||||||
|
if is_bedrock() then
|
||||||
|
print('Found Bedrock. Comming back')
|
||||||
|
comming_back(level)
|
||||||
|
error('Done')
|
||||||
|
end
|
||||||
|
turtle.dig()
|
||||||
|
turtle.turnLeft()
|
||||||
|
|
||||||
|
-- place a ladder
|
||||||
|
local success, item = turtle.inspect()
|
||||||
|
if not success then
|
||||||
|
hare.selectItem('minecraft:cobblestone')
|
||||||
|
turtle.place()
|
||||||
|
end
|
||||||
|
turtle.back()
|
||||||
|
hare.selectItem('minecraft:ladder')
|
||||||
|
turtle.place()
|
||||||
|
hare.selectEmptySlot()
|
||||||
|
-- Go back to Start Position
|
||||||
|
turtle.back()
|
||||||
|
end
|
||||||
|
|
70
Mining_Things/mining_lane.lua
Normal file
70
Mining_Things/mining_lane.lua
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
os.loadAPI("modules.lua")
|
||||||
|
|
||||||
|
-- handle command line arguments
|
||||||
|
local cliArgs = {...}
|
||||||
|
local length = tonumber(cliArgs[1])
|
||||||
|
local height = tonumber(cliArgs[2])
|
||||||
|
|
||||||
|
if length == nil or height == nil or cliArgs[1] == '?' then
|
||||||
|
print('Usage: mining_lane <length> <height>')
|
||||||
|
print('length = How wide the turtle should dig.')
|
||||||
|
print('height = How high the turtle should dig.')
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Check if we have enough fuel.
|
||||||
|
local fuelNeeded = (height + 1) * (length + 1)
|
||||||
|
while (turtle.getFuelLevel() < fuelNeeded) do
|
||||||
|
local missingFuel = fuelNeeded - turtle.getFuelLevel()
|
||||||
|
print("Not enough fuel. Put items in slot 1 in the equivalent of " .. missingFuel .. " fuel")
|
||||||
|
read()
|
||||||
|
turtle.select(1)
|
||||||
|
turtle.refuel()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local front = true
|
||||||
|
|
||||||
|
-- Main Loop. Dig your tunnel
|
||||||
|
for j = 1, height do
|
||||||
|
for k = 1, length do
|
||||||
|
modules.check_fuel()
|
||||||
|
turtle.dig()
|
||||||
|
turtle.forward()
|
||||||
|
end
|
||||||
|
if j < height then
|
||||||
|
print('executing digup')
|
||||||
|
turtle.digUp()
|
||||||
|
modules.check_fuel()
|
||||||
|
turtle.up()
|
||||||
|
end
|
||||||
|
turtle.turnLeft()
|
||||||
|
turtle.turnLeft()
|
||||||
|
front = not front
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Go all the way down
|
||||||
|
for tdown = 1, height-1 do
|
||||||
|
modules.check_fuel()
|
||||||
|
turtle.down()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- If we are away from our starting point go back to your starting point
|
||||||
|
if not front then
|
||||||
|
for tfront = 1, length do
|
||||||
|
modules.check_fuel()
|
||||||
|
turtle.forward()
|
||||||
|
end
|
||||||
|
else
|
||||||
|
turtle.turnLeft()
|
||||||
|
turtle.turnLeft()
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Puke everything in your inventory out
|
||||||
|
modules.puke()
|
||||||
|
|
||||||
|
-- Turn left to set the turtle to the starting positin
|
||||||
|
turtle.turnLeft()
|
||||||
|
turtle.turnLeft()
|
49
Mining_Things/mining_room.lua
Normal file
49
Mining_Things/mining_room.lua
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
os.loadAPI("modules.lua")
|
||||||
|
|
||||||
|
function mine_line(length, height)
|
||||||
|
local front = true
|
||||||
|
-- Check if the user enters only 1 length or height.
|
||||||
|
-- This is too short
|
||||||
|
if length == 1 or height == 1 then
|
||||||
|
print('Please choose a number higher than 1 for length and height.')
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
for i = 1, height do
|
||||||
|
for j = 1, length do
|
||||||
|
modules.check_fuel()
|
||||||
|
turtle.dig()
|
||||||
|
turtle.forward()
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Check if this is the last round to prevent digging up
|
||||||
|
if i ~= height then
|
||||||
|
modules.check_fuel()
|
||||||
|
turtle.digUp()
|
||||||
|
turtle.up()
|
||||||
|
end
|
||||||
|
|
||||||
|
turtle.turnLeft()
|
||||||
|
turtle.turnLeft()
|
||||||
|
front = not front
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Everything finisehd, go back to start
|
||||||
|
if not front then
|
||||||
|
for i = 1, length do
|
||||||
|
turtle.forward()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
for i = 1, height - 1 do
|
||||||
|
turtle.down()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
print("How long should I dig?")
|
||||||
|
local length = read()
|
||||||
|
print("How wide should I dig?")
|
||||||
|
local width = read()
|
||||||
|
print("How high should I dig?")
|
||||||
|
local height = read()
|
||||||
|
|
||||||
|
mine_line(length, height)
|
@ -195,3 +195,33 @@ function findBlock(name)
|
|||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- puke() puke everything that is in the turtles
|
||||||
|
-- inventory out in front of it (hopefully there is
|
||||||
|
-- a chest
|
||||||
|
function puke()
|
||||||
|
for i = 1, 16 do
|
||||||
|
turtle.select(i)
|
||||||
|
item = turtle.getItemDetail()
|
||||||
|
if item ~= nil then
|
||||||
|
print("Puking out: " .. item['name'])
|
||||||
|
end
|
||||||
|
turtle.drop()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Check Fuel checks if the turtle has enough fuel.
|
||||||
|
-- if not, it asks for fuel in slot 1 and refuels.
|
||||||
|
function check_fuel()
|
||||||
|
local refueled = false
|
||||||
|
while not refueled do
|
||||||
|
if turtle.getFuelLevel() == 0 then
|
||||||
|
print("Fuel is empty. Please put fuel in slot 1 and press a key.")
|
||||||
|
read()
|
||||||
|
turtle.select(1)
|
||||||
|
turtle.refuel()
|
||||||
|
else
|
||||||
|
refueled = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
--[[Tree Chopping program by Sascha
|
--[[Tree Chopping program by Sascha
|
||||||
Chops down the tree in front of turtle.]]
|
Chops down the tree in front of turtle.]]
|
||||||
|
os.loadAPI('modules.lua') -- Load the modules module
|
||||||
|
|
||||||
print('Chopping tree...')
|
print('Chopping tree...')
|
||||||
|
|
||||||
@ -7,15 +8,17 @@ if not turtle.dig() then -- chop base of tree
|
|||||||
error('Turtle needs a digging tool!')
|
error('Turtle needs a digging tool!')
|
||||||
end
|
end
|
||||||
|
|
||||||
os.sleep(5) -- Wait until everything droppen from the tree
|
os.sleep(3) -- Wait until everything droppen from the tree
|
||||||
for j = 1, 4 do
|
for j = 1, 4 do
|
||||||
for i = 1, 4 do
|
for i = 1, 4 do
|
||||||
turtle.suck() -- Suck up everything
|
turtle.suck() -- Suck up everything
|
||||||
turtle.turnLeft()
|
turtle.turnLeft()
|
||||||
end
|
end
|
||||||
turtle.forward()
|
check_fuel()
|
||||||
|
turtle.forward()
|
||||||
end
|
end
|
||||||
|
|
||||||
for i = 1, 4 do
|
for i = 1, 4 do
|
||||||
turtle.back()
|
check_fuel()
|
||||||
|
turtle.back()
|
||||||
end
|
end
|
||||||
|
@ -1,71 +1,85 @@
|
|||||||
--[[Tree Farming App by Al Sweigart
|
--[[Tree Farming App by Al Sweigart
|
||||||
Plants tree and cuts it down.]]
|
Plants tree and cuts it down.]]
|
||||||
|
|
||||||
os.loadAPI('hare.lua') -- Load the hare module
|
os.loadAPI('modules.lua') -- Load the modules module
|
||||||
|
|
||||||
local NUM_OF_TREES = 4
|
local NUM_OF_TREES = 4
|
||||||
local TREE_SAPLING = 'spruce'
|
local TREE_SAPLING = 'oak'
|
||||||
|
|
||||||
-- Check if choptree program exists
|
-- Check if choptree program exists
|
||||||
if not fs.exists('choptree.lua') then
|
if not fs.exists('choptree.lua') then
|
||||||
error('You must install choptree app first')
|
error('You must install choptree app first')
|
||||||
end
|
end
|
||||||
|
|
||||||
while true do
|
while true do
|
||||||
-- First of all, wait a few minutes
|
-- First of all, wait a few minutes
|
||||||
os.sleep(300)
|
os.sleep(300)
|
||||||
-- Check if turtle has enough fuel
|
|
||||||
if turtle.getFuelLevel() < (2 * (3 * NUM_OF_TREES)) then
|
-- Sort all Items together
|
||||||
hare.selectItem('minecraft:' .. TREE_SAPLING .. 'log')
|
modules.sort_items()
|
||||||
turtle.refuel(2)
|
|
||||||
|
|
||||||
|
-- Empty everything except for the saplings
|
||||||
|
for i = 1, 16 do
|
||||||
|
local item = turtle.getItemDetail(i)
|
||||||
|
|
||||||
|
if item ~= nil and item['name'] ~= 'minecraft:' .. TREE_SAPLING .. '_sapling' then
|
||||||
|
turtle.select(i)
|
||||||
|
print('Dropping ' .. item['name'] .. ' into chest.')
|
||||||
|
turtle.drop()
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Empty everything except for the saplings
|
|
||||||
for i = 1, 16 do
|
|
||||||
local item = turtle.getItemDetail(i)
|
|
||||||
|
|
||||||
if item ~= nil and item['name'] ~= 'minecraft:' .. TREE_SAPLING .. '_sapling' then
|
-- Check if we have saplings in our inventory
|
||||||
turtle.select(i)
|
if not modules.select_item('minecraft:' .. TREE_SAPLING .. '_sapling') then
|
||||||
turtle.drop()
|
error('Out of ' .. TREE_SAPLING .. ' saplings')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Build a Loop, where we plant and cut trees
|
||||||
|
turtle.turnLeft()
|
||||||
|
turtle.turnLeft()
|
||||||
|
for i = 1, NUM_OF_TREES do
|
||||||
|
for j = 1, 3 do
|
||||||
|
modules.check_fuel()
|
||||||
|
if i ~= 3 * NUM_OF_TREES then
|
||||||
|
turtle.dig()
|
||||||
|
end
|
||||||
|
turtle.forward()
|
||||||
end
|
end
|
||||||
|
turtle.turnLeft()
|
||||||
|
blockExists, item = turtle.inspect()
|
||||||
-- Check if we have saplings in our inventory
|
if blockExists and item['name'] == 'minecraft:' .. TREE_SAPLING .. '_log' then
|
||||||
if not hare.selectItem('minecraft:' .. TREE_SAPLING .. '_sapling') then
|
modules.select_emptySlot()
|
||||||
error('Out of ' .. TREE_SAPLING .. ' saplings')
|
shell.run('choptree.lua') -- Run Choptree
|
||||||
|
elseif blockExists and item['name'] ~= 'minecraft:' .. TREE_SAPLING .. '_sapling' then
|
||||||
|
print('Error! Wrong block. Found ' .. item['name'])
|
||||||
|
elseif not blockExists then
|
||||||
|
turtle.forward()
|
||||||
|
local success, underneath = turtle.inspectDown()
|
||||||
|
if underneath['name'] ~= 'minecraft:dirt' and underneath['name'] ~= 'minecraft:grass_block' then
|
||||||
|
print('Error. No Dirt or Grass underneath to plant a tree. Found: ' .. underneath['name'])
|
||||||
|
turtle.back()
|
||||||
|
else
|
||||||
|
turtle.back()
|
||||||
|
print('Planting seed.')
|
||||||
|
modules.select_item('minecraft:' .. TREE_SAPLING .. '_sapling')
|
||||||
|
turtle.place()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
turtle.turnRight()
|
||||||
|
end
|
||||||
|
|
||||||
-- Build a Loop, where we plant and cut trees
|
-- Move forward to the chest again
|
||||||
for i = 1, NUM_OF_TREES do
|
turtle.turnLeft()
|
||||||
turtle.back()
|
turtle.turnLeft()
|
||||||
turtle.back()
|
print('Heading back to chest.')
|
||||||
turtle.back()
|
for i = 1, (3 * NUM_OF_TREES) do
|
||||||
turtle.turnRight()
|
modules.check_fuel()
|
||||||
blockExists, item = turtle.inspect()
|
if i ~= 3 * NUM_OF_TREES then
|
||||||
if blockExists and item['name'] == 'minecraft:' .. TREE_SAPLING .. '_log' then
|
turtle.dig()
|
||||||
hare.selectEmtySlot()
|
|
||||||
shell.run('choptree.lua') -- Run Choptree
|
|
||||||
elseif blockExists and item['name'] ~= 'minecraft:' .. TREE_SAPLING .. '_sapling' then
|
|
||||||
print('Error! Wrong block')
|
|
||||||
elseif not blockExists then
|
|
||||||
turtle.forward()
|
|
||||||
local success, underneath = turtle.inspectDown()
|
|
||||||
if underneath['name'] ~= 'minecraft:dirt' and underneath['name'] ~= 'minecraft:grass_block' then
|
|
||||||
print('Error. No Dirt or Grass underneath to plant a tree. Found: ' .. underneath['name'])
|
|
||||||
turtle.back()
|
|
||||||
else
|
|
||||||
turtle.back()
|
|
||||||
hare.selectItem('minecraft:' .. TREE_SAPLING .. '_sapling')
|
|
||||||
turtle.place()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
turtle.turnLeft()
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Move forward to the chest again
|
|
||||||
for i = 1, (3 * NUM_OF_TREES) do
|
|
||||||
turtle.forward()
|
|
||||||
end
|
end
|
||||||
|
turtle.forward()
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
70
Tree_Farm/treeautofarm.lua
Normal file
70
Tree_Farm/treeautofarm.lua
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
--[[
|
||||||
|
treeautofarm program by The_Lux
|
||||||
|
This program checks a tree farm with given length and width and
|
||||||
|
chops the tree down, when it finds one.
|
||||||
|
]]
|
||||||
|
|
||||||
|
-- In which direction should the farm be automated?
|
||||||
|
DIRECTION = 'right'
|
||||||
|
NUM_OF_TREES = 9
|
||||||
|
TREE_SAPLING = 'oak'
|
||||||
|
TREE_DISTANCE = 3
|
||||||
|
DISTANCE = 3
|
||||||
|
WIDTH = 2
|
||||||
|
|
||||||
|
-- bring turtle in position
|
||||||
|
if DIRECTION == 'right' then
|
||||||
|
turtle.turnRight()
|
||||||
|
else
|
||||||
|
turtle.turnLeft()
|
||||||
|
end
|
||||||
|
turtle.forward()
|
||||||
|
if DIRECTION == 'right' then
|
||||||
|
turtle.turnLeft()
|
||||||
|
else
|
||||||
|
turtle.turnRight()
|
||||||
|
end
|
||||||
|
|
||||||
|
while true do
|
||||||
|
-- Wait a few minutes
|
||||||
|
os.sleep(300)
|
||||||
|
|
||||||
|
|
||||||
|
for i = 1, WIDTH do
|
||||||
|
-- Check a line of Trees
|
||||||
|
shell.run('treeline.lua', NUM_OF_TREES, TREE_DISTANCE, TREE_SAPLING)
|
||||||
|
|
||||||
|
-- Go to the next line. But only, if it isn't the last loop
|
||||||
|
if i < WIDTH then
|
||||||
|
if DIRECTION == 'right' then
|
||||||
|
turtle.turnRight()
|
||||||
|
else
|
||||||
|
turtle.turnLeft()
|
||||||
|
end
|
||||||
|
for j = 1, DISTANCE do
|
||||||
|
turtle.forward()
|
||||||
|
end
|
||||||
|
if DIRECTION == ' right' then
|
||||||
|
turtle.turnLeft()
|
||||||
|
else
|
||||||
|
turtle.turnRight()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Go back to start
|
||||||
|
if DIRECTION == 'right' then
|
||||||
|
turtle.turnRight()
|
||||||
|
else
|
||||||
|
turtle.turnLeft()
|
||||||
|
end
|
||||||
|
for i = 1, ((WIDTH - 1) * DISTANCE) do
|
||||||
|
turtle.forward()
|
||||||
|
end
|
||||||
|
if DIRECTION == ' right' then
|
||||||
|
turtle.turnLeft()
|
||||||
|
else
|
||||||
|
turtle.turnRight()
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
98
Tree_Farm/treeline.lua
Normal file
98
Tree_Farm/treeline.lua
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
--[[
|
||||||
|
treeline program by The_Lux
|
||||||
|
This program checks a tree farm with given length and chops the tree down
|
||||||
|
when it finds one.
|
||||||
|
]]
|
||||||
|
|
||||||
|
os.loadAPI('modules.lua') -- Load the modules module
|
||||||
|
|
||||||
|
-- Handle command line arguments
|
||||||
|
local cliArgs = {...}
|
||||||
|
local num_of_trees = tonumber(cliArgs[1])
|
||||||
|
local tree_distance = tonumber(cliArgs[2])
|
||||||
|
local tree_sapling = cliArgs[3]
|
||||||
|
|
||||||
|
if num_of_trees == nil or tree_distance == nil or tree_sapling == nil or cliArgs[1] == '?' then
|
||||||
|
print('Usage: treeline.lua <num_of_trees> <tree_distance> <tree_sapling>')
|
||||||
|
print('num_of_trees = How many trees a in a line.')
|
||||||
|
print('tree_distance = How much space (+1) are in between the trees.')
|
||||||
|
print('tree_sapling = What sapling to use.')
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Empty everything except for the saplings
|
||||||
|
for i = 1, 16 do
|
||||||
|
local item = turtle.getItemDetail(i)
|
||||||
|
|
||||||
|
if item ~= nil and item['name'] ~= 'minecraft:' .. tree_sapling .. '_sapling' then
|
||||||
|
turtle.select(i)
|
||||||
|
print('Dropping ' .. item['name'])
|
||||||
|
turtle.drop()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Check if we have saplings in our inventory
|
||||||
|
if not modules.select_item('minecraft:' .. tree_sapling .. '_sapling') then
|
||||||
|
print('Out of ' .. tree_sapling .. ' saplings. Please provide additional saplings')
|
||||||
|
print('Press Enter when additional sapling are filled.')
|
||||||
|
read()
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Check if we have enough fuel to make our way and come back to start
|
||||||
|
needed_fuel = (num_of_trees * tree_distance) * 2
|
||||||
|
while turtle.getFuelLevel() <= needed_fuel do
|
||||||
|
print('Not enough fuel to farm and come back.')
|
||||||
|
print('We need ' .. (needed_fuel - turtle.getFuelLevel()) .. ' additional fuel.')
|
||||||
|
print('Please put fuel in slot 1 and press a enter.')
|
||||||
|
read()
|
||||||
|
turtle.select(1)
|
||||||
|
turtle.refuel()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
for i = 1, num_of_trees do
|
||||||
|
for j = 1, tree_distance do
|
||||||
|
-- check if something is in your way and dig it up
|
||||||
|
if i ~= (tree_distance * num_of_trees) then
|
||||||
|
turtle.dig()
|
||||||
|
end
|
||||||
|
turtle.forward()
|
||||||
|
end
|
||||||
|
turtle.turnLeft()
|
||||||
|
blockExists, item = turtle.inspect()
|
||||||
|
if blockExists and item['name'] == 'minecraft:' .. tree_sapling .. '_log' then
|
||||||
|
print('Cutting tree...')
|
||||||
|
turtle.dig()
|
||||||
|
print('Planting seed.')
|
||||||
|
modules.select_item('minecraft:' .. tree_sapling .. '_sapling')
|
||||||
|
turtle.place()
|
||||||
|
elseif not blockExists then
|
||||||
|
turtle.forward()
|
||||||
|
local success, underneath = turtle.inspectDown()
|
||||||
|
if underneath['name'] ~= 'minecraft:dirt' and underneath['name'] ~= 'minecraft:grass_block' then
|
||||||
|
print('Error. No Dirt or Grass underneath to plant a tree. Found: ' .. underneath['name'])
|
||||||
|
turtle.back()
|
||||||
|
else
|
||||||
|
turtle.back()
|
||||||
|
print('Planting seed.')
|
||||||
|
modules.select_item('minecraft:' .. tree_sapling .. '_sapling')
|
||||||
|
turtle.place()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
turtle.turnRight()
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Move forward to the chest again
|
||||||
|
turtle.turnLeft()
|
||||||
|
turtle.turnLeft()
|
||||||
|
print('Heading back to start.')
|
||||||
|
for i = 1, (tree_distance * num_of_trees) do
|
||||||
|
if i ~= (tree_distance * num_of_trees) then
|
||||||
|
turtle.dig()
|
||||||
|
end
|
||||||
|
turtle.forward()
|
||||||
|
turtle.turnLeft()
|
||||||
|
turtle.turnLeft()
|
||||||
|
end
|
Reference in New Issue
Block a user