Skip to content

Instantly share code, notes, and snippets.

@Hri7566
Created June 23, 2023 01:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hri7566/3f2d933561b43fc457362e9358657027 to your computer and use it in GitHub Desktop.
Save Hri7566/3f2d933561b43fc457362e9358657027 to your computer and use it in GitHub Desktop.
-- Concrete factory
-- by Hri7566
local powderChest = peripheral.wrap("front")
local concreteChest = peripheral.wrap("right")
function isEmpty()
-- Check if we have powder
local hasPowder = false
for i = 1, 16 do
local data = turtle.getItemDetail(i)
if data then
if data.name:match("concrete_powder") then
hasPowder = true
end
end
end
return not hasPowder
end
function pullPowder()
-- Pull powder from chest
turtle.suck()
end
function convert()
-- Convert powder to concrete
for i=1,turtle.getItemCount() do
turtle.placeDown()
turtle.digDown()
end
end
function pushConcrete()
-- Push all concrete to chest
turtle.turnRight()
for i = 1, 16 do
local item = turtle.getItemDetail(i)
turtle.select(i)
turtle.drop()
end
turtle.select(1)
turtle.turnLeft()
end
while true do
if isEmpty() then
pullPowder()
end
convert()
pushConcrete()
sleep(0.2)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment