Page 1 of 1

LuaEquipmentGrid Contents/Shield

Posted: Fri Apr 07, 2017 3:45 am
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!

Re: LuaEquipmentGrid Contents/Shield

Posted: Fri Apr 07, 2017 9:32 am
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.

Re: LuaEquipmentGrid Contents/Shield

Posted: Fri Apr 07, 2017 1:58 pm
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.

Re: LuaEquipmentGrid Contents/Shield

Posted: Fri Apr 07, 2017 8:43 pm
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

Re: LuaEquipmentGrid Contents/Shield

Posted: Fri Apr 07, 2017 9:12 pm
by Rseding91
I made entity.grid work for the character for 0.15.