mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Update Set.lua
Added SET_CLIENT:FilterCallsigns() and SET_CLIENT:FilterPlayernames()
This commit is contained in:
@@ -386,7 +386,7 @@ do -- SET_BASE
|
|||||||
-- @param #SET_BASE self
|
-- @param #SET_BASE self
|
||||||
-- @return Core.Base#BASE
|
-- @return Core.Base#BASE
|
||||||
function SET_BASE:GetLast()
|
function SET_BASE:GetLast()
|
||||||
local tablemax = table.maxn(self.Index)
|
local tablemax = table.maxn(self.Index)
|
||||||
local ObjectName = self.Index[tablemax]
|
local ObjectName = self.Index[tablemax]
|
||||||
local LastObject = self.Set[ObjectName]
|
local LastObject = self.Set[ObjectName]
|
||||||
self:T3( { LastObject } )
|
self:T3( { LastObject } )
|
||||||
@@ -397,7 +397,7 @@ do -- SET_BASE
|
|||||||
-- @param #SET_BASE self
|
-- @param #SET_BASE self
|
||||||
-- @return Core.Base#BASE
|
-- @return Core.Base#BASE
|
||||||
function SET_BASE:GetRandom()
|
function SET_BASE:GetRandom()
|
||||||
local tablemax = table.maxn(self.Index)
|
local tablemax = table.maxn(self.Index)
|
||||||
local RandomItem = self.Set[self.Index[math.random(1,tablemax)]]
|
local RandomItem = self.Set[self.Index[math.random(1,tablemax)]]
|
||||||
self:T3( { RandomItem } )
|
self:T3( { RandomItem } )
|
||||||
return RandomItem
|
return RandomItem
|
||||||
@@ -3808,6 +3808,8 @@ do -- SET_CLIENT
|
|||||||
Countries = nil,
|
Countries = nil,
|
||||||
ClientPrefixes = nil,
|
ClientPrefixes = nil,
|
||||||
Zones = nil,
|
Zones = nil,
|
||||||
|
Playernames = nil,
|
||||||
|
Callsigns = nil,
|
||||||
},
|
},
|
||||||
FilterMeta = {
|
FilterMeta = {
|
||||||
Coalitions = {
|
Coalitions = {
|
||||||
@@ -3880,6 +3882,40 @@ do -- SET_CLIENT
|
|||||||
return ClientFound
|
return ClientFound
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Builds a set of clients of certain callsigns.
|
||||||
|
-- @param #SET_CLIENT self
|
||||||
|
-- @param #string Callsigns Can be a string e.g. "Ford", or a table of strings e.g. {"Ford","Enfield","Chevy"}
|
||||||
|
-- @return #SET_CLIENT self
|
||||||
|
function SET_CLIENT:Filtercallsigns( Callsigns )
|
||||||
|
if not self.Filter.Callsigns then
|
||||||
|
self.Filter.Callsigns = {}
|
||||||
|
end
|
||||||
|
if type( Callsigns ) ~= "table" then
|
||||||
|
Callsigns = { Callsigns }
|
||||||
|
end
|
||||||
|
for callsignID, callsign in pairs( Callsigns ) do
|
||||||
|
self.Filter.Coalitions[Callsigns] = Callsigns
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Builds a set of clients of certain playernames.
|
||||||
|
-- @param #SET_CLIENT self
|
||||||
|
-- @param #string Playernames Can be a string e.g. "Apple", or a table of strings e.g. {"Walter","Hermann","Gonzo"}
|
||||||
|
-- @return #SET_CLIENT self
|
||||||
|
function SET_CLIENT:FilterPlayernames( Playernames )
|
||||||
|
if not self.Filter.Playernames then
|
||||||
|
self.Filter.Playernames = {}
|
||||||
|
end
|
||||||
|
if type( Playernames ) ~= "table" then
|
||||||
|
Playernames = { Playernames }
|
||||||
|
end
|
||||||
|
for PlayernameID, Playernames in pairs( Playernames ) do
|
||||||
|
self.Filter.Coalitions[Playernames] = Playernames
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
--- Builds a set of clients of coalitions.
|
--- Builds a set of clients of coalitions.
|
||||||
-- Possible current coalitions are red, blue and neutral.
|
-- Possible current coalitions are red, blue and neutral.
|
||||||
-- @param #SET_CLIENT self
|
-- @param #SET_CLIENT self
|
||||||
@@ -4235,20 +4271,44 @@ do -- SET_CLIENT
|
|||||||
self:T( { "Evaluated Prefix", MClientPrefix } )
|
self:T( { "Evaluated Prefix", MClientPrefix } )
|
||||||
MClientInclude = MClientInclude and MClientPrefix
|
MClientInclude = MClientInclude and MClientPrefix
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
if self.Filter.Zones then
|
if self.Filter.Zones then
|
||||||
local MClientZone = false
|
local MClientZone = false
|
||||||
for ZoneName, Zone in pairs( self.Filter.Zones ) do
|
for ZoneName, Zone in pairs( self.Filter.Zones ) do
|
||||||
self:T3( "Zone:", ZoneName )
|
self:T3( "Zone:", ZoneName )
|
||||||
local unit = MClient:GetClientGroupUnit()
|
local unit = MClient:GetClientGroupUnit()
|
||||||
if unit and unit:IsInZone(Zone) then
|
if unit and unit:IsInZone(Zone) then
|
||||||
MClientZone = true
|
MClientZone = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
MClientInclude = MClientInclude and MClientZone
|
MClientInclude = MClientInclude and MClientZone
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if self.Filter.Playernames then
|
||||||
|
local MClientPlayername = false
|
||||||
|
local playername = MClient:GetPlayerName()
|
||||||
|
for _,_Playername in pairs(self.Filter.Playernames) do
|
||||||
|
if playername and playername == _Playername then
|
||||||
|
MClientPlayername = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self:T( { "Evaluated Playername", MClientPlayername } )
|
||||||
|
MClientInclude = MClientInclude and MClientPlayername
|
||||||
|
end
|
||||||
|
|
||||||
|
if self.Filter.Callsigns then
|
||||||
|
local MClientCallsigns = false
|
||||||
|
local callsign = MClient:GetCallsign()
|
||||||
|
for _,_Callsign in pairs(self.Filter.Callsigns) do
|
||||||
|
if callsign and string.find(callsign,_Callsign) then
|
||||||
|
MClientCallsigns = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self:T( { "Evaluated Callsign", MClientCallsigns } )
|
||||||
|
MClientInclude = MClientInclude and MClientCallsigns
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
self:T2( MClientInclude )
|
self:T2( MClientInclude )
|
||||||
return MClientInclude
|
return MClientInclude
|
||||||
end
|
end
|
||||||
@@ -6786,23 +6846,23 @@ do -- SET_SCENERY
|
|||||||
-- @return #SET_SCENERY
|
-- @return #SET_SCENERY
|
||||||
-- @usage
|
-- @usage
|
||||||
-- -- Define a new SET_SCENERY Object. This Object will contain a reference to all added Scenery Objects.
|
-- -- Define a new SET_SCENERY Object. This Object will contain a reference to all added Scenery Objects.
|
||||||
-- ZoneSet = SET_ZONE:New():FilterPrefixes("Bridge"):FilterOnce()
|
-- ZoneSet = SET_ZONE:New():FilterPrefixes("Bridge"):FilterOnce()
|
||||||
-- mysceneryset = SET_SCENERY:New(ZoneSet)
|
-- mysceneryset = SET_SCENERY:New(ZoneSet)
|
||||||
function SET_SCENERY:New(ZoneSet)
|
function SET_SCENERY:New(ZoneSet)
|
||||||
|
|
||||||
local zoneset = {}
|
local zoneset = {}
|
||||||
-- Inherits from BASE
|
-- Inherits from BASE
|
||||||
local self = BASE:Inherit( self, SET_BASE:New( zoneset ) ) -- Core.Set#SET_SCENERY
|
local self = BASE:Inherit( self, SET_BASE:New( zoneset ) ) -- Core.Set#SET_SCENERY
|
||||||
|
|
||||||
local zonenames = {}
|
local zonenames = {}
|
||||||
|
|
||||||
if ZoneSet then
|
if ZoneSet then
|
||||||
for _,_zone in pairs(ZoneSet.Set) do
|
for _,_zone in pairs(ZoneSet.Set) do
|
||||||
self:T("Zone type handed: "..tostring(_zone.ClassName))
|
self:T("Zone type handed: "..tostring(_zone.ClassName))
|
||||||
table.insert(zonenames,_zone:GetName())
|
table.insert(zonenames,_zone:GetName())
|
||||||
end
|
end
|
||||||
self:AddSceneryByName(zonenames)
|
self:AddSceneryByName(zonenames)
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@@ -6986,6 +7046,6 @@ do -- SET_SCENERY
|
|||||||
-- @return #SET_SCENERY self
|
-- @return #SET_SCENERY self
|
||||||
function SET_SCENERY:IsIncludeObject( MScenery )
|
function SET_SCENERY:IsIncludeObject( MScenery )
|
||||||
self:F2( MScenery )
|
self:F2( MScenery )
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user