Compare commits
28 Commits
3ae694a216
...
master
Author | SHA1 | Date | |
---|---|---|---|
8a3bd602c8 | |||
da931b0e3d | |||
7d6f7a4085 | |||
f988e1fd10 | |||
4b2201e544 | |||
55ef03625a | |||
d7226d2cac | |||
e8d03a1211 | |||
21b3cce893 | |||
591b06aa19 | |||
58f282e0bf | |||
a1a3673536 | |||
69e0a4555a | |||
8e92de7a16 | |||
e68905578f | |||
33043a6d56 | |||
d6e6f6b850 | |||
fccec77a40 | |||
68fa543ca7 | |||
fb14343729 | |||
ffc6d10401 | |||
cf41150a10 | |||
85abbfd8a4 | |||
49bfd155e2 | |||
c7cbc40159 | |||
df7f7bbb7e | |||
fdcc4f3eba | |||
ef84490431 |
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)
|
812
Modules/circles.lua
Normal file
812
Modules/circles.lua
Normal file
@ -0,0 +1,812 @@
|
||||
--[[ Modules for generation or building circles in various forms
|
||||
--written by TheLux
|
||||
--Check https://i.redd.it/swn3e9w8dyc31.jpg to see
|
||||
--the references for the numbers]]
|
||||
|
||||
-- Check if the modules API is present
|
||||
-- and load it. We need it
|
||||
if not os.loadAPI('modules.lua') then
|
||||
error('Error! modules.lua is missing. Please insert it into turtle.')
|
||||
end
|
||||
|
||||
--initial_circle_setup() checks if there is enough
|
||||
--material and sets the turtle to the start
|
||||
--position and places the first block.
|
||||
--Alle circles uses this function
|
||||
function initial_circle_setup(material, material_count)
|
||||
-- Check if we have enough material
|
||||
if modules.count_inventory(material) < material_count then
|
||||
print('Error! Not enough blocks of ' .. material)
|
||||
return false
|
||||
end
|
||||
|
||||
turtle.up()
|
||||
end
|
||||
|
||||
|
||||
--place_diagonal() places n blocks in a diagonal manner
|
||||
function place_diagonal(amount, material)
|
||||
for i = 1, amount do
|
||||
turtle.turnRight()
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--place_column() places n block in a column
|
||||
function place_column(amount, material)
|
||||
turtle.turnRight()
|
||||
for i = 1, amount do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
end
|
||||
|
||||
|
||||
--place_row() places n block in a row
|
||||
function place_row(amount, material)
|
||||
turtle.turnRight()
|
||||
turtle.forward()
|
||||
turtle.turnLeft()
|
||||
for i = 1, amount do
|
||||
modules.select_and_place_down(material)
|
||||
turtle.forward()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
--place_triangle() places a trinagular block
|
||||
function place_triangle(material)
|
||||
turtle.turnRight()
|
||||
turtle.forward()
|
||||
turtle.turnLeft()
|
||||
modules.select_and_place_down(material)
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
turtle.turnRight()
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
end
|
||||
|
||||
|
||||
--circle2 build a 2 by 2 circle
|
||||
function circle2(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 4)
|
||||
|
||||
modules.select_and_place_down(material)
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
turtle.turnRight()
|
||||
turtle.forward()
|
||||
turtle.turnRight()
|
||||
modules.select_and_place_down(material)
|
||||
turtle.forward()
|
||||
turtle.turnRight()
|
||||
modules.select_and_place_down(material)
|
||||
turtle.forward()
|
||||
turtle.turnRight()
|
||||
print('Done building a 2 by 2 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle3 builds a 3 by 3 wide circle
|
||||
function circle3(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 8)
|
||||
|
||||
for i = 1, 4 do
|
||||
for j = 1, 2 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.turnRight()
|
||||
end
|
||||
print('Done building a 3 by 3 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle4 builds a 4 by 4 wide circle
|
||||
function circle4(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 8)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
turtle.turnRight()
|
||||
for i = 1, 3 do
|
||||
for j = 1, 2 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
turtle.turnRight()
|
||||
end
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
turtle.turnRight()
|
||||
print('Done building a 4 by 4 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle5 builds a 5 by 5 wide circle
|
||||
function circle5(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 12)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
turtle.turnRight()
|
||||
for i = 1, 3 do
|
||||
for j = 1, 3 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
turtle.turnRight()
|
||||
end
|
||||
|
||||
for i = 1, 3 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.turnRight()
|
||||
print('Done building a 5 by 5 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle6 builds a 6 by 6 wide circle
|
||||
function circle6(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 16)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
turtle.turnRight()
|
||||
for i = 1, 3 do
|
||||
for j = 1, 4 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
turtle.turnRight()
|
||||
end
|
||||
|
||||
for i = 1, 4 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.turnRight()
|
||||
print('Done building a 4 by 4 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle7 builds a 7 by 7 wide circle
|
||||
function circle7(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 16)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
turtle.turnRight()
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
turtle.turnRight()
|
||||
for j = 1, 3 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 7 by 7 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle8 builds a 8 by 8 wide circle
|
||||
function circle8(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 20)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
turtle.turnRight()
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
turtle.turnRight()
|
||||
for j = 1, 4 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 8 by 8 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle9 builds a 9 by 9 wide circle
|
||||
function circle9(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 24)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
turtle.turnRight()
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
turtle.turnRight()
|
||||
for j = 1, 5 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 9 by 9 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle10 builds a 10 by 10 wide circle
|
||||
function circle10(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 28)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
circles.place_triangle(material)
|
||||
turtle.turnRight()
|
||||
for j = 1, 4 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 10 by 10 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle11 builds a 11 by 11 wide circle
|
||||
function circle11(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 28)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
circles.place_column(2, material)
|
||||
turtle.turnRight()
|
||||
for j = 1, 5 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 11 by 11 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle12 builds a 12 by 12 wide circle
|
||||
function circle12(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 32)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
circles.place_row(2, material)
|
||||
circles.place_column(2, material)
|
||||
turtle.turnRight()
|
||||
for j = 1, 4 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 12 by 12 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle13 builds a 13 by 13 wide circle
|
||||
function circle13(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 36)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
circles.place_row(2, material)
|
||||
circles.place_column(2, material)
|
||||
turtle.turnRight()
|
||||
for j = 1, 5 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 13 by 13 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle14 builds a 14 by 14 wide circle
|
||||
function circle14(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 36)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
circles.place_diagonal(3, material)
|
||||
turtle.turnRight()
|
||||
for j = 1, 6 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 14 by 14 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle15 builds a 15 by 15 wide circle
|
||||
function circle15(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 36)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
circles.place_row(2, material)
|
||||
circles.place_diagonal(1, material)
|
||||
circles.place_column(2, material)
|
||||
turtle.turnRight()
|
||||
for j = 1, 5 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 15 by 15 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle16 builds a 16 by 16 wide circle
|
||||
function circle16(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 44)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
circles.place_row(2, material)
|
||||
circles.place_diagonal(1, material)
|
||||
circles.place_column(2, material)
|
||||
turtle.turnRight()
|
||||
for j = 1, 6 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 16 by 16 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle17 builds a 17 by 17 wide circle
|
||||
function circle17(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 48)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
circles.place_row(2, material)
|
||||
circles.place_triangle(material)
|
||||
circles.place_column(2, material)
|
||||
turtle.turnRight()
|
||||
for j = 1, 5 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 17 by 17 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle18 builds a 18 by 18 wide circle
|
||||
function circle18(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 48)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
circles.place_row(2, material)
|
||||
circles.place_diagonal(2, material)
|
||||
circles.place_column(2, material)
|
||||
turtle.turnRight()
|
||||
for j = 1, 6 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 18 by 18 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle19 builds a 19 by 19 wide circle
|
||||
function circle19(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 52)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
circles.place_row(2, material)
|
||||
circles.place_diagonal(2, material)
|
||||
circles.place_column(2, material)
|
||||
turtle.turnRight()
|
||||
for j = 1, 7 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 19 by 19 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle20 builds a 20 by 20 wide circle
|
||||
function circle20(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 56)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
circles.place_row(2, material)
|
||||
circles.place_row(2, material)
|
||||
circles.place_column(2, material)
|
||||
circles.place_column(2, material)
|
||||
turtle.turnRight()
|
||||
for j = 1, 6 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 20 by 20 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle21 builds a 21 by 21 wide circle
|
||||
function circle21(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 56)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
circles.place_row(2, material)
|
||||
circles.place_diagonal(3, material)
|
||||
circles.place_column(2, material)
|
||||
turtle.turnRight()
|
||||
for j = 1, 7 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 21 by 21 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle22 builds a 22 by 22 wide circle
|
||||
function circle22(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 60)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
circles.place_row(3, material)
|
||||
circles.place_diagonal(3, material)
|
||||
circles.place_column(3, material)
|
||||
turtle.turnRight()
|
||||
for j = 1, 6 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 22 by 22 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle23 builds a 23 by 23 wide circle
|
||||
function circle23(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 64)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
circles.place_row(2, material)
|
||||
circles.place_row(2, material)
|
||||
circles.place_diagonal(1, material)
|
||||
circles.place_column(2, material)
|
||||
circles.place_column(2, material)
|
||||
turtle.turnRight()
|
||||
for j = 1, 7 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 23 by 23 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle24 builds a 24 by 24 wide circle
|
||||
function circle24(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 64)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
circles.place_row(3, material)
|
||||
circles.place_diagonal(4, material)
|
||||
circles.place_column(3, material)
|
||||
turtle.turnRight()
|
||||
for j = 1, 6 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 24 by 24 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle25 builds a 25 by 25 wide circle
|
||||
function circle25(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 68)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
circles.place_row(2, material)
|
||||
circles.place_row(2, material)
|
||||
circles.place_diagonal(2, material)
|
||||
circles.place_column(2, material)
|
||||
circles.place_column(2, material)
|
||||
turtle.turnRight()
|
||||
for j = 1, 7 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 25 by 25 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle26 builds a 26 by 26 wide circle
|
||||
function circle26(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 72)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
circles.place_row(2, material)
|
||||
circles.place_row(2, material)
|
||||
circles.place_diagonal(2, material)
|
||||
circles.place_column(2, material)
|
||||
circles.place_column(2, material)
|
||||
turtle.turnRight()
|
||||
for j = 1, 8 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 26 by 26 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle27 builds a 27 by 27 wide circle
|
||||
function circle27(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 76)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
circles.place_row(3, material)
|
||||
circles.place_diagonal(1, material)
|
||||
circles.place_row(2, material)
|
||||
circles.place_column(2, material)
|
||||
circles.place_diagonal(1, material)
|
||||
circles.place_column(3, material)
|
||||
turtle.turnRight()
|
||||
for j = 1, 7 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 27 by 27 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle28 builds a 28 by 28 wide circle
|
||||
function circle28(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 76)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
circles.place_row(2, material)
|
||||
circles.place_row(2, material)
|
||||
circles.place_diagonal(3, material)
|
||||
circles.place_column(2, material)
|
||||
circles.place_column(2, material)
|
||||
turtle.turnRight()
|
||||
for j = 1, 7 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 28 by 28 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle29 builds a 29 by 29 wide circle
|
||||
function circle29(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 80)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
circles.place_row(3, material)
|
||||
circles.place_row(2, material)
|
||||
circles.place_diagonal(3, material)
|
||||
circles.place_column(2, material)
|
||||
circles.place_column(3, material)
|
||||
turtle.turnRight()
|
||||
for j = 1, 7 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 29 by 29 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle30 builds a 30 by 30 wide circle
|
||||
function circle30(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 84)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
circles.place_row(3, material)
|
||||
circles.place_diagonal(1, material)
|
||||
circles.place_row(2, material)
|
||||
circles.place_diagonal(1, material)
|
||||
circles.place_column(2, material)
|
||||
circles.place_diagonal(1, material)
|
||||
circles.place_column(3, material)
|
||||
turtle.turnRight()
|
||||
for j = 1, 8 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 30 by 30 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle31 builds a 31 by 31 wide circle
|
||||
function circle31(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 84)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
circles.place_row(3, material)
|
||||
circles.place_row(2, material)
|
||||
circles.place_diagonal(4, material)
|
||||
circles.place_column(2, material)
|
||||
circles.place_column(3, material)
|
||||
turtle.turnRight()
|
||||
for j = 1, 7 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 31 by 31 circle')
|
||||
end
|
||||
|
784
Modules/fcircles.lua
Normal file
784
Modules/fcircles.lua
Normal file
@ -0,0 +1,784 @@
|
||||
--[[ Modules for generation or building circles in various forms
|
||||
--filled with another sort of block - written by TheLux
|
||||
--Check https://i.redd.it/swn3e9w8dyc31.jpg to see
|
||||
--the references for the numbers]]
|
||||
|
||||
-- Check if the modules API is present
|
||||
-- and load it. We need it
|
||||
if not os.loadAPI('modules.lua') then
|
||||
error('Error! modules.lua is missing. Please insert it into turtle.')
|
||||
end
|
||||
|
||||
--initial_circle_setup() checks if there is enough
|
||||
--material and sets the turtle to the start
|
||||
--position.
|
||||
--All circles uses this function
|
||||
--omaterial = Outer Material
|
||||
--imaterial = Inner Material
|
||||
function initial_circle_setup(omaterial, imaterial, omaterial_count, imaterial_count)
|
||||
-- Check if we have enough material
|
||||
if modules.count_inventory(omaterial) < omaterial_count then
|
||||
print('Error! Not enough blocks of ' .. omaterial)
|
||||
return false
|
||||
end
|
||||
|
||||
if modules.count_inventory(imaterial) < imaterial_count then
|
||||
print('Error! Not enough blocks of ' .. imaterial)
|
||||
return false
|
||||
end
|
||||
|
||||
turtle.up()
|
||||
end
|
||||
|
||||
-- go_to_start() brings the turtle back to the starting point
|
||||
function go_to_start(moving_forward, diameter)
|
||||
if moving_forward then
|
||||
-- turtle is on the left position
|
||||
for i = 1, finished_left do
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.turnLeft()
|
||||
else
|
||||
-- turtle is on the right position
|
||||
for i = 1, finished_right do
|
||||
turtle.back()
|
||||
end
|
||||
turtle.turnLeft()
|
||||
end
|
||||
|
||||
for i = 1, diameter do
|
||||
turtle.back()
|
||||
end
|
||||
|
||||
|
||||
--circle3 builds a 3 by 3 wide circle
|
||||
function circle3(omaterial, imaterial)
|
||||
-- Definition of the diameter of the circle
|
||||
local diameter = 3
|
||||
local moving_forward = true
|
||||
|
||||
-- Define the blocks you have to go from left and right,
|
||||
-- when building is finished, to go back to start
|
||||
local finished_left = 0
|
||||
local finished_right = 2
|
||||
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(omaterial, imaterial, 8, 1)
|
||||
|
||||
turtle.turnLeft()
|
||||
for i = 1, diameter do
|
||||
modules.select_and_place_down(material)
|
||||
for j = 1, diameter -1 do
|
||||
if moving_forward then
|
||||
turtle.forward()
|
||||
elseif not moving_forward then
|
||||
turtle.back()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
turtle.turnRight()
|
||||
moving_forward = not moving_forward
|
||||
|
||||
-- Done building, go back to start
|
||||
go_to_start(moving_forward, diameter)
|
||||
end
|
||||
print('Done building a filled 3 by 3 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle4 builds a 4 by 4 wide circle
|
||||
function circle4(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 8)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
turtle.turnRight()
|
||||
for i = 1, 3 do
|
||||
for j = 1, 2 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
turtle.turnRight()
|
||||
end
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
turtle.turnRight()
|
||||
print('Done building a 4 by 4 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle5 builds a 5 by 5 wide circle
|
||||
function circle5(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 12)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
turtle.turnRight()
|
||||
for i = 1, 3 do
|
||||
for j = 1, 3 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
turtle.turnRight()
|
||||
end
|
||||
|
||||
for i = 1, 3 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.turnRight()
|
||||
print('Done building a 5 by 5 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle6 builds a 6 by 6 wide circle
|
||||
function circle6(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 16)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
turtle.turnRight()
|
||||
for i = 1, 3 do
|
||||
for j = 1, 4 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
turtle.turnRight()
|
||||
end
|
||||
|
||||
for i = 1, 4 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.turnRight()
|
||||
print('Done building a 4 by 4 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle7 builds a 7 by 7 wide circle
|
||||
function circle7(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 16)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
turtle.turnRight()
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
turtle.turnRight()
|
||||
for j = 1, 3 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 7 by 7 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle8 builds a 8 by 8 wide circle
|
||||
function circle8(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 20)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
turtle.turnRight()
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
turtle.turnRight()
|
||||
for j = 1, 4 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 8 by 8 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle9 builds a 9 by 9 wide circle
|
||||
function circle9(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 24)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
turtle.turnRight()
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
turtle.turnRight()
|
||||
for j = 1, 5 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 9 by 9 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle10 builds a 10 by 10 wide circle
|
||||
function circle10(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 28)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
circles.place_triangle(material)
|
||||
turtle.turnRight()
|
||||
for j = 1, 4 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 10 by 10 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle11 builds a 11 by 11 wide circle
|
||||
function circle11(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 28)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
circles.place_column(2, material)
|
||||
turtle.turnRight()
|
||||
for j = 1, 5 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 11 by 11 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle12 builds a 12 by 12 wide circle
|
||||
function circle12(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 32)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
circles.place_row(2, material)
|
||||
circles.place_column(2, material)
|
||||
turtle.turnRight()
|
||||
for j = 1, 4 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 12 by 12 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle13 builds a 13 by 13 wide circle
|
||||
function circle13(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 36)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
circles.place_row(2, material)
|
||||
circles.place_column(2, material)
|
||||
turtle.turnRight()
|
||||
for j = 1, 5 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 13 by 13 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle14 builds a 14 by 14 wide circle
|
||||
function circle14(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 36)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
circles.place_diagonal(3, material)
|
||||
turtle.turnRight()
|
||||
for j = 1, 6 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 14 by 14 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle15 builds a 15 by 15 wide circle
|
||||
function circle15(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 36)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
circles.place_row(2, material)
|
||||
circles.place_diagonal(1, material)
|
||||
circles.place_column(2, material)
|
||||
turtle.turnRight()
|
||||
for j = 1, 5 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 15 by 15 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle16 builds a 16 by 16 wide circle
|
||||
function circle16(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 44)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
circles.place_row(2, material)
|
||||
circles.place_diagonal(1, material)
|
||||
circles.place_column(2, material)
|
||||
turtle.turnRight()
|
||||
for j = 1, 6 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 16 by 16 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle17 builds a 17 by 17 wide circle
|
||||
function circle17(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 48)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
circles.place_row(2, material)
|
||||
circles.place_triangle(material)
|
||||
circles.place_column(2, material)
|
||||
turtle.turnRight()
|
||||
for j = 1, 5 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 17 by 17 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle18 builds a 18 by 18 wide circle
|
||||
function circle18(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 48)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
circles.place_row(2, material)
|
||||
circles.place_diagonal(2, material)
|
||||
circles.place_column(2, material)
|
||||
turtle.turnRight()
|
||||
for j = 1, 6 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 18 by 18 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle19 builds a 19 by 19 wide circle
|
||||
function circle19(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 52)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
circles.place_row(2, material)
|
||||
circles.place_diagonal(2, material)
|
||||
circles.place_column(2, material)
|
||||
turtle.turnRight()
|
||||
for j = 1, 7 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 19 by 19 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle20 builds a 20 by 20 wide circle
|
||||
function circle20(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 56)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
circles.place_row(2, material)
|
||||
circles.place_row(2, material)
|
||||
circles.place_column(2, material)
|
||||
circles.place_column(2, material)
|
||||
turtle.turnRight()
|
||||
for j = 1, 6 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 20 by 20 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle21 builds a 21 by 21 wide circle
|
||||
function circle21(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 56)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
circles.place_row(2, material)
|
||||
circles.place_diagonal(3, material)
|
||||
circles.place_column(2, material)
|
||||
turtle.turnRight()
|
||||
for j = 1, 7 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 21 by 21 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle22 builds a 22 by 22 wide circle
|
||||
function circle22(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 60)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
circles.place_row(3, material)
|
||||
circles.place_diagonal(3, material)
|
||||
circles.place_column(3, material)
|
||||
turtle.turnRight()
|
||||
for j = 1, 6 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 22 by 22 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle23 builds a 23 by 23 wide circle
|
||||
function circle23(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 64)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
circles.place_row(2, material)
|
||||
circles.place_row(2, material)
|
||||
circles.place_diagonal(1, material)
|
||||
circles.place_column(2, material)
|
||||
circles.place_column(2, material)
|
||||
turtle.turnRight()
|
||||
for j = 1, 7 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 23 by 23 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle24 builds a 24 by 24 wide circle
|
||||
function circle24(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 64)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
circles.place_row(3, material)
|
||||
circles.place_diagonal(4, material)
|
||||
circles.place_column(3, material)
|
||||
turtle.turnRight()
|
||||
for j = 1, 6 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 24 by 24 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle25 builds a 25 by 25 wide circle
|
||||
function circle25(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 68)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
circles.place_row(2, material)
|
||||
circles.place_row(2, material)
|
||||
circles.place_diagonal(2, material)
|
||||
circles.place_column(2, material)
|
||||
circles.place_column(2, material)
|
||||
turtle.turnRight()
|
||||
for j = 1, 7 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 25 by 25 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle26 builds a 26 by 26 wide circle
|
||||
function circle26(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 72)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
circles.place_row(2, material)
|
||||
circles.place_row(2, material)
|
||||
circles.place_diagonal(2, material)
|
||||
circles.place_column(2, material)
|
||||
circles.place_column(2, material)
|
||||
turtle.turnRight()
|
||||
for j = 1, 8 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 26 by 26 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle27 builds a 27 by 27 wide circle
|
||||
function circle27(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 76)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
circles.place_row(3, material)
|
||||
circles.place_diagonal(1, material)
|
||||
circles.place_row(2, material)
|
||||
circles.place_column(2, material)
|
||||
circles.place_diagonal(1, material)
|
||||
circles.place_column(3, material)
|
||||
turtle.turnRight()
|
||||
for j = 1, 7 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 27 by 27 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle28 builds a 28 by 28 wide circle
|
||||
function circle28(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 76)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
circles.place_row(2, material)
|
||||
circles.place_row(2, material)
|
||||
circles.place_diagonal(3, material)
|
||||
circles.place_column(2, material)
|
||||
circles.place_column(2, material)
|
||||
turtle.turnRight()
|
||||
for j = 1, 7 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 28 by 28 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle29 builds a 29 by 29 wide circle
|
||||
function circle29(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 80)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
circles.place_row(3, material)
|
||||
circles.place_row(2, material)
|
||||
circles.place_diagonal(3, material)
|
||||
circles.place_column(2, material)
|
||||
circles.place_column(3, material)
|
||||
turtle.turnRight()
|
||||
for j = 1, 7 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 29 by 29 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle30 builds a 30 by 30 wide circle
|
||||
function circle30(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 84)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
circles.place_row(3, material)
|
||||
circles.place_diagonal(1, material)
|
||||
circles.place_row(2, material)
|
||||
circles.place_diagonal(1, material)
|
||||
circles.place_column(2, material)
|
||||
circles.place_diagonal(1, material)
|
||||
circles.place_column(3, material)
|
||||
turtle.turnRight()
|
||||
for j = 1, 8 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 30 by 30 circle')
|
||||
end
|
||||
|
||||
|
||||
--circle31 builds a 31 by 31 wide circle
|
||||
function circle31(material)
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
circles.initial_circle_setup(material, 84)
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
circles.place_row(3, material)
|
||||
circles.place_row(2, material)
|
||||
circles.place_diagonal(4, material)
|
||||
circles.place_column(2, material)
|
||||
circles.place_column(3, material)
|
||||
turtle.turnRight()
|
||||
for j = 1, 7 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(material)
|
||||
end
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
print('Done building a 31 by 31 circle')
|
||||
end
|
||||
|
89
Modules/fvcircles.lua
Normal file
89
Modules/fvcircles.lua
Normal file
@ -0,0 +1,89 @@
|
||||
--[[ Modules for generation or building vertical circles in
|
||||
--various forms which are filled. Good for underwater bases
|
||||
--written by TheLux
|
||||
--Check https://i.redd.it/swn3e9w8dyc31.jpg to see
|
||||
--the references for the numbers]]
|
||||
|
||||
-- Check if the modules API is present
|
||||
-- and load it. We need it
|
||||
if not os.loadAPI('modules.lua') then
|
||||
error('Error! modules.lua is missing. Please insert it into turtle.')
|
||||
end
|
||||
|
||||
--initial_full_circle_setup() checks if there is enough
|
||||
--material and sets the turtle to the start
|
||||
--position and places the first block.
|
||||
--Alle circles uses this function
|
||||
function initial_full_circle_setup(omaterial, omaterial_count, imaterial, imaterial_count)
|
||||
-- Check if we have enough material
|
||||
if modules.count_inventory(omaterial) < omaterial_count then
|
||||
error('Error! Not enough blocks of ' .. omaterial .. '. You need ' .. omaterial_count .. omaterial)
|
||||
return false
|
||||
end
|
||||
|
||||
if modules.count_inventory(imaterial) < imaterial_count then
|
||||
error('Error! Not enough blocks of ' .. imaterial .. '. You need ' .. imaterial_count .. imaterial)
|
||||
return false
|
||||
end
|
||||
|
||||
turtle.up()
|
||||
end
|
||||
|
||||
--fvcircle5 builds a vertical 5 by 5 circle
|
||||
--which are filled with another material
|
||||
function fvcircle5(omaterial, imaterial, times)
|
||||
|
||||
-- times checks how often this function should be called
|
||||
-- this is only for checking, if we have enough blocks in
|
||||
-- our inventory
|
||||
times = times or 1
|
||||
omatcount = 12 * times
|
||||
imatcount = 9 * times
|
||||
|
||||
-- Start the initial Setup and place the turtle in
|
||||
-- the right position
|
||||
fvcircles.initial_full_circle_setup(omaterial, omatcount, imaterial, imatcount)
|
||||
|
||||
|
||||
-- First Row
|
||||
turtle.turnLeft()
|
||||
turtle.back()
|
||||
turtle.back()
|
||||
for i = 1, 3 do
|
||||
modules.select_and_place_down(omaterial)
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.up()
|
||||
-- Second and Third and Fourth Row
|
||||
for i = 1, 3 do
|
||||
turtle.turnLeft()
|
||||
turtle.turnLeft()
|
||||
modules.select_and_place_down(omaterial)
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(imaterial)
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(imaterial)
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(imaterial)
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(omaterial)
|
||||
turtle.up()
|
||||
end
|
||||
|
||||
-- Fifth and last row
|
||||
turtle.turnLeft()
|
||||
turtle.turnLeft()
|
||||
for i = 1, 3 do
|
||||
turtle.forward()
|
||||
modules.select_and_place_down(omaterial)
|
||||
end
|
||||
turtle.turnRight()
|
||||
turtle.forward()
|
||||
for i = 1, 5 do
|
||||
turtle.down()
|
||||
end
|
||||
|
||||
print('Done building a filled and vertical 5 by 5 circle')
|
||||
end
|
||||
|
||||
|
@ -34,19 +34,95 @@ function selectEmptySlot()
|
||||
return false -- couldn't find empty space
|
||||
end
|
||||
|
||||
-- getItemFromChest(chestItem) selects
|
||||
-- something from a chest in front of the turtle
|
||||
-- and pushes it into the turtle.
|
||||
function getItemFromChest(chestItem)
|
||||
sapling = peripheral.wrap('front') -- This find the chest at the front and allow you do things to it
|
||||
selectEmptySlot()
|
||||
-- countInventory() returns the total
|
||||
-- numer of items in the inventory
|
||||
function countInventory()
|
||||
local total = 0
|
||||
|
||||
for slot, item in pairs(sapling.getAllStacks()) do
|
||||
if item.id == chestItem then
|
||||
-- If the chest is on the north side of the turtle, the turtle is on the south side of the peripheral
|
||||
sapling.pushItem('south', slot)
|
||||
end
|
||||
for slot = 1, 16 do
|
||||
total = total + turtle.getItem(slot)
|
||||
end
|
||||
return total
|
||||
end
|
||||
|
||||
-- selectAndPlaceDown() selects a nonempty slot
|
||||
-- and places a block from it under the turtle
|
||||
function selectAndPlaceDown()
|
||||
for slot = 1, 16 do
|
||||
if turtle.getItemCount(slot) > 0 then
|
||||
turtle.select(slot)
|
||||
turtle.placeDown()
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- buildWall() creates a wall stretching
|
||||
-- in front of the turtle
|
||||
function buildWall(length, height)
|
||||
if modules.countInventory() > length * height then
|
||||
return false --not enough block
|
||||
end
|
||||
|
||||
turtle.up()
|
||||
|
||||
local movingForward = true
|
||||
|
||||
for currentHeight = 1, height do
|
||||
for currentLength = 1, length do
|
||||
selectAndPlaceDown() -- Place the block
|
||||
if movingForward and currentLength ~= length then
|
||||
turtle.forward()
|
||||
elseif not movingForward and currentLength ~= length then
|
||||
turtle.back()
|
||||
end
|
||||
end
|
||||
if currentHeight ~= height then
|
||||
turtle.up()
|
||||
end
|
||||
movingForward = not movingForward
|
||||
end
|
||||
|
||||
-- done building wall; move to end position
|
||||
if movingForward then
|
||||
-- turtle is near the start position
|
||||
for currentLength = 1, length do
|
||||
turtle.forward()
|
||||
end
|
||||
else
|
||||
-- turtle is near the end position
|
||||
turtle.forward()
|
||||
end
|
||||
|
||||
-- move down to the ground
|
||||
for currentHeight = 1, height do
|
||||
turtle.down()
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
-- buildRoom() constructs four walls
|
||||
-- and a ceiling
|
||||
function buildRoom(length, width, height)
|
||||
if hare.countInventory() < (((length -1) * height * 2) +
|
||||
((width -1) * height * 2)) then
|
||||
return false -- not enough blocks
|
||||
end
|
||||
|
||||
-- build the four walls
|
||||
buildWall(length -1, height)
|
||||
turtle.turnRight()
|
||||
|
||||
buildWall(width - 1, height)
|
||||
turtle.turnRight()
|
||||
|
||||
buildWall(length - 1, height)
|
||||
turtle.turnRight()
|
||||
|
||||
buildWall(width - 1, height)
|
||||
turtle.turnRight()
|
||||
|
||||
return true
|
||||
end
|
||||
|
227
Modules/modules.lua
Normal file
227
Modules/modules.lua
Normal file
@ -0,0 +1,227 @@
|
||||
--[[Function Module program by Al Sweigart
|
||||
Provides useful utility functions.]]
|
||||
|
||||
-- selectItem() selects the inventory
|
||||
-- slot with the named item, returns
|
||||
-- true if found and false if not
|
||||
function select_item(name)
|
||||
-- check all inventory slots
|
||||
local item
|
||||
for slot = 1, 16 do
|
||||
item = turtle.getItemDetail(slot)
|
||||
if item ~= nil and item['name'] == name then
|
||||
turtle.select(slot)
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false -- couldn't find item
|
||||
end
|
||||
|
||||
|
||||
-- selectEmptySlot() selects inventory
|
||||
-- slot that is empty, returns true if
|
||||
-- found, false if no empty spaces
|
||||
function select_emptySlot()
|
||||
|
||||
-- loop through all slots
|
||||
for slot = 1, 16 do
|
||||
if turtle.getItemCount(slot) == 0 then
|
||||
turtle.select(slot)
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false -- couldn't find empty space
|
||||
end
|
||||
|
||||
-- countInventory() returns the total
|
||||
-- number of a given minecraft id item in the inventory
|
||||
function count_inventory(minecraft_id, times)
|
||||
local total = 0
|
||||
|
||||
for slot = 1, 16 do
|
||||
item = turtle.getItemDetail(slot)
|
||||
if item ~= nil and item['name'] == 'minecraft:' .. minecraft_id then
|
||||
total = total + turtle.getItemCount(slot)
|
||||
end
|
||||
end
|
||||
return total
|
||||
end
|
||||
|
||||
-- selectAndPlaceDown() selects a slot with given
|
||||
-- minecraft id and places a block from it under the turtle
|
||||
function select_and_place_down(minecraft_id)
|
||||
for slot = 1, 16 do
|
||||
item = turtle.getItemDetail(slot)
|
||||
if item ~= nil and item['name'] == 'minecraft:' .. minecraft_id then
|
||||
turtle.select(slot)
|
||||
turtle.placeDown()
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- build_wall() creates a wall stretching
|
||||
-- in front of the turtle
|
||||
function build_wall(length, height)
|
||||
if modules.count_inventory() > length * height then
|
||||
return false --not enough block
|
||||
end
|
||||
|
||||
turtle.up()
|
||||
|
||||
local movingForward = true
|
||||
|
||||
for currentHeight = 1, height do
|
||||
for currentLength = 1, length do
|
||||
select_and_place_down() -- Place the block
|
||||
if movingForward and currentLength ~= length then
|
||||
turtle.forward()
|
||||
elseif not movingForward and currentLength ~= length then
|
||||
turtle.back()
|
||||
end
|
||||
end
|
||||
if currentHeight ~= height then
|
||||
turtle.up()
|
||||
end
|
||||
movingForward = not movingForward
|
||||
end
|
||||
|
||||
-- done building wall; move to end position
|
||||
if movingForward then
|
||||
-- turtle is near the start position
|
||||
for currentLength = 1, length do
|
||||
turtle.forward()
|
||||
end
|
||||
else
|
||||
-- turtle is near the end position
|
||||
turtle.forward()
|
||||
end
|
||||
|
||||
-- move down to the ground
|
||||
for currentHeight = 1, height do
|
||||
turtle.down()
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
-- build_room() constructs four walls
|
||||
-- and a ceiling
|
||||
function build_room(length, width, height)
|
||||
if modules.count_inventory() < (((length -1) * height * 2) +
|
||||
((width -1) * height * 2)) then
|
||||
return false -- not enough blocks
|
||||
end
|
||||
|
||||
-- build the four walls
|
||||
build_wall(length -1, height)
|
||||
turtle.turnRight()
|
||||
|
||||
build_wall(width - 1, height)
|
||||
turtle.turnRight()
|
||||
|
||||
build_wall(length - 1, height)
|
||||
turtle.turnRight()
|
||||
|
||||
build_wall(width - 1, height)
|
||||
turtle.turnRight()
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
-- sweepField() moves acress the rows
|
||||
-- and columns of an area in front and
|
||||
-- to the right of the turtle, calling
|
||||
-- the provided sweepFunc at each space
|
||||
function sweepField(length, width, sweepFunc)
|
||||
local turnRightNext = true
|
||||
|
||||
for x = 1, width do
|
||||
for y = 1, length do
|
||||
sweepFunc()
|
||||
|
||||
-- don't move forward on the last row
|
||||
if y ~= width then
|
||||
turtle.forward()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- don't turn on the last column
|
||||
if x ~= width then
|
||||
-- turn to the next column
|
||||
if turnRightNext then
|
||||
turtle.turnRight()
|
||||
turtle.forward()
|
||||
turtle.turnRight()
|
||||
else
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
turtle.turnLeft()
|
||||
end
|
||||
|
||||
turnRightNext = not turnRightNext
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- move back to the start position
|
||||
if width % 2 == 0 then
|
||||
turtle.turnRight()
|
||||
else
|
||||
for y = 1, length -1 do
|
||||
turtle.back()
|
||||
end
|
||||
turtle.turnLeft()
|
||||
end
|
||||
turtle.turnRight()
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
--findBlock() spins around searching
|
||||
--for the named block next to the turtle
|
||||
function findBlock(name)
|
||||
local result, block
|
||||
|
||||
for i = 1, 4 do
|
||||
result, block = turtle.inspect()
|
||||
if block ~= nil and block['name'] == name then
|
||||
return true
|
||||
end
|
||||
turtle.turnRight()
|
||||
end
|
||||
return false
|
||||
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,27 +1,24 @@
|
||||
--[[Tree Chopping program by Sascha
|
||||
Chops down the tree in front of turtle.]]
|
||||
|
||||
if not turtle.detect() then
|
||||
error('Could not find tree!')
|
||||
end
|
||||
os.loadAPI('modules.lua') -- Load the modules module
|
||||
|
||||
print('Chopping tree...')
|
||||
|
||||
if not turtle.dig() then -- chop base of tree
|
||||
error('Turtle needs a digging tool!')
|
||||
end
|
||||
|
||||
os.sleep(5) -- Wait until everything droppen from the tree
|
||||
end
|
||||
|
||||
os.sleep(3) -- Wait until everything droppen from the tree
|
||||
for j = 1, 4 do
|
||||
for i = 1, 4 do
|
||||
if not turtle.suck() then -- Suck up all Wood
|
||||
print('Did not find something to suck')
|
||||
end
|
||||
turtle.turnLeft()
|
||||
end
|
||||
turtle.forward()
|
||||
for i = 1, 4 do
|
||||
turtle.suck() -- Suck up everything
|
||||
turtle.turnLeft()
|
||||
end
|
||||
check_fuel()
|
||||
turtle.forward()
|
||||
end
|
||||
|
||||
for i = 1, 4 do
|
||||
turtle.back()
|
||||
check_fuel()
|
||||
turtle.back()
|
||||
end
|
||||
|
@ -1,79 +1,85 @@
|
||||
--[[Tree Farming App by Al Sweigart
|
||||
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 TREE_SAPLING = 'spruce'
|
||||
local blockExists, item
|
||||
local logCount = 0
|
||||
local TREE_SAPLING = 'oak'
|
||||
|
||||
-- Check if choptree program exists
|
||||
if not fs.exists('choptree.lua') then
|
||||
error('You must install choptree app first')
|
||||
error('You must install choptree app first')
|
||||
end
|
||||
|
||||
while true do
|
||||
-- First, empty the whole turtle
|
||||
for i = 1, 16 do
|
||||
turtle.select(i)
|
||||
turtle.drop()
|
||||
end
|
||||
-- First of all, wait a few minutes
|
||||
os.sleep(300)
|
||||
|
||||
-- Check if turtle has enough fuel
|
||||
if turtle.getFuelLevel() < (2 * (3 * NUM_OF_TREES)) then
|
||||
hare.getItemFromChest('minecraft:' .. TREE_SAPLING .. '_log')
|
||||
turtle.craft()
|
||||
hare.selectItem('minecraft:' .. TREE_SAPLING .. 'plan')
|
||||
turtle.refuel()
|
||||
end
|
||||
-- Sort all Items together
|
||||
modules.sort_items()
|
||||
|
||||
-- Take one stack of Saplings from the Chest
|
||||
if not hare.getItemFromChest('minecraft:' .. TREE_SAPLING .. '_sapling') then
|
||||
error('Out of saplingurtle.craft() -- craft stone brickss')
|
||||
end
|
||||
|
||||
-- Build a Loop, where we plant and cut trees
|
||||
for i = 1, NUM_OF_TREES do
|
||||
turtle.back()
|
||||
turtle.back()
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
blockExists, item = turtle.inspect()
|
||||
if blockExists and item['name'] == 'minecraft:' .. TREE_SAPLING .. 'log' then
|
||||
shell.run('choptree.lua') -- Run Choptree
|
||||
elseif block Exists and item['name'] ~= 'minecraft:' .. TREE_SAPLING .. 'sapling' then
|
||||
turtle.drop()
|
||||
|
||||
print('Planting...')
|
||||
turtle.place() -- plant sapling
|
||||
|
||||
-- Loop until tree is grown
|
||||
while true do
|
||||
blockExists, item = turtle.inspect()
|
||||
if item['name'] ~= 'minecraft:spruce_log' then
|
||||
print('wait 5 seconds')
|
||||
os.sleep(5)
|
||||
else
|
||||
break -- tree has grown
|
||||
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'] .. ' into chest.')
|
||||
turtle.drop()
|
||||
end
|
||||
hare.selectEmptySlot()
|
||||
shell.run('choptree.lua') -- run choptree
|
||||
|
||||
-- move to and face chest
|
||||
turtle.back()
|
||||
turtle.turnLeft()
|
||||
turtle.turnLeft()
|
||||
|
||||
-- put logs into chest
|
||||
while hare.selectItem('minecraft:spruce_log') do
|
||||
logCount = logCount + turtle.getItemCount()
|
||||
print('Total logs: ' .. logCount)
|
||||
turtle.drop()
|
||||
end
|
||||
|
||||
|
||||
-- Check if we have saplings in our inventory
|
||||
if not modules.select_item('minecraft:' .. TREE_SAPLING .. '_sapling') then
|
||||
error('Out of ' .. TREE_SAPLING .. ' saplings')
|
||||
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
|
||||
|
||||
--face planting sport
|
||||
turtle.turnLeft()
|
||||
turtle.turnLeft()
|
||||
blockExists, item = turtle.inspect()
|
||||
if blockExists and item['name'] == 'minecraft:' .. TREE_SAPLING .. '_log' then
|
||||
modules.select_emptySlot()
|
||||
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
|
||||
turtle.turnRight()
|
||||
end
|
||||
|
||||
-- Move forward to the chest again
|
||||
turtle.turnLeft()
|
||||
turtle.turnLeft()
|
||||
print('Heading back to chest.')
|
||||
for i = 1, (3 * NUM_OF_TREES) do
|
||||
modules.check_fuel()
|
||||
if i ~= 3 * NUM_OF_TREES then
|
||||
turtle.dig()
|
||||
end
|
||||
turtle.forward()
|
||||
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
|
27
Underwater_Base/build_pipe.lua
Normal file
27
Underwater_Base/build_pipe.lua
Normal file
@ -0,0 +1,27 @@
|
||||
--[[ App for building an underwater Pipe
|
||||
--written by TheLux
|
||||
--Check https://i.redd.it/swn3e9w8dyc31.jpg to see
|
||||
--the references for the numbers]]
|
||||
|
||||
--- Check if the fvcircles API is present
|
||||
-- and load it. We need it
|
||||
if not os.loadAPI('fvcircles.lua') then
|
||||
error('Error! fvcircles.lua is missing. Please insert it into turtle.')
|
||||
end
|
||||
|
||||
print("How many pipes do you want to build: ")
|
||||
local pipes = read()
|
||||
|
||||
print("What should be the outer Material (ex. glass): ")
|
||||
local omaterial = read()
|
||||
|
||||
print("What should be the inner Material (ex. sand): ")
|
||||
local imaterial = read()
|
||||
|
||||
print("Building a " .. pipes .. " blocks long tunnel")
|
||||
for i = 1, pipes do
|
||||
turtle.down()
|
||||
fvcircles.fvcircle5(omaterial, imaterial, pipes)
|
||||
end
|
||||
|
||||
print("Done build the tunnel")
|
@ -1,49 +0,0 @@
|
||||
--[[Stone Brick Factory program by Al Sweigart
|
||||
Gets stone from furnace to craft stone bricks, turtle 2 of 2]]
|
||||
|
||||
print('Starting stone brick crafting program')
|
||||
|
||||
local NUM_FURNACES = 5
|
||||
local brickCount = 0
|
||||
while true do
|
||||
-- check turtle's fuel
|
||||
if turtle.getFuelLevel() < (2 * NUM_FURNACES) then
|
||||
error('Turtle needs more fuel!')
|
||||
end
|
||||
|
||||
turtle.select(1) -- put stone in slot 1
|
||||
|
||||
-- start collecting stone from furnaces
|
||||
for i = 1, NUM_FURNACES do
|
||||
turtle.suckUp(64 - turtle.getItemCount(1)) -- get stone from furnace
|
||||
if turtle.getItemCount(1) == 64 then
|
||||
break -- stop once there are 64 stone blocks
|
||||
end
|
||||
if i ~= NUM_FURNACES then
|
||||
turtle.back() -- move to next furnace
|
||||
end
|
||||
end
|
||||
|
||||
-- craft stone bricks
|
||||
if turtle.getItemCount(1) == 64 then
|
||||
turtle.transferTo(2, 16) -- put in slot 2
|
||||
turtle.transferTo(5, 16) -- put in slot 5
|
||||
turtle.transferTo(6, 16) -- put in slot 6
|
||||
turtle.select(16) -- stone brick to go in slot 16
|
||||
turtle.craft() -- craft stone bricks
|
||||
brick.Count = brickCount + 64
|
||||
print('Total stone bricks: ' .. brickCount)
|
||||
else
|
||||
print('Not enough stones yet. Sleeping...')
|
||||
os.sleep(120) -- wait for 2 minutes
|
||||
end
|
||||
|
||||
-- move back to chest (by first furnace)
|
||||
for i = 1, NUM_FURNACES - 1 do
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.turnLeft() -- face chest
|
||||
turtle.select(16) -- select stone bricks
|
||||
turtle.drop() -- put stone bricks into chest
|
||||
turtle.turnRight() -- face generator again
|
||||
end
|
46
cobminer.lua
46
cobminer.lua
@ -1,46 +0,0 @@
|
||||
--[[Stone Brick Factory program by Al Sweigart
|
||||
Mines cobblestone from a generator, trutle 1 of 2]]
|
||||
|
||||
os.loadAPI('hare') -- load the hare module
|
||||
local numToDrop
|
||||
local NUM_FURNACES = 5
|
||||
|
||||
print('Starting mining program...')
|
||||
while true do
|
||||
-- mine cobblestone
|
||||
if turtle.detect() then
|
||||
print('Cobblestone detected. Mining...')
|
||||
turtle.dig() -- Mine cobblestone
|
||||
else
|
||||
print('No cobblestone detected. Sleeping...')
|
||||
os.sleep(0.5) -- half-second pause
|
||||
end
|
||||
|
||||
-- check for a full stack of cobblestone
|
||||
hare.selectItem('minecraft:cobblestone')
|
||||
if turtle.getItemCount() == 64 then
|
||||
-- check turtle's fuel
|
||||
if turtle.getFuelLevel() < (2 * NUM_FURNACES) then
|
||||
error('Turtle needs more fuel!')
|
||||
end
|
||||
|
||||
-- put cobblestone in furnaces
|
||||
print('Dropping off cobblestone...')
|
||||
for furnacesToFill = NUM_FURNACES, 1, -1 do
|
||||
turtle.back() -- move over furnace
|
||||
numToDrop = math.floor(turtle.getItemCount() / furnacesToFill)
|
||||
turtle.dropDown(numToDrop) -- put cobblestone in furnace
|
||||
end
|
||||
|
||||
-- move back to cobblestone generator
|
||||
for moves = 1, NUM_FURNACES do
|
||||
turtle.forward()
|
||||
end
|
||||
|
||||
if turtle.getItemCount() > 0 then
|
||||
print('All furnaces full. Sleeping...')
|
||||
os.sleep(300) -- wait for five minutes
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user