First of all, thanks for great mods!
I'd like to report an incompatibility between NE Buildings and Endgame Combat.
Shortly after adding EC I got a crash. Did a bit of source spelunking and I
think I found the problem.
Recap of my understanding of relevant NE code:
Terraforming Stations in NE are using a turret entity to hold ammo, and an invisible radar entity whose periodic scan fires the terraforming event
Reduce_Evolution. This event also reads and modifies the turrent entity, the reference to which is stored in the
global.Terraforming_Station_Table
Recap of my understanding of relevant EC code:
Endgame Combat has a tech for increasing turret range. It does this by replacing all turrets with increased range versions (I guess that the API doesn't support dynamically changing range). The increased version object prototypes are created programmatically, by going through all turrets, modifying their name and range, and adding as a new prototype.
Incompatibility:
I think you see where this is going. After researching the increased range tech, "Terraforming Station" was replaced by "Terraforming Station [Range Boost 1]", which invalidated the reference stored in
global.Terraforming_Station_Table[].inventory. The next time a terraforming event fired, the map crashed with this stacktrace:
Code: Select all
Error while running event Natural_Evolution_Buildings::on_sector_scanned (ID 7)
LuaEntity API call when LuaEntity was invalid.
stack traceback:
__Natural_Evolution_Buildings__/control.lua:594: in function 'Reduce_Evolution'
__Natural_Evolution_Buildings__/control.lua:652: in function <__Natural_Evolution_Buildings__/control.lua:646>
To make matters worse, removing the upgraded Station didn't help, since the newly placed entity didn't trigger the NE removal code. Reverting to an earlier save (before tech was researched), removing all Stations, and never placing a new one, is the only workaround that I can think of to use both mods.
Suggestions:
Frankly, I don't have any good ones.
1) Try to detect the entity change and update the references. I don't know Lua or Factorio modding API, so I don't know if this is feasible.
2) Register
On_Built,
On_Remove,
On_Death event handlers to also fire for other types of entity addition/removal. Again, I don't know if it's feasible. Also, entities with increased range will have different names :/
3) Special detection code for Endgame Combat that disables range increase for Terraforming Station. Seems like a lot of work, and could break any time EC updates.
4) Change building type of the Terraforming Station. EC generates range-increased versions for object types "ammo-turret", "electric-turret", "fluid-turret". Station is designated as "ammo-turret", so it gets the treatment. Again, could be a lot of work for very little gain.
5) Mark Endgame Turrets as incompatible with NE Buildings so that those mods can't be used together. Don't know if it can be done, and other stuff seems to not have any conflicts (for now; I only added EC a little while ago). I'd also like to use both, so I don't like this possibility
6) Warn users that a combination of Terraforming Stations and EC range increase tech will crash the game and shouldn't be used together. Essentially, pushing the responsibility on the players. I like this one better than #5
Sorry for the wall-of-text, I wanted to report my findings since it could help if someone else encounters the same problem. Thanks again for NE!