In short trying to get the ammo-type from an ammo slot
create a tank and select it
/c inv = game.player.selected.get_inventory(defines.inventory.car_ammo); game.player.print(tostring(inv.has_filters())) -- returns true
/c inv = game.player.selected.get_inventory(defines.inventory.car_ammo); game.player.print(tostring(inv.get_filter(1))) -- returns nil
my assumption is that because it is type and not an item it is returning nil and if this is the case can it be changed to return type if item doesn't exist? or add inventory:get_ammo_filter to return ammo type?
[.14.5] inv has_filters true - get_filter nil
Re: [.14.5] inv has_filters true - get_filter nil
Those 2 functions do 2 completely different things and what you describe is perfectly normal.
An inventory can support filters (thus has_filters() returns true) and have no filters set (thus get_filter(..) returns nil).
An inventory can support filters (thus has_filters() returns true) and have no filters set (thus get_filter(..) returns nil).
If you want to get ahold of me I'm almost always on Discord.
Re: [.14.5] inv has_filters true - get_filter nil
Well that explains that.
Any chance for an inventory:get_ammo_category(slot) to return string ammo-type?
Any chance for an inventory:get_ammo_category(slot) to return string ammo-type?
Re: [.14.5] inv has_filters true - get_filter nil
Rseding91 wrote:Those 2 functions do 2 completely different things and what you describe is perfectly normal.
An inventory can support filters (thus has_filters() returns true) and have no filters set (thus get_filter(..) returns nil).
hm... maybe a better name for the function? like support_filters()?

- aubergine18
- Smart Inserter
- Posts: 1264
- Joined: Fri Jul 22, 2016 8:51 pm
- Contact:
Re: [.14.5] inv has_filters true - get_filter nil
or is_filterable()
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.