Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set 'raise_built' and 'raise_destroy' to let other mods know when you modify their entities. #11

Closed
wants to merge 3 commits into from

Conversation

Kingdud
Copy link

@Kingdud Kingdud commented Sep 30, 2020

One of my mods (Turret Shields) was having problems with yours (Hero Turrets). Long story short, you were not sending the raise_built and raise_destroy flags when you destroyed/built entities during a turret upgrade. These events allow other mods (mine) to know that something happened to their entities.

What was happening without these flags was that my array of turrets (keyed by unitID) was having the entities it referred to removed, but without the cleanup process my own code does to remove the shield entity when the turret goes away. This ended up meaning that upgraded turrets had no shields and there were lots of dangling shield entities on the map as more and more turrets got upgraded. These two changes completely remove this problem.

Only two lines of code were actually changed:

`diff --git a/ModMash/HeroTurrets/prototypes/scripts/turrets.lua b/ModMash/HeroTurrets/prototypes/scripts/turrets.lua
index bac6fa1..f32c31f 100644
--- a/ModMash/HeroTurrets/prototypes/scripts/turrets.lua
+++ b/ModMash/HeroTurrets/prototypes/scripts/turrets.lua
@@ -45,8 +45,8 @@ local local_replace_turret = function(entity,recipe)
c = i.get_contents()
end

  •   entity.destroy()
    
  •   local new_entity = s.create_entity{name=recipe.name, position=p, force = f, direction = d, orientation = o}
    
  •   entity.destroy({raise_destroy = true})
    
  •   local new_entity = s.create_entity{name=recipe.name, position=p, force = f, direction = d, orientation = o, raise_built = true}
    

`

Everything else was bringing the code I got from forking your repo up to date with the code that was in the current release version of the mod (your repo has 1.24; the release version is 1.26).

@pixelwhipped
Copy link
Owner

was done prior release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants