ComputerCraft/Modules/circles.lua

813 lines
19 KiB
Lua

--[[ 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