Program to manage an iron generator built using create and the create datapack Ultimate Factory

This commit is contained in:
Emerson Rosen-Jones 2025-08-01 22:59:36 -04:00
parent 2cf0dc58d9
commit d5f3debf56

34
irongen.lua Normal file
View file

@ -0,0 +1,34 @@
-- Program for managing an iron generator in create with the create: ultimate
-- factory datapack
local store = peripheral.wrap("create:item_vault_0")
local basins = { peripheral.find("create:basin") }
local output = store
local BASIN_OUT_SLOT = 10
local IRON_NUGGET = "minecraft:iron_nugget"
local GRAVEL = "minecraft:gravel"
function find_item (inv, item_name)
for i, v in pairs(inv.list()) do
if v.name == item_name then
return i
end
end
end
while true do
for _, b in ipairs(basins) do
local iron_slot = find_item(store, IRON_NUGGET)
local gravel_slot = find_item(store, GRAVEL)
local basin_name = peripheral.getName(b)
if gravel_slot ~= nil then
store.pushItems(basin_name, gravel_slot)
end
if iron_slot ~= nil then
store.pushItems(basin_name, iron_slot)
else
sleep(1)
end
output.pullItems(basin_name, BASIN_OUT_SLOT)
end
end