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.
Ability to interact with a robot's inventory
-
- Long Handed Inserter
- Posts: 88
- Joined: Fri Apr 22, 2016 9:55 pm
- Contact:
Re: Ability to interact with a robot's inventory
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.
-
- Long Handed Inserter
- Posts: 88
- Joined: Fri Apr 22, 2016 9:55 pm
- Contact:
Re: Ability to interact with a robot's inventory
If you follow the link I posted, you'll see that it doesn't seem to actually work. I tried something like
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?
Code: Select all
local inventory
for _, inv in pairs(defines.inventory) do
inventory = event.robot.get_inventory(inv)
if inventory then break end
end
Re: Ability to interact with a robot's inventory
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.Exasperation wrote:If you follow the link I posted, you'll see that it doesn't seem to actually work. I tried something likeand 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?Code: Select all
local inventory for _, inv in pairs(defines.inventory) do inventory = event.robot.get_inventory(inv) if inventory then break end end
If you want to get ahold of me I'm almost always on Discord.