1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-11-29 22:47:52 +02:00

Beams - fix abuse

This commit is contained in:
Gerkiz
2022-12-23 00:52:12 +01:00
parent 0ed24ffd38
commit d5f9d5a8f6

View File

@@ -3,7 +3,23 @@ local Global = require 'utils.global'
local Gui = require 'utils.gui'
local this = {
renders = {}
renders = {},
valid_targets = {
'character',
'tank',
'car',
'lab',
'locomotive',
'cargo-wagon',
'fluid-wagon',
'artillery-wagon',
'artillery-turret',
'laser-turret',
'gun-turret',
'flamethrower-turret',
'silo',
'spidertron'
}
}
local Public = {}
@@ -20,25 +36,6 @@ Global.register(
end
)
local target_entities = {
'character',
'tank',
'car',
'radar',
'lab',
'furnace',
'locomotive',
'cargo-wagon',
'fluid-wagon',
'artillery-wagon',
'artillery-turret',
'laser-turret',
'gun-turret',
'flamethrower-turret',
'silo',
'spidertron'
}
local sqrt = math.sqrt
local random = math.random
local remove = table.remove
@@ -58,7 +55,7 @@ end
function Public:new_target()
local surface = game.get_surface(self.surface_id)
local position
local entities = surface.find_entities_filtered {type = target_entities}
local entities = surface.find_entities_filtered {type = this.valid_targets}
if entities and #entities > 0 then
position = entities[random(#entities)].position
end