Closed Dimava closed 2 weeks ago
🤔 I'm not sure if this actually makes sense though
The types of LuaEntity don't fit one-on-one with the "subclasses" of LuaEntity, so I'm not sure an EntityTypeMap
the same way as PrototypeMap
will work nicely.
It might be possible to define this manually, but this might be error prone and hard to maintain (e.g. "underground-belt": EntityWithOwner & { type: "underground-belt"
).
Would this be useful?
At the very least, having a list of entity.name
possible values may be very useful for autocompletion of if (entity.name === '...')
and surface.create_entity({name: '...'})
So you may just make that basically Record<'...', {}>
for now to use it as keyof
, and later enhance as needed
The whole list of name
was in docs somewhere iirc
... Nevermind, I've missed that name
is not type
so not applicable to some of surface.createEntity
. Would be good to allow type?: 'inserter'
if it would be ignored there anyways tho
The thing I would expect to be the most useful is the types for stuff like Can only be used if this is ResourceEntity
- so I sorta need that ResourceEntity as a type
Restricting the possible values of type
would be possible.
Also, there is a ResourceEntity
type (and for other subclasses), which contains only properties specific to a subclass. This might be what you are looking for.
However, subclass types do not (yet) include prototype hierarchy relationships (e.g. an assembler is also an entity-with-force); it could be a good idea to add this in the future.
I think this could use the SuperclassNameMap or something lol
Turns out defines.prototypes
provides the "subclass map" the whole time, and since factorio v1.1.110 it just got fully defined. Additionally, specific string types such as EntityType
, ItemType
, EquipmentType
were added in a earlier (this package) version.
As such, since types for v1.1.110 were just released (in package v2.13.0), I'm closing this issue as "fixed".
I have an LuaEntity and want to make something like
to make sorta type autoinferring, but this requires something like PrototypeMap for factorio:runtime