You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.
When rangeboost is researched, then Endgame Combat will do a replace upon placing turrets. When it does this, no other mods are able to get an event about the original entity (because it's gone) or the new entity.
I'd request that Endgame Combat generates an event, script_raised_built being an ideal candidate, providing updated versions of the same parameters that on_built_entity utilizes. I'd suggest the below patch:
From 79c76e4d6245ba9a19caf4a01da851ea4939c65e Mon Sep 17 00:00:00 2001
From: Kovus <kovus@soulless.wtf>
Date: Wed, 25 Jul 2018 10:28:32 -0500
Subject: [PATCH] Raise event when quickly replacing turrets that are placed.
This lets other mods watch for the script_raised_built event and (with proper checks on data content) respond accordingly.
---
control.lua | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/control.lua b/control.lua
index 79ac35d..129d5c0 100644
--- a/control.lua+++ b/control.lua@@ -146,6 +146,7 @@ local function trackNewTurret(egcombat, turret)
--game.print("Adding " .. turret.name .. " @ " .. turret.position.x .. ", " .. turret.position.y .. " for " .. force.name .. " to turret table; size=" .. #egcombat.placed_turrets[force.name])
end
+ return turret
end
local function reloadRangeTech()
@@ -504,7 +505,16 @@ local function onEntityAdded(event)
end
if (entity.type == "ammo-turret" or entity.type == "electric-turret" or entity.type == "fluid-turret") then
- trackNewTurret(egcombat, entity)+ local orig_name = entity.name+ local turret = trackNewTurret(egcombat, entity)+ if turret.name ~= orig_name then+ script.raise_event(defines.events.script_raised_built, {+ mod_name = "EndgameCombat",+ created_entity = turret,+ player_index = event.player_index,+ stack = event.stack,+ })+ end
return
end
end
--
2.17.1
When rangeboost is researched, then Endgame Combat will do a replace upon placing turrets. When it does this, no other mods are able to get an event about the original entity (because it's gone) or the new entity.
I'd request that Endgame Combat generates an event,
script_raised_builtbeing an ideal candidate, providing updated versions of the same parameters thaton_built_entityutilizes. I'd suggest the below patch:If you are approving of this code, then it might be easiest to accept the PR ReikaKalseki/EndgameCombat#3 .
The text was updated successfully, but these errors were encountered: