LuaItemPrototype.get_ammo_type() can be used with all item prototypes

Place to report issues and suggest improvements to the API documentation.
Post Reply
Pi-C
Smart Inserter
Smart Inserter
Posts: 1698
Joined: Sun Oct 14, 2018 8:13 am
Contact:

LuaItemPrototype.get_ammo_type() can be used with all item prototypes

Post by Pi-C »

The description of LuaItemPrototype.get_ammo_type() contains the warning "Can only be used if this is AmmoItem". This isn't true: If you loop over game.item_prototypes and run get_ammo_type(), this will not throw an error for items that are not an AmmoItem, but return nil instead.
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

curiosity
Filter Inserter
Filter Inserter
Posts: 400
Joined: Wed Sep 11, 2019 4:13 pm
Contact:

Re: LuaItemPrototype.get_ammo_type() can be used with all item prototypes

Post by curiosity »

Pi-C wrote:
Thu Jun 27, 2024 1:33 pm
The description of LuaItemPrototype.get_ammo_type() contains the warning "Can only be used if this is AmmoItem". This isn't true: If you loop over game.item_prototypes and run get_ammo_type(), this will not throw an error for items that are not an AmmoItem, but return nil instead.
That's just how all prototype properties are. It's a flaw in the documentation generation system. Last time I asked, the answer was along the lines "not until I can make a general fix".

Pi-C
Smart Inserter
Smart Inserter
Posts: 1698
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: LuaItemPrototype.get_ammo_type() can be used with all item prototypes

Post by Pi-C »

curiosity wrote:
Thu Jun 27, 2024 2:18 pm
That's just how all prototype properties are. It's a flaw in the documentation generation system. Last time I asked, the answer was along the lines "not until I can make a general fix".
OK, thanks for the info! :-)
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

Post Reply

Return to “Documentation Improvement Requests”