Page 1 of 1

Identifying [non] entity prototypes during data stage

Posted: Thu Apr 18, 2019 8:59 pm
by sparr

Code: Select all

local entity_types = { ["accumulator"] = true, ["arithmetic-combinator"] = true, ["artillery-flare"] = true, ["artillery-projectile"] = true, ["artillery-turret"] = true, ["artillery-wagon"] = true, ["assembling-machine"] = true, ["beacon"] = true, ["boiler"] = true, ["capsule"] = true, ["car"] = true, ["cargo-wagon"] = true, ["character-corpse"] = true, ["cliff"] = true, ["combat-robot"] = true, ["constant-combinator"] = true, ["construction-robot"] = true, ["container"] = true, ["corpse"] = true, ["decider-combinator"] = true, ["electric-pole"] = true, ["electric-turret"] = true, ["entity-ghost"] = true, ["explosion"] = true, ["fire"] = true, ["fish"] = true, ["flame-thrower-explosion"] = true, ["fluid-turret"] = true, ["fluid-wagon"] = true, ["flying-text"] = true, ["furnace"] = true, ["gate"] = true, ["generator"] = true, ["heat-pipe"] = true, ["inserter"] = true, ["lab"] = true, ["lamp"] = true, ["land-mine"] = true, ["loader"] = true, ["locomotive"] = true, ["logistic-container"] = true, ["logistic-robot"] = true, ["mining-drill"] = true, ["monolith"] = true, ["offshore-pump"] = true, ["pipe-to-ground"] = true, ["pipe"] = true, ["player-port"] = true, ["player"] = true, ["power-switch"] = true, ["programmable-speaker"] = true, ["projectile"] = true, ["pump"] = true, ["radar"] = true, ["rail-chain-signal"] = true, ["rail-remnants"] = true, ["rail-signal"] = true, ["reactor"] = true, ["roboport"] = true, ["rocket-silo"] = true, ["solar-panel"] = true, ["splitter"] = true, ["storage-tank"] = true, ["straight-rail"] = true, ["tile"] = true, ["transport-belt"] = true, ["turret"] = true, ["underground-belt"] = true, ["unit-spawner"] = true, ["unit"] = true, ["wall"] = true, }
I have this list in an old mod that I want to update. I am trying to avoid adding/removing from this long list by hand. Is there some way to tell during the data stage whether a prototype type (data.raw.FOO) contains entities or non-entities? Or to tell if a particular prototype is an entity or not?

Re: Identifying [non] entity prototypes during data stage

Posted: Thu Apr 18, 2019 9:04 pm
by sparr
Use case: I have a mod for deleting arbitrary prototypes by name or type+name. It is meant to allow players to work around bugs and conflicts in other mods without knowing how to code or waiting for updates that might never come. When an entity prototype is deleted, any item that has place_result of that entity needs to have that field blanked, and that requires knowing which prototypes are entities.

Re: Identifying [non] entity prototypes during data stage

Posted: Thu Apr 18, 2019 11:17 pm
by robot256
You could just iterate through the list of items and look for ones where place_result is not nil, and also equal to your target name. Sure you would do a lot of searching if it wasn't an entity with a corresponding item, but that's okay since it only happens during load.

Re: Identifying [non] entity prototypes during data stage

Posted: Fri Apr 19, 2019 6:22 am
by sparr
That would not work right when removing a non-entity prototype (like an item or technology) with the same name as an entity. For example, if I am removing data.raw.technology.foo, I do not want to eliminate the place_result of data.raw.item.foo which is "foo" . But if I am removing data.raw.someentitytype.foo then I do need to eliminate that place_result.