Created
June 23, 2023 01:53
-
-
Save Hri7566/3f2d933561b43fc457362e9358657027 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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