LuaEntity.priority_targets for Turrets
Posted: Sat Dec 21, 2024 9:14 pm
Currently the only way to check the priority targets of turrets is to call LuaEntity.get_priority_target(index) for increasing indices until an Index out of bounds error is raised (the amount of targets isn't able to be read either AFAIK).
A LuaEntity.priority_targets::array[LuaEntityPrototype] would be cleaner.
vs
A LuaEntity.priority_targets::array[LuaEntityPrototype] would be cleaner.
Code: Select all
local targets = entity.priority_targets
Code: Select all
local targets = {}
local index = 0
while true do
index = index + 1
local success, target = pcall(entity.get_priority_target, index)
if not success then break end
table.insert(targets, target)
end