Ability to interact with a robot's inventory

Things that already exist in the current mod API
Post Reply
Exasperation
Long Handed Inserter
Long Handed Inserter
Posts: 88
Joined: Fri Apr 22, 2016 9:55 pm
Contact:

Ability to interact with a robot's inventory

Post by Exasperation »

I have recently run into the same problem that was encountered here: viewtopic.php?f=25&t=33223
There just doesn't seem to be any way to modify the properties of an item carried by a construction robot (in my case, I'm trying to modify the label property of an item-with-label). I know which robot has the item, I just can't do anything with it.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13235
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Ability to interact with a robot's inventory

Post by Rseding91 »

You just use get_inventory on the robot like any other entity.
If you want to get ahold of me I'm almost always on Discord.

Exasperation
Long Handed Inserter
Long Handed Inserter
Posts: 88
Joined: Fri Apr 22, 2016 9:55 pm
Contact:

Re: Ability to interact with a robot's inventory

Post by Exasperation »

If you follow the link I posted, you'll see that it doesn't seem to actually work. I tried something like

Code: Select all

local inventory
for _, inv in pairs(defines.inventory) do
    inventory = event.robot.get_inventory(inv)
    if inventory then break end
end
and just got nil back, the person in the thread I linked to tried doing event.robot.get_inventory(1) and got back something that looked like an inventory but returned a piece of userdata instead of an ItemStack when they tried to access its first slot. Is this just a bug, and what we've been trying should work?

Rseding91
Factorio Staff
Factorio Staff
Posts: 13235
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Ability to interact with a robot's inventory

Post by Rseding91 »

Exasperation wrote:If you follow the link I posted, you'll see that it doesn't seem to actually work. I tried something like

Code: Select all

local inventory
for _, inv in pairs(defines.inventory) do
    inventory = event.robot.get_inventory(inv)
    if inventory then break end
end
and just got nil back, the person in the thread I linked to tried doing event.robot.get_inventory(1) and got back something that looked like an inventory but returned a piece of userdata instead of an ItemStack when they tried to access its first slot. Is this just a bug, and what we've been trying should work?
get_inventory(1) does work. The event is simply called before the items are put into the robot so you won't be able to see them. The event passes the *simple-item-stack but the docks are wrong in saying it passes "LuaItemStack". I fixed the docs.
If you want to get ahold of me I'm almost always on Discord.

Post Reply

Return to “Already exists”