mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 11:35:22 +09:00
Bug Fixing Round Two
This commit is contained in:
@@ -6,6 +6,8 @@ local max_time_to_live = 4294967295 -- unit32 max
|
||||
Commands.new_command('repair','Repairs entities on your force around you')
|
||||
:add_param('range',false,'integer-range',1,config.max_range)
|
||||
:register(function(player,range,raw)
|
||||
local revive_count = 0
|
||||
local heal_count = 0
|
||||
local range2 = range^2
|
||||
local surface = player.surface
|
||||
local center = player.position
|
||||
@@ -13,12 +15,13 @@ Commands.new_command('repair','Repairs entities on your force around you')
|
||||
if config.allow_ghost_revive then
|
||||
local ghosts = surface.find_entities_filtered({area=area,type='entity-ghost',force=player.force})
|
||||
for _,ghost in pairs(ghosts) do
|
||||
if ghost.valid and entity.force == player.force then
|
||||
if ghost.valid then
|
||||
local x = ghost.position.x-center.x
|
||||
local y = ghost.position.y-center.y
|
||||
if x^2+y^2 <= range2 then
|
||||
if config.allow_blueprint_repair or ghost.time_to_live ~= max_time_to_live then
|
||||
ghost.revive()
|
||||
revive_count = revive_count+1
|
||||
if not config.disallow[ghost.ghost_name] then ghost.revive() end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -27,11 +30,15 @@ Commands.new_command('repair','Repairs entities on your force around you')
|
||||
if config.allow_heal_entities then
|
||||
local entities = surface.find_entities_filtered({area=area,force=player.force})
|
||||
for _,entity in pairs(entities) do
|
||||
local x = entity.position.x-center.x
|
||||
local y = entity.position.y-center.y
|
||||
if entity.health and x^2+y^2 <= range2 then
|
||||
entity.health = max_time_to_live
|
||||
if entity.valid then
|
||||
local x = entity.position.x-center.x
|
||||
local y = entity.position.y-center.y
|
||||
if entity.health and entity.get_health_ratio() ~= 1 and x^2+y^2 <= range2 then
|
||||
heal_count = heal_count+1
|
||||
entity.health = max_time_to_live
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return Commands.success{'exp-commands.repair-result',revive_count,heal_count}
|
||||
end)
|
||||
Reference in New Issue
Block a user