Hey Linver,
So heres the code to add.
I ammended the Player line, so that it actually grabs the player that built the offshore pump when robots also do it, i need this to work also for my map markers. Then theres just my 3 lines of code in.
local function onBuiltAnEntity(event)
local old_entity = event.created_entity or event.entity
if old_entity.valid and old_entity.name == "offshore-pump" then
local with_damage = old_entity.prototype.max_health - old_entity.health
local network = old_entity.circuit_connection_definitions
local pos = old_entity.position
local force = old_entity.force
local direction = old_entity.direction
local surface = old_entity.surface
local player = old_entity.last_user
if old_entity and old_entity.valid then
old_entity.destroy()
end
local new_entity = surface.create_entity
{
name = "kr-electric-offshore-pump",
position = pos,
direction = direction,
force = force,
player = player,
create_build_effect_smoke = false,
raise_built = false
}
if game.active_mods["WaterAsAResource"] then
remote.call("WaaR","build", new_entity, true)
end
-- Set in the new entity the health of the destroyed entity
if with_damage > 0 then
new_entity.damage(with_damage, game.forces.neutral)
end
end
end
Would you also put in an optional dependency for (?)WaterAsAResource >= 0.7.8.
Thanks.