Page 1 of 1

[.14.5] inv has_filters true - get_filter nil

Posted: Mon Sep 12, 2016 12:00 am
by Nexela
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?

Re: [.14.5] inv has_filters true - get_filter nil

Posted: Mon Sep 12, 2016 2:26 am
by Rseding91
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).

Re: [.14.5] inv has_filters true - get_filter nil

Posted: Mon Sep 12, 2016 4:26 am
by Nexela
Well that explains that.

Any chance for an inventory:get_ammo_category(slot) to return string ammo-type?

Re: [.14.5] inv has_filters true - get_filter nil

Posted: Mon Sep 12, 2016 6:41 am
by Mooncat
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()? :P

Re: [.14.5] inv has_filters true - get_filter nil

Posted: Mon Sep 12, 2016 2:59 pm
by aubergine18
or is_filterable()