* Small fix allowing minus signs in template names for repairs
This commit is contained in:
Applevangelist 2023-04-15 16:19:35 +02:00
parent 9e138aa149
commit b402a99a25

View File

@ -22,7 +22,7 @@
-- @module Ops.CTLD -- @module Ops.CTLD
-- @image OPS_CTLD.jpg -- @image OPS_CTLD.jpg
-- Last Update Mar 2023 -- Last Update Apr 2023
do do
@ -2005,6 +2005,7 @@ end
function CTLD:_FindRepairNearby(Group, Unit, Repairtype) function CTLD:_FindRepairNearby(Group, Unit, Repairtype)
self:T(self.lid .. " _FindRepairNearby") self:T(self.lid .. " _FindRepairNearby")
--self:I({Group:GetName(),Unit:GetName(),Repairtype})
local unitcoord = Unit:GetCoordinate() local unitcoord = Unit:GetCoordinate()
-- find nearest group of deployed groups -- find nearest group of deployed groups
@ -2035,6 +2036,7 @@ function CTLD:_FindRepairNearby(Group, Unit, Repairtype)
local match = false local match = false
if type(Table) == "table" then if type(Table) == "table" then
for _,_name in pairs (Table) do for _,_name in pairs (Table) do
_name = string.gsub(_name,"-"," ")
if string.find(String,_name) then if string.find(String,_name) then
match = true match = true
break break
@ -2042,6 +2044,7 @@ function CTLD:_FindRepairNearby(Group, Unit, Repairtype)
end end
else else
if type(String) == "string" then if type(String) == "string" then
Table = string.gsub(Table,"-"," ")
if string.find(String,Table) then match = true end if string.find(String,Table) then match = true end
end end
end end
@ -2051,6 +2054,7 @@ function CTLD:_FindRepairNearby(Group, Unit, Repairtype)
-- walk through generics and find matching type -- walk through generics and find matching type
local Cargotype = nil local Cargotype = nil
for k,v in pairs(self.Cargo_Crates) do for k,v in pairs(self.Cargo_Crates) do
--self:I({groupname,v.Templates,Repairtype})
if matchstring(groupname,v.Templates) and matchstring(groupname,Repairtype) then if matchstring(groupname,v.Templates) and matchstring(groupname,Repairtype) then
Cargotype = v -- #CTLD_CARGO Cargotype = v -- #CTLD_CARGO
break break
@ -2060,6 +2064,7 @@ function CTLD:_FindRepairNearby(Group, Unit, Repairtype)
if Cargotype == nil then if Cargotype == nil then
return nil, nil return nil, nil
else else
--self:I({groupname,Cargotype})
return nearestGroup, Cargotype return nearestGroup, Cargotype
end end