Another one for grids
LuaEquipmentGrid Owner the entity/item_stack that this grid belongs too.
Useful during on_player_put_item so you know where the grid is
LuaEquipmentGrid Owner
Re: LuaEquipmentGrid Owner
Equipment grids do not know who owns them so that information is not available to expose in the Lua API.
If you want to get ahold of me I'm almost always on Discord.
Re: LuaEquipmentGrid Owner
So every time the event fires to tell me a player put a foo_equipment in a grid, I need to walk the tree down to game.players.get_inventory(defines.inventory.defines.inventory.player_armor)[1].grid.get_contents()["foo_equipment"] to see if they are now wearing one? And I need to keep track of that count in a global so that next time the event fires I can see if they added one vs put it in another grid that I don't care about?Rseding91 wrote:Equipment grids do not know who owns them so that information is not available to expose in the Lua API.
Re: LuaEquipmentGrid Owner
just player.character.grid works
Re: LuaEquipmentGrid Owner
That does shorten it significantly. Removes a lot of my concerns about repeated lua lookup times. Thanks!
Re: LuaEquipmentGrid Owner
In case mods add grids to vehicles.
How would you access the locomotive or car the player put the equipment into?
Do we have to keep track of all equipment inside all vehicles and parse through that to find changes?
How would you access the locomotive or car the player put the equipment into?
Do we have to keep track of all equipment inside all vehicles and parse through that to find changes?
My Mods: mods.factorio.com
Re: LuaEquipmentGrid Owner
Code: Select all
on_put_equipment(event)
local player = games.players[event.player_index]
if player.opened and player.opened.grid == event.grid then
entity_putting_in = player.opened
end
end