Skip to content

Instantly share code, notes, and snippets.

@dkowis
Last active August 1, 2017 00:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dkowis/e47ea42520fe6933fea69f18211dfa2d to your computer and use it in GitHub Desktop.
Save dkowis/e47ea42520fe6933fea69f18211dfa2d to your computer and use it in GitHub Desktop.
Learning some OpenComputers API
local component = require("component");
local sides = require("sides");
local ica = component.inventory_controller.address;
print("ICA: " .. ica)
local proxy = component.proxy(ica);
--Lets try to find our inventories
-- Top is the source
-- East is the output
print("Source inventory size: " .. proxy.getInventorySize(sides.top));
-- Lets get all stacks from the inventory slots in Source
for i=0,proxy.getInventorySize(sides.top) do
local item = proxy.getStackInSlot(sides.top, i)
if item == nil then
print("No item in slot " .. i);
else
print(item.size .. " of " .. item.id .. " - " .. item.name);
end
end
print("all done!");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment