34 lines
985 B
Lua
34 lines
985 B
Lua
-- 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
|