Skip to content

Instantly share code, notes, and snippets.

@lukacat10
Last active September 20, 2021 20:46
Show Gist options
  • Save lukacat10/a9ac20d35bf9f223a9cdfddf11400589 to your computer and use it in GitHub Desktop.
Save lukacat10/a9ac20d35bf9f223a9cdfddf11400589 to your computer and use it in GitHub Desktop.
term.clear()
function fluid_transfer(config)
local width, height = term.getSize()
local resIndex = -1
for k,v in pairs(config) do
resIndex = resIndex + 1
term.setCursorPos(1, height - (4 + 4 * resIndex))
print("Fluid storage of '"..k.."'")
for kk,vv in pairs(v["storage"]) do
local storage = peripheral.wrap(vv)
if storage ~= nil then
local s_tanks = storage.getTanks()
for sk,s_tank in pairs(s_tanks) do
term.setCursorPos(1, height - (3 + 4 * resIndex))
print("tank "..sk)
term.setCursorPos(1, height - (2 + 4 * resIndex))
if s_tank.amount ~= nil then print("amount: "..s_tank.amount) end
term.setCursorPos(1, height - (1 + 4 * resIndex))
if s_tank.capacity ~= nil then print("capacity: "..s_tank.capacity) end
if v["input"] ~= nil then
for kkk,vvv in pairs(v["input"]) do
if s_tank.amount == nil or s_tank.amount < s_tank.capacity then
local input = peripheral.wrap(vvv)
if storage.pullFluid ~= nil then
storage.pullFluid(vvv, 1000000, k)
else
--print("no")
end
end
end
end
storage = peripheral.wrap(vv)
if v["output"] ~= nil then
for kkk,vvv in pairs(v["output"]) do
if s_tank.amount ~= nil and s_tank.amount >= 0 then
local output = peripheral.wrap(vvv)
-- print(vvv)
-- print(k)
if storage.pushFluid ~= nil then
--print("no no")
-- print(textutils.serialize(storage.getDocs()))
storage.pushFluid(vvv, 1000000, k)
else
--print("nono")
end
end
end
end
end
end
end
end
end
function item_transfer(config)
for k,v in pairs(config) do
for kk,vv in pairs(v["storage"]) do
local storage = peripheral.wrap(vv)
if v["output"] ~= nil then
for kkk,vvv in pairs(v["output"]) do
local output = peripheral.wrap(kkk)
for kkkk,vvvv in pairs(storage.list()) do
if vvvv.name == k then
storage.pushItems(kkk, kkkk, 64, vvv)
end
end
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment