Merge branch 'master' of http://tea.irgendwasmit.it:3000/sascham/ComputerCraft
This commit is contained in:
commit
8e92de7a16
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
|
||||
|
||||
|
@ -35,14 +35,14 @@ function select_emptySlot()
|
||||
end
|
||||
|
||||
-- countInventory() returns the total
|
||||
-- numer of a given minecraft id item in the inventory
|
||||
function count_inventory(minecraft_id)
|
||||
-- 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.getItem(slot)
|
||||
total = total + turtle.getItemCount(slot)
|
||||
end
|
||||
end
|
||||
return total
|
||||
@ -52,7 +52,8 @@ end
|
||||
-- minecraft id and places a block from it under the turtle
|
||||
function select_and_place_down(minecraft_id)
|
||||
for slot = 1, 16 do
|
||||
if turtle.getItemDetail(slot) == 'minecraft:' .. minecraft_id then
|
||||
item = turtle.getItemDetail(slot)
|
||||
if item ~= nil and item['name'] == 'minecraft:' .. minecraft_id then
|
||||
turtle.select(slot)
|
||||
turtle.placeDown()
|
||||
return
|
||||
|
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")
|
Loading…
Reference in New Issue
Block a user