LuaEquipmentGrid Contents/Shield

Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

LuaEquipmentGrid Contents/Shield

Post by Nexela »

Just a few things that could help when working with equipment grids.

#1 LuaEquipmentGrid::get_contents() → dictionary string → uint similar to LuaInventory::get_contents() returns equipment_name and count

#2 LuaEquipmentGrid::shield (r) and LuaEquipmentGrid::max_shield (r) similar to same fields in LuaEquipment except totaled for all/read only

#3 LuaEntity::get_armor_grid() -> luaEquipmentGrid returns the armor grid for the entity if it has one, similar to the other get_specific_inv functions


Thanks for looking in to this!
Rseding91
Factorio Staff
Factorio Staff
Posts: 15997
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: LuaEquipmentGrid Contents/Shield

Post by Rseding91 »

http://lua-api.factorio.com/latest/LuaE ... ntity.grid already exists

As for the other two: I'll add them for 0.15.
If you want to get ahold of me I'm almost always on Discord.
Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: LuaEquipmentGrid Contents/Shield

Post by Nexela »

Thanks!

And I really wish I would have seen entity.grid before now! in fact I think I did but my brain didn't put 2 and 2 together.
Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: LuaEquipmentGrid Contents/Shield

Post by Nexela »

Nix that. I shouldn't respond when not fully awake.


Regarding #3
entity.grid just returns the entities grid.

entity.get_armor_grid() would get the entities armor grid if it exists (is weaing armor and armor has a grid). Similar to how the entity.get_fuel_inventory() function works

get armor_grid would be like the get_fuel_inventory() a shortcut to getting the armor grid

return entity.get_inventory(defines.inventory.armor)[1].grid returning the grid or nil if anything isn't valid inbetween
Rseding91
Factorio Staff
Factorio Staff
Posts: 15997
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: LuaEquipmentGrid Contents/Shield

Post by Rseding91 »

I made entity.grid work for the character for 0.15.
If you want to get ahold of me I'm almost always on Discord.
Post Reply

Return to “Implemented mod requests”