mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
#CTLD
* Small fix allowing minus signs in template names for repairs
This commit is contained in:
parent
ee409c45a0
commit
ad8938cd74
@ -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
|
||||||
|
|
||||||
@ -1220,7 +1220,7 @@ CTLD.UnitTypes = {
|
|||||||
|
|
||||||
--- CTLD class version.
|
--- CTLD class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
CTLD.version="1.0.33"
|
CTLD.version="1.0.34"
|
||||||
|
|
||||||
--- Instantiate a new CTLD.
|
--- Instantiate a new CTLD.
|
||||||
-- @param #CTLD self
|
-- @param #CTLD self
|
||||||
@ -2007,6 +2007,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
|
||||||
@ -2023,7 +2024,9 @@ function CTLD:_FindRepairNearby(Group, Unit, Repairtype)
|
|||||||
nearestDistance = distance
|
nearestDistance = distance
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--self:I("Distance: ".. nearestDistance)
|
||||||
|
|
||||||
-- found one and matching distance?
|
-- found one and matching distance?
|
||||||
if nearestGroup == nil or nearestDistance > self.EngineerSearch then
|
if nearestGroup == nil or nearestDistance > self.EngineerSearch then
|
||||||
self:_SendMessage("No unit close enough to repair!", 10, false, Group)
|
self:_SendMessage("No unit close enough to repair!", 10, false, Group)
|
||||||
@ -2035,8 +2038,10 @@ function CTLD:_FindRepairNearby(Group, Unit, Repairtype)
|
|||||||
-- helper to find matching template
|
-- helper to find matching template
|
||||||
local function matchstring(String,Table)
|
local function matchstring(String,Table)
|
||||||
local match = false
|
local match = false
|
||||||
if type(Table) == "table" then
|
String = string.gsub(String,"-"," ")
|
||||||
|
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
|
||||||
@ -2044,6 +2049,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
|
||||||
@ -2053,6 +2059,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
|
||||||
@ -2062,6 +2069,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
|
||||||
|
|
||||||
@ -2076,7 +2084,7 @@ end
|
|||||||
-- @param #number Number Number of objects in Crates (found) to limit search.
|
-- @param #number Number Number of objects in Crates (found) to limit search.
|
||||||
-- @param #boolean Engineering If true it is an Engineering repair.
|
-- @param #boolean Engineering If true it is an Engineering repair.
|
||||||
function CTLD:_RepairObjectFromCrates(Group,Unit,Crates,Build,Number,Engineering)
|
function CTLD:_RepairObjectFromCrates(Group,Unit,Crates,Build,Number,Engineering)
|
||||||
self:T(self.lid .. " _RepairObjectFromCrates")
|
self:T(self.lid .. " _RepairObjectFromCrates")
|
||||||
local build = Build -- -- #CTLD.Buildable
|
local build = Build -- -- #CTLD.Buildable
|
||||||
local Repairtype = build.Template -- #string
|
local Repairtype = build.Template -- #string
|
||||||
local NearestGroup, CargoType = self:_FindRepairNearby(Group,Unit,Repairtype) -- Wrapper.Group#GROUP, #CTLD_CARGO
|
local NearestGroup, CargoType = self:_FindRepairNearby(Group,Unit,Repairtype) -- Wrapper.Group#GROUP, #CTLD_CARGO
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user