Created
March 18, 2022 16:50
-
-
Save FederAndInk/b85ec02a2810222ddacb3e6be045152d 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
---select the first non empty slot that is not bone_meal | |
---@return boolean | |
local function first_not_bone_meal() | |
local i = 1 | |
while i <= 16 and | |
(turtle.getItemCount(i) == 0 or turtle.getItemDetail(i).name == | |
"minecraft:bone_meal") do | |
i = i + 1 | |
end | |
if i <= 16 then | |
turtle.select(i) | |
end | |
return i <= 16 | |
end | |
---select the first slot with item | |
---@return boolean | |
local function select_slot_with(item_name) | |
local i = 1 | |
while i <= 16 and | |
(turtle.getItemCount(i) == 0 or turtle.getItemDetail(i).name ~= item_name) do | |
i = i + 1 | |
end | |
if i <= 16 then | |
turtle.select(i) | |
end | |
return i <= 16 | |
end | |
---@return string | |
local function front_block_name() | |
local here, b = turtle.inspect() | |
if here then | |
if type(b) == type({}) then | |
b = b.name | |
end | |
return b | |
end | |
end | |
local activation_side = "right" | |
while first_not_bone_meal() do | |
turtle.place() | |
assert(select_slot_with("minecraft:bone_meal"), "no more bone meal!") | |
turtle.place() | |
local placed_block = front_block_name() | |
redstone.setOutput(activation_side, true) | |
while placed_block == front_block_name() do | |
sleep(0.02) | |
end | |
redstone.setOutput(activation_side, false) | |
end | |
print("No more item to process") | |
print("Exiting") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment