LuaEntity::get_recipe() subclasses

Place to post guides, observations, things related to modding that are not mods themselves.
Post Reply
User avatar
Therenas
Fast Inserter
Fast Inserter
Posts: 204
Joined: Tue Dec 11, 2018 2:10 pm
Contact:

LuaEntity::get_recipe() subclasses

Post by Therenas »

Honktown wrote:
Fri Jun 04, 2021 1:19 am
https://lua-api.factorio.com/latest/Lua ... get_recipe

Works on a ghost of a crafting machine. Not sure if it is intentional or not (there is no other obvious way to check the recipe on a ghost), but it works. get_recipe() and previous_recipe don't do anything on a blueprint of a furnace, which makes sense.
Is this more of a comment? What do you think should be changed?

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3432
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Small documentation improvement requests

Post by DaveMcW »

Can only be used if this is CraftingMachine, or EntityGhost of CraftingMachine.

User avatar
Therenas
Fast Inserter
Fast Inserter
Posts: 204
Joined: Tue Dec 11, 2018 2:10 pm
Contact:

Re: LuaEntity::get_recipe() subclasses

Post by Therenas »

Doesn't CraftingMachine already imply that?

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3432
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: LuaEntity::get_recipe() subclasses

Post by DaveMcW »

Not unless you know the LuaEntity inheritance tree. If you want to document how a LuaEntity can be two types at once, that would be great too!

User avatar
Therenas
Fast Inserter
Fast Inserter
Posts: 204
Joined: Tue Dec 11, 2018 2:10 pm
Contact:

Re: LuaEntity::get_recipe() subclasses

Post by Therenas »

You're right, probably best to be explicit. Fixed for the next release.

The whole 'Can only be used if' system is kind of bad in general though, it's due for a re-do at some point I feel like.

Honktown
Filter Inserter
Filter Inserter
Posts: 804
Joined: Thu Oct 03, 2019 7:10 am
Contact:

Re: LuaEntity::get_recipe() subclasses

Post by Honktown »

Therenas wrote:
Fri Jun 04, 2021 6:28 am
Doesn't CraftingMachine already imply that?
Ghosts can't craft and machines of them are an entity-ghost, so from a modder perspective, no. How I viewed it, hence the request. Similarly, seemingly far more important attributes, ghost_name, ghost_prototype, ghost_type, e.g. are separate. No ghost_get_recipe() or ghost_set_recipe()
I have mods! I guess!
Link

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5081
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: LuaEntity::get_recipe() subclasses

Post by eradicator »

Therenas wrote:
Fri Jun 04, 2021 6:28 am
Doesn't CraftingMachine already imply that?
Intuitively and without evidence and very personal opinion: No.
I generally assume that SomethingGhost behaves entirely different than the real thing.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Post Reply

Return to “Modding discussion”