create_entity not reliably firing?
Posted: Sat May 15, 2021 4:13 am
A user posted about a bug their encountering in my mod, and after some digging, it seems the issue lies with
If I leave the surface index as 1, then no entity is created*. If I set the index as 2, then an entity is created, but seemingly of another faction (game says I can't mine it)
And it seems that, since this is firing during on_built_entity, I can't use entity.surface or entinty.force (Get a LuaEntity not valid error)
The intent of it is that, my mod has entity tiers that are discreetly replaced when a new tier is researched (tiers have different entity health values)
If anyone has any insight into what's going on and can help me fix this, it'd be much appreciated.
*: Sometimes. In my personal saves, it works fine. In the save that the user provided, it does not work. My mod is the only enabled mod in either case.
Code: Select all
game.surfaces[1].create_entity{name, position, direction, force}
And it seems that, since this is firing during on_built_entity, I can't use entity.surface or entinty.force (Get a LuaEntity not valid error)
The intent of it is that, my mod has entity tiers that are discreetly replaced when a new tier is researched (tiers have different entity health values)
If anyone has any insight into what's going on and can help me fix this, it'd be much appreciated.
*: Sometimes. In my personal saves, it works fine. In the save that the user provided, it does not work. My mod is the only enabled mod in either case.