Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
  • 0
Jalopy43

robot and inventory controller upgrade

Question

it says on the wiki that the side back is what is used to access the robot's inventory with the inventory controller upgrade, but when i try to use the side i get an unsupported side error. i have an item in the first slot of the inventory and it seems to work using other sides. I was just wondering if there was a different way to get the robot's inventory info or if that isn't possible.

 

my code is as follows:

 

local robot = require("robot")
local sides = require("sides")
local component = require("component")
local inv = component.inventory_controller
local term = require("term")
term.clear()

print(inv.getStackInSlot(sides.back, 1)

 

 

Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Figured it out with the adapter block on a creative robot. For those that are going to want to access the robot's internal inventory the function is

 

component.inventory_controller.getStackInInternalSlot()

 

you still have to have the inventory controller upgrade obviously.

Link to post
Share on other sites
  • 0

I am having a similar issue with accessing the robots internal inventory, but it doesn't appear that there is a dedicated function. I want to count the number of slots in the robots inventory, and anticipated that the function, getInventorySize(side: number): number or nil[, string] would work.

 

However, when I use this function specifying "sides.back", I get an unsupported sides error (like Jalopy43 did).

 

Does anybody know how I can accomplish this without the need for an additional block?

 

Thanks!

Link to post
Share on other sites
  • 0

I was going to write a simple "me too:" I'm also a bit annoyed that there isn't (as far as I can tell) a function for getting the number of slots on a robot's own inventory.

The documentation says that the own inventory is accessed with sides.back but that returns an "invalid side" error.

My guess is that the "historic" ability to use getStackInSlot() for the robot's internal API went from "deprecated" to "scrapped" but the author forgot to provide a replacement for getInventorySize() .

Anyway, happily for both of us, there's a workaround: The function getStackInInternalSlot() errors out if you call it with an out-of-range slot number. So what I did was to count up slots and caught the error:

local s, lastSlot = 1, 0;
while true do
  local stat, stk = pcall(invcon.getStackInInternalSlot, s)
  if stat then lastSlot = s; s = s + 1 else break end
end
print(string.format("Last slot: %d", lastSlot))

This gave me the correct inventory size for my cheap single inventory upgrade robot with 16 slots.
Realistically, it's probably enough (and more efficient) to just test sizes of 16, 32, 48 and 64, because it seems inventory upgrades are 16 slots each and you can only install up to 4 of them.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.