Entity Replacement System (Ongoing work, do not merge)#98
Entity Replacement System (Ongoing work, do not merge)#98nicholasgower wants to merge 30 commits into
Conversation
…ities not subject to entity replacement rules.
…lift-multiplier property setting.
| local is_ghost = entity.name == "entity-ghost" | ||
| local name = is_ghost and entity.ghost_name or entity.name | ||
|
|
||
| local is_space = not not surface.platform |
There was a problem hiding this comment.
My new favorite lua-ism
| new_entity.copy_settings(entity) | ||
|
|
||
| if not is_ghost then | ||
| local modules = entity.get_module_inventory().get_contents() | ||
| for _, item in pairs(modules) do | ||
| local inserted_count = new_entity.insert(item) | ||
| if inserted_count < item.count then | ||
| item.count = item.count - inserted_count | ||
| surface.spill_item_stack { | ||
| position = entity.position, | ||
| stack = item, | ||
| enable_looted = true, | ||
| force = entity.force_index, | ||
| allow_belts = false | ||
| } | ||
| end | ||
| end | ||
| end | ||
|
|
||
| entity.destroy() |
There was a problem hiding this comment.
AIUI, these should all be unnecessary if you use fast_replace = true in the surface.create_entity call. Note that this does mean that entity will be immediately invalid, so any data needed from it would need to be retrieved beforehand.
|
|
||
| end | ||
|
|
||
| --Function called to replace PlanetsLib planet-exclusive entity replacements with original versions. Keeping blueprints in a stable state feels like a safer choice than allowing people to |
There was a problem hiding this comment.
You can take a look at how Rigor Module does this, in the sanitize_blueprint_entities function:
- Logic uses bplib.
- Logic is skipped for cut/paste to preserve external wire connections. Unfortunately, the only way I could figure out how to implement this was to track which players are currently holding the cut tool in storage, because once the blueprint event is fired, the player is now holding the blueprint item, and that information is lost.
|
I've requested a feature from Wube to assist in this PR to simplify the removal of entity variants. https://forums.factorio.com/viewtopic.php?t=133940 |
…requirement to define an item name, or assume that item name and entity name are the same.
|
I've implemented an initial version of the rocket lift multiplier system. This is accomplished via a new |
|
|
Description
This PR allows developers to quickly create planet-exclusive entity variants. For example, one could give chemical plants on one planet two additional module slots.
If one were to abuse this system to its limit, they could copy every entity in the game, double the heating energy of each entity, and effectively double the heat required by every entity in the game on a particular planet. The possible performance issues of doing that are currently unknown.
Adding this system required combining rocket silo code and the new entity-replacement code into one event function. I have tested rocket silos to confirm that they still work as they did beforehand.
I would like to see one other developer make a mod with this system before pushing it to the mod portal.
This PR is step one towards adding a "rocket-lift-multiplier" variable to planets that would create variants of rocket silos with different lift capacities for different planets, using a currently-unavailable 2.1 feature.
Checklist
changelog.txthas been updatedREADME.mdhas been updated (documentation section and/or Contributors list)Testing Notes
To test this system, I've made this test mod that creates chemical plant variants for every planet except Nauvis. github.com/nicholasgower/PlanetsLib-testing