mirror of
https://github.com/akaAgar/the-universal-mission-for-dcs-world.git
synced 2025-11-25 19:31:01 +00:00
Cleaned up and added comments to DCSEx tables
This commit is contained in:
parent
33f8986317
commit
8d05b98a95
@ -1,6 +1,6 @@
|
||||
-- ====================================================================================
|
||||
-- (DCS LUA ADD-ON) CONVERTER - UNITS CONVERSION FUNCTIONS
|
||||
--
|
||||
-- DCSEX.CONVERTER - UNITS CONVERSION FUNCTIONS
|
||||
-- ====================================================================================
|
||||
-- DCSEx.converter.celsiusToFahrenheit(t)
|
||||
-- DCSEx.converter.degreesToRadians(degrees)
|
||||
-- DCSEx.converter.fahrenheitToCelsius(fahrenheit)
|
||||
@ -21,6 +21,7 @@ DCSEx.converter = {}
|
||||
|
||||
-------------------------------------
|
||||
-- Converts Celsius degrees to Fahrenheit
|
||||
-------------------------------------
|
||||
-- @param t Temperature in Celsius degrees
|
||||
-- @return Temperature in Fahrenheit degrees
|
||||
-------------------------------------
|
||||
@ -30,6 +31,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Converts angle in degrees to radians.
|
||||
-------------------------------------
|
||||
-- @param degrees Angle in degrees
|
||||
-- @return Angle in radians
|
||||
-------------------------------------
|
||||
@ -39,6 +41,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Converts Fahrenheit degrees to Celsius
|
||||
-------------------------------------
|
||||
-- @param fahrenheit Temperature in Fahrenheit degrees
|
||||
-- @return Temperature in Celsius degrees
|
||||
-------------------------------------
|
||||
@ -48,6 +51,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Converts feet to meters.
|
||||
-------------------------------------
|
||||
-- @param feet Distance in feet
|
||||
-- @return Distance in meters
|
||||
-------------------------------------
|
||||
@ -57,6 +61,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Converts Kelvin degrees to Celsius
|
||||
-------------------------------------
|
||||
-- @param kelvin Temperature in Kelvin degrees
|
||||
-- @return Temperature in Celsius degrees
|
||||
-------------------------------------
|
||||
@ -66,6 +71,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Converts Kelvin degrees to Fahrenheit
|
||||
-------------------------------------
|
||||
-- @param kelvin Temperature in Kelvin degrees
|
||||
-- @return Temperature in Fahrenheit degrees
|
||||
-------------------------------------
|
||||
@ -75,6 +81,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Converts kilometers per hour to meters per second.
|
||||
-------------------------------------
|
||||
-- @param kmph speed in km/h
|
||||
-- @return speed in m/s
|
||||
-------------------------------------
|
||||
@ -84,6 +91,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Converts knots to meters per second.
|
||||
-------------------------------------
|
||||
-- @param knots speed in knots
|
||||
-- @return speed in m/s
|
||||
-------------------------------------
|
||||
@ -93,6 +101,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Converts meters to feet.
|
||||
-------------------------------------
|
||||
-- @param meters distance in meters
|
||||
-- @return distance in feet
|
||||
-------------------------------------
|
||||
@ -102,6 +111,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Converts meters to nautical miles.
|
||||
-------------------------------------
|
||||
-- @param meters distance in meters
|
||||
-- @return distance in nautical miles
|
||||
-------------------------------------
|
||||
@ -111,6 +121,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Converts meters per second to kilometers per hour.
|
||||
-------------------------------------
|
||||
-- @param mps speed in m/s
|
||||
-- @return speed in km/h
|
||||
-------------------------------------
|
||||
@ -120,6 +131,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Converts meters per second to knots.
|
||||
-------------------------------------
|
||||
-- @param mps speed in m/s
|
||||
-- @return speed in knots
|
||||
-------------------------------------
|
||||
@ -129,6 +141,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Converts nautical miles to meters.
|
||||
-------------------------------------
|
||||
-- @param nm distance in nautical miles
|
||||
-- @return distance in meters
|
||||
-------------------------------------
|
||||
@ -138,6 +151,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Converts angle in radians to degrees.
|
||||
-------------------------------------
|
||||
-- @param degrees Angle in radians
|
||||
-- @return Angle in degrees
|
||||
-------------------------------------
|
||||
|
||||
@ -1,33 +1,32 @@
|
||||
-- ====================================================================================
|
||||
-- DCSTOOLS - FUNCTIONS LINKED TO DCS WORLD RULES AND TABLES
|
||||
-- DCSEX.DCS - FUNCTIONS HANDLING DCS WORLD'S GAME RULES AND TABLES
|
||||
-- ====================================================================================
|
||||
-- DCSEx.dcs.getBRAA(point, refPoint, showAltitude, metricSystem, casualFormat)
|
||||
-- DCSEx.dcs.getCJTFForCoalition(coalitionID)
|
||||
-- DCSEx.dcs.getCoalitionAsString(coalitionID)
|
||||
-- DCSEx.dcs.getCoalitionColor(coalitionID, alpha)
|
||||
-- DCSEx.dcs.getFirstUnitCallsign(group)
|
||||
-- DCSEx.dcs.getGroupCenterPoint(group)
|
||||
-- DCSEx.dcs.getGroupIDAsNumber(group)
|
||||
-- DCSEx.dcs.getNearestObject(refPoint, objectTable)
|
||||
-- DCSEx.dcs.getNearestObjects(refPoint, objectTable, maxCount)
|
||||
-- DCSEx.dcs.getNearestPoints(refPoint, pointsTable, maxCount)
|
||||
-- DCSEx.dcs.getObjectIDAsNumber(obj)
|
||||
-- DCSEx.dcs.getOppositeCoalition(coalitionID)
|
||||
-- DCSEx.dcs.getPlayerUnitsInGroup(group)
|
||||
-- DCSEx.dcs.getPlayerUnitsInGroupByID(groupID)
|
||||
-- DCSEx.dcs.getRadioModulationName(modulationID)
|
||||
-- DCSEx.dcs.getObjectIDAsNumber(obj)
|
||||
-- DCSEx.dcs.getUnitTypeFromFamily(unitFamily)
|
||||
-- DCSEx.dcs.getUnitFamilyForDecade(unitFamily, decade) -- TODO: remove?
|
||||
-- DCSEx.dcs.getUnitCategoryFromFamily(unitFamily)
|
||||
-- DCSEx.dcs.loadMission(fileName)
|
||||
-- DCSEx.dcs.outPicture(fileName, durationSeconds, clearView, startDelay, horizontalAlign, verticalAlign, size, sizeUnits)
|
||||
-- ====================================================================================
|
||||
|
||||
DCSEx.dcs = { }
|
||||
|
||||
-- TODO: add description and update file header
|
||||
function DCSEx.dcs.doNothing()
|
||||
end
|
||||
|
||||
-------------------------------------
|
||||
-- Gets a BRAA (bearing, range, altitude, aspect) string about a point
|
||||
-- Format is "[bearing to unit] for [distance] at [altitude]"
|
||||
-------------------------------------
|
||||
-- @param unit A unit
|
||||
-- @param refPoint Reference point for the bearing and distance
|
||||
-- @param showAltitude Should altitude be displayed?
|
||||
@ -86,6 +85,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns the CJTF country for a given coalition
|
||||
-------------------------------------
|
||||
-- @param A coalition ID
|
||||
-- @return A country ID (country.id.CJTF_BLUE or country.id.CJTF_RED)
|
||||
-------------------------------------
|
||||
@ -97,6 +97,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns the name of a coalition, as a string ("blue", "red" or "neutral")
|
||||
-------------------------------------
|
||||
-- @param A coalition ID
|
||||
-- @return A string
|
||||
-------------------------------------
|
||||
@ -109,8 +110,9 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns the RGBA color table for the given coalition, accoding to NATO symbology colors
|
||||
-------------------------------------
|
||||
-- @param coalitionID A coalition side
|
||||
-- @param alpha (optional) Alpha. Default is 1
|
||||
-- @param alpha (optional) Alpha. Default is 1.0
|
||||
-- @return A RGBA color table
|
||||
-------------------------------------
|
||||
function DCSEx.dcs.getCoalitionColor(coalitionID, alpha)
|
||||
@ -123,7 +125,12 @@ function DCSEx.dcs.getCoalitionColor(coalitionID, alpha)
|
||||
end
|
||||
end
|
||||
|
||||
-- TODO: description
|
||||
-------------------------------------
|
||||
-- Returns the callsign table for the first unit of the group
|
||||
-------------------------------------
|
||||
-- @param group A group
|
||||
-- @return A callsign table, or nil if no units or no group
|
||||
-------------------------------------
|
||||
function DCSEx.dcs.getFirstUnitCallsign(group)
|
||||
if not group then return nil end
|
||||
|
||||
@ -137,6 +144,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns a vec3 point at the center of all units of a group
|
||||
-------------------------------------
|
||||
-- @param group A group object
|
||||
-- @return A vec3
|
||||
-------------------------------------
|
||||
@ -162,6 +170,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns the ID of a group as a number (here to fix a bug where sometimes ID is returned as a string)
|
||||
-------------------------------------
|
||||
-- @param group A group table
|
||||
-- @return An ID (as an number) or nil if group is nil or has no ID
|
||||
-------------------------------------
|
||||
@ -175,6 +184,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns the object nearest (in a 2D plane) from a given point
|
||||
-------------------------------------
|
||||
-- @param refPoint A reference point, as a vec2 or vec3
|
||||
-- @param objectTable A table of DCS objects
|
||||
-- @return The object nearest from the point, or nil if no object was found
|
||||
@ -187,6 +197,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns the nearest objects (in a 2D plane) from a given point
|
||||
-------------------------------------
|
||||
-- @param refPoint A reference point, as a vec2 or vec3
|
||||
-- @param objectTable A table of DCS objects
|
||||
-- @param maxCount (optional) Maximum number of objects to return
|
||||
@ -218,6 +229,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns the nearest points (in a 2D plane) from a given point
|
||||
-------------------------------------
|
||||
-- @param refPoint A reference point, as a vec2 or vec3
|
||||
-- @param objectTable A table of points (vec2 or vec3)
|
||||
-- @param maxCount (optional) Maximum number of points to return
|
||||
@ -249,6 +261,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns the coalition opposed to the provided coalition (coalition.side.NEUTRAL still returns NEUTRAL)
|
||||
-------------------------------------
|
||||
-- @param group A coalition
|
||||
-- @return Another coalition
|
||||
-------------------------------------
|
||||
@ -260,6 +273,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns all player-controlled units in a group
|
||||
-------------------------------------
|
||||
-- @param group A group object
|
||||
-- @return A table of unit objects
|
||||
-------------------------------------
|
||||
@ -280,6 +294,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns all player-controlled units in the group with the given ID
|
||||
-------------------------------------
|
||||
-- @param groupID A group ID
|
||||
-- @return A table of unit objects
|
||||
-------------------------------------
|
||||
@ -289,6 +304,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns a radio modulation type as a string
|
||||
-------------------------------------
|
||||
-- @param modulationID A modulation ID (from radio.modulation enum)
|
||||
-- @return A string
|
||||
-------------------------------------
|
||||
@ -297,66 +313,9 @@ function DCSEx.dcs.getRadioModulationName(modulationID)
|
||||
return "AM"
|
||||
end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns a remplacement unit family for given family if it's not available in this decade (e.g. SAMs in the 1940s). Else returns the original family.
|
||||
-- @param unitFamily An unit family
|
||||
-- @param decade (optional) A decade, or the current decade from env.mission.date.Year
|
||||
-- @return An unit family
|
||||
-------------------------------------
|
||||
function DCSEx.dcs.getUnitFamilyForDecade(unitFamily, decade)
|
||||
-- TODO
|
||||
-- decade = decade or envMission.getDecade()
|
||||
|
||||
-- if decade < 1990 then
|
||||
-- if unitFamily == DCSEx.enums.unitFamily.UAVs then
|
||||
-- unitFamily = DCSEx.enums.unitFamily.AttackHelicopters
|
||||
-- end
|
||||
-- end
|
||||
|
||||
-- if decade < 1970 then
|
||||
-- if unitFamily == DCSEx.enums.unitFamily.AWACS then
|
||||
-- unitFamily = DCSEx.enums.unitFamily.Transports
|
||||
-- elseif unitFamily == DCSEx.enums.unitFamily.SAMShort then
|
||||
-- unitFamily = DCSEx.enums.unitFamily.MobileAAA
|
||||
-- elseif unitFamily == DCSEx.enums.unitFamily.SAMShortIR then
|
||||
-- unitFamily = DCSEx.enums.unitFamily.MobileAAA
|
||||
-- end
|
||||
-- end
|
||||
|
||||
-- if decade < 1960 then
|
||||
-- if unitFamily == DCSEx.enums.unitFamily.AttackHelicopters then
|
||||
-- unitFamily = DCSEx.enums.unitFamily.Fighters
|
||||
-- elseif unitFamily == DCSEx.enums.unitFamily.MANPADS then
|
||||
-- unitFamily = DCSEx.enums.unitFamily.Infantry
|
||||
-- elseif unitFamily == DCSEx.enums.unitFamily.SAMLong then
|
||||
-- unitFamily = DCSEx.enums.unitFamily.StaticAAA
|
||||
-- elseif unitFamily == DCSEx.enums.unitFamily.SAMMedium then
|
||||
-- unitFamily = DCSEx.enums.unitFamily.StaticAAA
|
||||
-- elseif unitFamily == DCSEx.enums.unitFamily.SSMissiles then
|
||||
-- unitFamily = DCSEx.enums.unitFamily.Artillery
|
||||
-- elseif unitFamily == DCSEx.enums.unitFamily.TransportHelicopters then
|
||||
-- unitFamily = DCSEx.enums.unitFamily.Transports
|
||||
-- end
|
||||
-- end
|
||||
|
||||
-- if decade < 1950 then
|
||||
-- if unitFamily == DCSEx.enums.unitFamily.MobileAAA then
|
||||
-- unitFamily = DCSEx.enums.unitFamily.APC
|
||||
-- elseif unitFamily == DCSEx.enums.unitFamily.Tankers then
|
||||
-- unitFamily = DCSEx.enums.unitFamily.Transports
|
||||
-- end
|
||||
-- end
|
||||
|
||||
return unitFamily
|
||||
end
|
||||
|
||||
-- TODO: description
|
||||
function DCSEx.dcs.getUnitTypeFromFamily(unitFamily)
|
||||
return math.floor(unitFamily / 100)
|
||||
end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns the ID of an object as a number (here to fix a bug where sometimes ID is returned as a string)
|
||||
-------------------------------------
|
||||
-- @param obj An object (unit, static object...)
|
||||
-- @return An ID (as an number) or nil if unit is nil or has no ID
|
||||
-------------------------------------
|
||||
@ -365,21 +324,36 @@ function DCSEx.dcs.getObjectIDAsNumber(obj)
|
||||
return tonumber(obj:getID())
|
||||
end
|
||||
|
||||
-- TODO: description & file header
|
||||
-------------------------------------
|
||||
-- Returns a the unit category (Unit.Category enum) an unit family (DCSEx.enums.unitFamily) belongs to
|
||||
-------------------------------------
|
||||
-- @param unitFamily A value from the Unit.Category enum
|
||||
-- @return A value from the DCSEx.enums.unitFamily enum
|
||||
-------------------------------------
|
||||
function DCSEx.dcs.getUnitCategoryFromFamily(unitFamily)
|
||||
return math.floor(unitFamily / 100)
|
||||
end
|
||||
|
||||
-------------------------------------
|
||||
-- Loads another DCS World mission
|
||||
-------------------------------------
|
||||
-- @param fileName Filename of the mission
|
||||
-------------------------------------
|
||||
function DCSEx.dcs.loadMission(fileName)
|
||||
net.dostring_in("mission", string.format("a_load_mission(\"%s\")", fileName))
|
||||
end
|
||||
|
||||
-- TODO: description & file header
|
||||
-- function DCSEx.dcs.isMultiplayer()
|
||||
-- if #net.get_player_list() > 0 then return true end
|
||||
-- if dcs and dcs.isServer() == true then return true end
|
||||
-- return false
|
||||
-- end
|
||||
|
||||
-- TODO: a_end_mission
|
||||
|
||||
-- TODO: description & file header
|
||||
-------------------------------------
|
||||
-- Displays a picture on the screen of ALL players
|
||||
-------------------------------------
|
||||
-- @param fileName Filename/ResourceName of the image in the mission resources
|
||||
-- @param durationSeconds Duration (in seconds) during which the image should be displayed
|
||||
-- @param startDelay After how many seconds should the image be displayed? (default: 0)
|
||||
-- @param horizontalAlign Horizontal alignment of the image (0/1/2=left/center/right) (default: 1)
|
||||
-- @param verticalAlign Vertical alignment of the image (0/1/2=top/center/bottom) (default: 1)
|
||||
-- @param size Size of the image, in pixels or % of the screen (see sizeUnits) (default: 100)
|
||||
-- @param sizeUnits If 0, the size parameter is in pixels. If 1, it's in % of screen size (default: 0)
|
||||
-------------------------------------
|
||||
function DCSEx.dcs.outPicture(fileName, durationSeconds, clearView, startDelay, horizontalAlign, verticalAlign, size, sizeUnits)
|
||||
clearView = clearView or false
|
||||
startDelay = startDelay or 0
|
||||
|
||||
@ -1,7 +1,19 @@
|
||||
-- ====================================================================================
|
||||
-- DCSEX.ENUMS - VARIOUS ENUMS
|
||||
-- ====================================================================================
|
||||
-- DCSEx.enums.lineType
|
||||
-- DCSEx.enums.taskEvent
|
||||
-- DCSEx.enums.taskFamily
|
||||
-- DCSEx.enums.taskFlag
|
||||
-- DCSEx.enums.timePeriod
|
||||
-- DCSEx.enums.unitFamily
|
||||
-- DCSEx.enums.victoryCondition
|
||||
-- ====================================================================================
|
||||
|
||||
DCSEx.enums = {}
|
||||
|
||||
-------------------------------------
|
||||
-- Line types for map markers. The enum is missing from DCS
|
||||
-- Line types for map markers. This enum is missing from DCS
|
||||
-------------------------------------
|
||||
DCSEx.enums.lineType = {
|
||||
NO_LINE = 0,
|
||||
@ -13,16 +25,6 @@ DCSEx.enums.lineType = {
|
||||
TWO_DASH = 6,
|
||||
}
|
||||
|
||||
-------------------------------------
|
||||
-- Event to check to see if a task/objective is complete
|
||||
-------------------------------------
|
||||
DCSEx.enums.spawnPointType = {
|
||||
LAND_LARGE = 1,
|
||||
LAND_MEDIUM = 2,
|
||||
LAND_SMALL = 3,
|
||||
SEA = 4,
|
||||
}
|
||||
|
||||
-------------------------------------
|
||||
-- Event to check to see if a task/objective is complete
|
||||
-------------------------------------
|
||||
@ -113,11 +115,13 @@ DCSEx.enums.unitFamily = {
|
||||
STATIC_STRUCTURE = 402
|
||||
}
|
||||
|
||||
-------------------------------------
|
||||
-- Victory conditions for tasks/objectives
|
||||
-------------------------------------
|
||||
DCSEx.enums.victoryCondition = {
|
||||
DESTROY = 1,
|
||||
DESTROY_NO_AIR_DEFENSE = 2,
|
||||
DESTROY_SCENERY = 3,
|
||||
DESTROY_TRACK_RADARS_ONLY = 4, -- for SEAD tasks
|
||||
|
||||
LAND_NEAR = 5,
|
||||
LAND_NEAR = 5
|
||||
}
|
||||
|
||||
@ -1,18 +1,20 @@
|
||||
-- ====================================================================================
|
||||
-- (DCS LUA ADD-ON) ENVMISSION - FUNCTIONS RELATED TO THE ENV.MISSION TABLE
|
||||
--
|
||||
-- DCSEX.ENVMISSION - FUNCTIONS RELATED TO THE ENV.MISSION TABLE
|
||||
-- ====================================================================================
|
||||
-- DCSEx.envMission.getDecade(yearOffset)
|
||||
-- DCSEx.envMission.getDistanceToNearestPlayerSpawnPoint(point)
|
||||
-- DCSEx.envMission.getDistanceToNearestPlayerSpawnPoint(coalition, point)
|
||||
-- DCSEx.envMission.getGroup(groupID)
|
||||
-- DCSEx.envMission.getGroups(sideID)
|
||||
-- DCSEx.envMission.getPlayerGroups(coalitionId)
|
||||
-- DCSEx.envMission.getPlayerGroupsCenterPoint(coalitionId)
|
||||
-- DCSEx.envMission.setBriefing(side, text, picture)
|
||||
-- ====================================================================================
|
||||
|
||||
DCSEx.envMission = {}
|
||||
|
||||
-------------------------------------
|
||||
-- Returns the decade during which the mission takes place (1940 to 2010)
|
||||
-------------------------------------
|
||||
-- @param yearOffset An offset to apply to the actual year
|
||||
-- @return The decade, as a number
|
||||
-------------------------------------
|
||||
@ -22,6 +24,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns the distance to the nearest player spawn point
|
||||
-------------------------------------
|
||||
-- @param coalition Coalition the players belong to
|
||||
-- @param point A vec3 or vec2
|
||||
-- @return The distance, in meters, to the nearest player spawn point, or nil if no player spawn points are present
|
||||
@ -42,6 +45,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Gets information about a group
|
||||
-------------------------------------
|
||||
-- @param groupID Group ID
|
||||
-- @return Missiondata group table or nil if ID doesn't exist
|
||||
-------------------------------------
|
||||
@ -59,6 +63,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Gets all unit groups
|
||||
-------------------------------------
|
||||
-- @param sideID Coalition ID (coalition.side.*), or nil to return unit groups from all coalitions
|
||||
-- @return Table of missiondata group tables
|
||||
-------------------------------------
|
||||
@ -98,6 +103,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Gets all player groups
|
||||
-------------------------------------
|
||||
-- @param coalitionId Coalition ID (coalition.side.*), or nil to return unit groups from all coalitions
|
||||
-- @return Table of missiondata group tables
|
||||
-------------------------------------
|
||||
@ -126,6 +132,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Return the center 2D point of all player groups
|
||||
-------------------------------------
|
||||
-- @param coalitionId Coalition ID (coalition.side.*), or nil to use unit groups from all coalitions
|
||||
-- @return A 2D point, or nil if no player groups
|
||||
-------------------------------------
|
||||
@ -145,7 +152,13 @@ function DCSEx.envMission.getPlayerGroupsCenterPoint(coalitionId)
|
||||
return center
|
||||
end
|
||||
|
||||
-- TODO: description & file header
|
||||
-------------------------------------
|
||||
-- Sets the text for the briefing description in the briefing panel
|
||||
-------------------------------------
|
||||
-- @param side Coalition ID (coalition.side.*) of the coalition
|
||||
-- @param text Text of the briefing
|
||||
-- @param picture Resource name of the picture to use for the briefing
|
||||
-------------------------------------
|
||||
function DCSEx.envMission.setBriefing(side, text, picture)
|
||||
text = text or ""
|
||||
text = text:gsub("\n", "\\n")
|
||||
|
||||
@ -1,106 +1,56 @@
|
||||
-- ====================================================================================
|
||||
-- DCSEx.IO - HANDLES READING/WRITING FILES
|
||||
-- DCSEX.IO - HANDLES READING/WRITING FILES
|
||||
-- ====================================================================================
|
||||
-- DCSEx.io.canReadAndWrite()
|
||||
-- DCSEx.io.load(fileName)
|
||||
-- DCSEx.io.save(fileName, values)
|
||||
-- DCSEx.io.save(fileName, str)
|
||||
-- ====================================================================================
|
||||
|
||||
DCSEx.io = {}
|
||||
|
||||
do
|
||||
-------------------------------------
|
||||
-- Returns true if the IO table has been unsanitized (allowing IO operations)
|
||||
-- and false if it hasn't been
|
||||
--
|
||||
-- @return A boolean
|
||||
-------------------------------------
|
||||
function DCSEx.io.canReadAndWrite()
|
||||
return io ~= nil
|
||||
end
|
||||
|
||||
-------------------------------------
|
||||
-- Loads a table from a text file
|
||||
--
|
||||
-- @param fileName Name of the file to read
|
||||
-- @param obfuscate Should the file contents be obfuscated?
|
||||
-- @return A table, or nil if something went wrong
|
||||
-------------------------------------
|
||||
-- function DCSEx.io.load(fileName, obfuscate)
|
||||
-- obfuscate = obfuscate or false -- TODO: obfuscation
|
||||
|
||||
-- -- IO table is sanitized, cannot read/write to disk
|
||||
-- if not DCSEx.io.canReadAndWrite() then return nil end
|
||||
|
||||
-- local saveFile = io.open(fileName, "r")
|
||||
-- if not saveFile then return nil end
|
||||
|
||||
-- local values = {}
|
||||
-- local rawText = saveFile:read("*all")
|
||||
-- for k, v in string.gmatch(rawText, "(%w+)=(%w+)") do
|
||||
-- local numval = tonumber(v)
|
||||
-- if numval then
|
||||
-- values[k] = tonumber(v)
|
||||
-- else
|
||||
-- values[k] = v
|
||||
-- -- trigger.action.outText("GET value \""..k.."\" AT \""..tostring(v).."\"", 1)
|
||||
-- end
|
||||
-- end
|
||||
-- saveFile:close()
|
||||
|
||||
-- return values
|
||||
-- end
|
||||
|
||||
function DCSEx.io.load(fileName)
|
||||
-- IO table is sanitized, cannot read/write to disk
|
||||
if not DCSEx.io.canReadAndWrite() then return nil end
|
||||
|
||||
local saveFile = io.open(fileName, "r")
|
||||
if not saveFile then return nil end
|
||||
local str = saveFile:read("*all")
|
||||
saveFile:close()
|
||||
|
||||
return str
|
||||
end
|
||||
|
||||
-------------------------------------
|
||||
-- Saves a table to a text file
|
||||
--
|
||||
-- @param fileName Name of the file to write to
|
||||
-- @param values Key/value table containing the values to save
|
||||
-- @param obfuscate Should the file contents be obfuscated?
|
||||
-- @return True if everything went right, false otherwise
|
||||
-------------------------------------
|
||||
-- function DCSEx.io.save(fileName, values, obfuscate)
|
||||
-- obfuscate = obfuscate or false -- TODO: obfuscation
|
||||
|
||||
-- -- IO table is sanitized, cannot read/write to disk
|
||||
-- if not DCSEx.io.canReadAndWrite() then return false end
|
||||
|
||||
-- -- No values or not a table
|
||||
-- if values == nil then return false end
|
||||
-- if type(values) ~= "table" then return false end
|
||||
|
||||
-- local saveFile = io.open(fileName, "w")
|
||||
-- if not saveFile then return false end
|
||||
|
||||
-- for k,v in pairs(values) do
|
||||
-- saveFile:write(k.."="..tostring(v).."\n")
|
||||
-- -- trigger.action.outText("SET value \""..k.."\" TO \""..tostring(v).."\"", 1)
|
||||
-- end
|
||||
-- saveFile:close()
|
||||
|
||||
-- return true
|
||||
-- end
|
||||
function DCSEx.io.save(fileName, str)
|
||||
-- IO table is sanitized, cannot read/write to disk
|
||||
if not DCSEx.io.canReadAndWrite() then return false end
|
||||
|
||||
local saveFile = io.open(fileName, "w")
|
||||
if not saveFile then return false end
|
||||
saveFile:write(str)
|
||||
saveFile:close()
|
||||
|
||||
return true
|
||||
end
|
||||
-------------------------------------
|
||||
-- Returns true if the IO table has been unsanitized (allowing IO operations) and false if it hasn't been
|
||||
-------------------------------------
|
||||
-- @return A boolean
|
||||
-------------------------------------
|
||||
function DCSEx.io.canReadAndWrite()
|
||||
return io ~= nil
|
||||
end
|
||||
|
||||
-------------------------------------
|
||||
-- Loads a string from a text file
|
||||
-------------------------------------
|
||||
-- @param fileName Name of the file to read
|
||||
-- @return A string, or nil if something went wrong
|
||||
-------------------------------------
|
||||
function DCSEx.io.load(fileName)
|
||||
-- IO table is sanitized, cannot read/write to disk
|
||||
if not DCSEx.io.canReadAndWrite() then return nil end
|
||||
|
||||
local saveFile = io.open(fileName, "r")
|
||||
if not saveFile then return nil end
|
||||
local str = saveFile:read("*all")
|
||||
saveFile:close()
|
||||
|
||||
return str
|
||||
end
|
||||
|
||||
-------------------------------------
|
||||
-- Writes a string to a text file
|
||||
-------------------------------------
|
||||
-- @param fileName Name of the file to write to. It will be overwritten if it exists.
|
||||
-- @param values Key/value table containing the values to save
|
||||
-- @param str String to write
|
||||
-- @return True if everything went right, false otherwise
|
||||
-------------------------------------
|
||||
function DCSEx.io.save(fileName, str)
|
||||
-- IO table is sanitized, cannot read/write to disk
|
||||
if not DCSEx.io.canReadAndWrite() then return false end
|
||||
|
||||
local saveFile = io.open(fileName, "w")
|
||||
if not saveFile then return false end
|
||||
saveFile:write(str)
|
||||
saveFile:close()
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
-- ====================================================================================
|
||||
-- (DCS LUA ADD-ON) MATH - EXTENSION TO THE "MATH" TABLE
|
||||
--
|
||||
-- DCSEX.MATH - MATH AND MATH-RELATED FUNCTIONS
|
||||
-- ====================================================================================
|
||||
-- (Constant) DCSEx.math.TWO_PI
|
||||
-- DCSEx.math.addVec(vecA, vecB)
|
||||
-- DCSEx.math.clamp(val, min, max)
|
||||
-- DCSEx.math.getBearing(point, refPoint, returnAsNESWstring)
|
||||
-- DCSEx.math.getDistance2D(vec2a, vec2b)
|
||||
-- DCSEx.math.getDistance3D(vec3a, vec3b)
|
||||
-- DCSEx.math.getRelativeHeading(point, refObject)
|
||||
-- DCSEx.math.getRelativeHeading(point, refObject, format)
|
||||
-- DCSEx.math.getVec2FromAngle(angle)
|
||||
-- DCSEx.math.isPointInsideCircle(center, radius, vec2)
|
||||
-- DCSEx.math.isPointInsidePolygon(polygon, vec2)
|
||||
@ -28,12 +28,13 @@
|
||||
DCSEx.math = {}
|
||||
|
||||
-------------------------------------
|
||||
-- Constants
|
||||
-- Two times Pi
|
||||
-------------------------------------
|
||||
DCSEx.math.TWO_PI = math.pi * 2
|
||||
|
||||
-------------------------------------
|
||||
-- Returns the sum of two vec2 or vec3
|
||||
-------------------------------------
|
||||
-- @param vecA A vector
|
||||
-- @param vecB Another vector
|
||||
-- @return The sum of both vectors
|
||||
@ -48,6 +49,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Clamp a number value between min and max
|
||||
-------------------------------------
|
||||
-- @param value The value to clamp
|
||||
-- @param min Minimum allowed value
|
||||
-- @param max Maximum allowed value
|
||||
@ -59,6 +61,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Gets the bearing between two vectors, in degrees
|
||||
-------------------------------------
|
||||
-- @param point A vec2/vec3
|
||||
-- @param refPoint Vec2/vec3 to use as a reference point
|
||||
-- @param returnAsNESWstring Should the value be returned as a N/S/E/W string instead of a numeric value
|
||||
@ -90,6 +93,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns the pythagorean distance between two 2D points or the length of a single vector
|
||||
-------------------------------------
|
||||
-- @param vec2a A 2D point
|
||||
-- @param vec2b (optional) Another 2D point
|
||||
-- @return Distance between the points
|
||||
@ -104,6 +108,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns the pythagorean distance between two 3D points or the length of a single vector
|
||||
-------------------------------------
|
||||
-- @param vec3a A 3D point
|
||||
-- @param vec3b (optional) Another 3D point
|
||||
-- @return Distance between the points
|
||||
@ -116,6 +121,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns the relative heading difference between refObject and a given point
|
||||
-------------------------------------
|
||||
-- @param point The point for which to check the relative heading
|
||||
-- @param refObject The reference object against which relative heading should be measured
|
||||
-- @param format (optional) Return format. Possible formats are "clock" (1 o'clock...) or "cardinal" (NNW...)
|
||||
@ -149,6 +155,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns an normalized vec2 from an angle/bearing in radians
|
||||
-------------------------------------
|
||||
-- @param unit Angle/bearing in radians
|
||||
-- @return A normalized vec2
|
||||
-------------------------------------
|
||||
@ -158,6 +165,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Is a point inside a circle?
|
||||
-------------------------------------
|
||||
-- @param center The center of the circle, as a vec2
|
||||
-- @param radius The radius of the circle
|
||||
-- @param vec2 A vec2
|
||||
@ -169,6 +177,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Is a point inside a polygon?
|
||||
-------------------------------------
|
||||
-- @param vec2[] A polygon, as a table of vec2
|
||||
-- @param vec2 A vec2
|
||||
-- @return True if vec2 is inside the polygon, false otherwise
|
||||
@ -195,6 +204,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Compares two 2D or 3D points
|
||||
-------------------------------------
|
||||
-- @param pointA a Point2 or Point3
|
||||
-- @param pointB another Point2 or Point3
|
||||
-- @return True if points are the same, false otherwise
|
||||
@ -210,7 +220,8 @@ function DCSEx.math.isSamePoint(pointA, pointB)
|
||||
end
|
||||
|
||||
-------------------------------------
|
||||
-- Linearly interpolates between two numbers
|
||||
-- Linearly interpolates two numbers
|
||||
-------------------------------------
|
||||
-- @param val0 Value vers l=0
|
||||
-- @param val1 Value vers l=1
|
||||
-- @param t Interpolation between 0 and 1
|
||||
@ -222,6 +233,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Multiplies both the x and y components of a vec2 by a floating-point value
|
||||
-------------------------------------
|
||||
-- @param vec2 A vec2
|
||||
-- @param mult A floating-point value
|
||||
-- @return A vec2
|
||||
@ -232,6 +244,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns an normalized vec2
|
||||
-------------------------------------
|
||||
-- @param unit A vec2
|
||||
-- @return A normalized vec2
|
||||
-------------------------------------
|
||||
@ -242,6 +255,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns a random boolean
|
||||
-------------------------------------
|
||||
-- @return A boolean
|
||||
-------------------------------------
|
||||
function DCSEx.math.randomBoolean()
|
||||
@ -250,20 +264,19 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns a random floating-point number between min and max
|
||||
-------------------------------------
|
||||
-- @param min Minimum floating-point value
|
||||
-- @param max Maximum floating-point value
|
||||
-- @return A number
|
||||
-------------------------------------
|
||||
function DCSEx.math.randomFloat(min, max)
|
||||
if min >= max then
|
||||
return min
|
||||
end
|
||||
|
||||
if min >= max then return min end
|
||||
return min + math.random() * (max - min)
|
||||
end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns a random vec2 at a given distance of another vec2
|
||||
-------------------------------------
|
||||
-- @param point Reference point
|
||||
-- @param distance Distance from the reference point
|
||||
-- @return A vec2
|
||||
@ -278,6 +291,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns a random vec2 in circle of a given center and radius
|
||||
-------------------------------------
|
||||
-- @param center Center of the circle as a vec2
|
||||
-- @param radius Radius of the circle
|
||||
-- @param minRadius (optional) Minimum inner radius circle in which points should not be spawned
|
||||
@ -306,6 +320,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns a random sign as a number, -1 or 1
|
||||
-------------------------------------
|
||||
-- @return -1 50% of the time, 1 50% of the time
|
||||
-------------------------------------
|
||||
function DCSEx.math.randomSign()
|
||||
@ -317,6 +332,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Converts a value to a boolean
|
||||
-------------------------------------
|
||||
-- @param val Value to convert
|
||||
-- @return A boolean, or nil if val was nil
|
||||
-------------------------------------
|
||||
@ -331,6 +347,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Converts a vec2 to a vec3
|
||||
-------------------------------------
|
||||
-- @param vec2 A vec2
|
||||
-- @param y (Optional) A value for the vec3's y component or "land" to use land height
|
||||
-- @return A vec3 where v3.x=v2.x, v3.y=y and v3.z=v2.y
|
||||
@ -349,6 +366,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Converts a vec3 to a vec2
|
||||
-------------------------------------
|
||||
-- @param vec3 A vec3
|
||||
-- @return A vec2 where v2.x=v3.x and v2.y=v3.z
|
||||
-------------------------------------
|
||||
|
||||
@ -1,8 +1,12 @@
|
||||
-- ====================================================================================
|
||||
-- (DCS LUA ADD-ON) STRING - EXTENSION TO THE "STRING" TABLE
|
||||
--
|
||||
-- DCSEX.STRING - FUNCTIONS RELATED TO STRING MANIPULATION
|
||||
-- ====================================================================================
|
||||
-- DCSEx.string.firstToUpper(str)
|
||||
-- DCSEx.string.getReadingTime(message)
|
||||
-- DCSEx.string.join(table, separator)
|
||||
-- DCSEx.string.getTimeString(timeInSeconds, separator)
|
||||
-- DCSEx.string.toStringNumber(number, firstToUpper)
|
||||
-- DCSEx.string.toStringThousandsSeparator(number)
|
||||
-- DCSEx.string.split(str, separator)
|
||||
-- DCSEx.string.startsWith(haystack, needle)
|
||||
-- DCSEx.string.trim(str)
|
||||
@ -12,6 +16,7 @@ DCSEx.string = {}
|
||||
|
||||
-------------------------------------
|
||||
-- Uppercases the fist letter of a string
|
||||
-------------------------------------
|
||||
-- @param str A string
|
||||
-- @return A string, with the first letter cast to upper case
|
||||
-------------------------------------
|
||||
@ -21,6 +26,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Estimates the time (in seconds) required to read a string
|
||||
-------------------------------------
|
||||
-- @param message A text message
|
||||
-- @return A duration in seconds
|
||||
-------------------------------------
|
||||
@ -31,7 +37,13 @@ function DCSEx.string.getReadingTime(message)
|
||||
return DCSEx.math.clamp(#message / 8.7, 3.0, 15.0) -- 10.7 letters per second, minimum length 3 seconds, max length 15 seconds
|
||||
end
|
||||
|
||||
-- TODO: description, update file header
|
||||
-------------------------------------
|
||||
-- Joins a table of string into a single string
|
||||
-------------------------------------
|
||||
-- @param table A table of strings
|
||||
-- @param separator Separator used to glue table entries (default: "")
|
||||
-- @return A string
|
||||
-------------------------------------
|
||||
function DCSEx.string.join(table, separator)
|
||||
local joinedString = ""
|
||||
|
||||
@ -45,10 +57,16 @@ function DCSEx.string.join(table, separator)
|
||||
return joinedString
|
||||
end
|
||||
|
||||
-- TODO: description, file header
|
||||
function DCSEx.string.getTimeString(timeInSeconds, useColon)
|
||||
-------------------------------------
|
||||
-- Converts a time of day (in seconds since midnight) to a human-readable time string
|
||||
-------------------------------------
|
||||
-- @param timeInSeconds Number of seconds since midnight (default: current time)
|
||||
-- @param separator Separator between minutes and seconds (":", "h"...) (default: "")
|
||||
-- @return The time, as as string
|
||||
-------------------------------------
|
||||
function DCSEx.string.getTimeString(timeInSeconds, separator)
|
||||
timeInSeconds = timeInSeconds or timer.getAbsTime()
|
||||
useColon = useColon or false
|
||||
separator = separator or ""
|
||||
|
||||
timeInSeconds = math.max(0, timeInSeconds) % 86400
|
||||
|
||||
@ -61,13 +79,15 @@ function DCSEx.string.getTimeString(timeInSeconds, useColon)
|
||||
local minutesStr = tostring(minutes)
|
||||
if #minutesStr == 1 then minutesStr = "0"..minutesStr end
|
||||
|
||||
local separator = ""
|
||||
if useColon then separator = ":" end
|
||||
|
||||
return hoursStr..separator..minutesStr
|
||||
end
|
||||
|
||||
-- TODO: description, file header
|
||||
-------------------------------------
|
||||
-- Converts a numeric value between 0 and 20 into its word/string representation
|
||||
-------------------------------------
|
||||
-- @param number A number (>=0, <=20)
|
||||
-- @return A string
|
||||
-------------------------------------
|
||||
function DCSEx.string.toStringNumber(number, firstToUpper)
|
||||
firstToUpper = firstToUpper or false
|
||||
local NUMBERS = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen", "twenty" }
|
||||
@ -81,8 +101,13 @@ function DCSEx.string.toStringNumber(number, firstToUpper)
|
||||
return DCSEx.string.toStringThousandsSeparator(number)
|
||||
end
|
||||
|
||||
-- TODO: description, file header
|
||||
-- Code from https://stackoverflow.com/questions/10989788/format-integer-in-lua
|
||||
-------------------------------------
|
||||
-- Converts a numeric value to a string, with proper thousands separators
|
||||
-- (Code taken from https://stackoverflow.com/questions/10989788/format-integer-in-lua)
|
||||
-------------------------------------
|
||||
-- @param number A number
|
||||
-- @return A string
|
||||
-------------------------------------
|
||||
function DCSEx.string.toStringThousandsSeparator(number)
|
||||
local i, j, minus, int, fraction = tostring(number):find('([-]?)(%d+)([.]?%d*)')
|
||||
int = int:reverse():gsub("(%d%d%d)", "%1,")
|
||||
@ -90,7 +115,8 @@ function DCSEx.string.toStringThousandsSeparator(number)
|
||||
end
|
||||
|
||||
-------------------------------------
|
||||
-- Splits a string
|
||||
-- Splits a string into a table
|
||||
-------------------------------------
|
||||
-- @param str The string to split
|
||||
-- @param separator The string to split
|
||||
-- @return A table of split strings
|
||||
@ -105,6 +131,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Does a string starts with the given substring?
|
||||
-------------------------------------
|
||||
-- @param haystack The string
|
||||
-- @param needle The substring to look for
|
||||
-- @return True if it starts with the substring, false otherwise
|
||||
@ -115,6 +142,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Trims a string
|
||||
-------------------------------------
|
||||
-- @param str A string
|
||||
-- @return A string
|
||||
-------------------------------------
|
||||
|
||||
@ -1,15 +1,17 @@
|
||||
-- ====================================================================================
|
||||
-- (DCS LUA ADD-ON) TABLE - EXTENSION TO THE "TABLE" TABLE
|
||||
--
|
||||
-- DCSEX.TABLE - FUNCTIONS RELATED TO TABLE MANIPULATION
|
||||
-- ====================================================================================
|
||||
-- DCSEx.table.contains(t, val)
|
||||
-- DCSEx.table.containsKey(t, k)
|
||||
-- DCSEx.table.containsAll(t, values)
|
||||
-- DCSEx.table.containsAny(t, values)
|
||||
-- DCSEx.table.containsAllKeys(t, keys)
|
||||
-- DCSEx.table.containsAnyKeys(t, keys)
|
||||
-- DCSEx.table.countNonNils(t)
|
||||
-- DCSEx.table.deepCopy(orig)
|
||||
-- DCSEx.table.dump(t)
|
||||
-- DCSEx.table.getKeys(t)
|
||||
-- DCSEx.table.getKeyFromValue(t, val)
|
||||
-- DCSEx.table.getKeys(t)
|
||||
-- DCSEx.table.getRandom(t)
|
||||
-- DCSEx.table.getRandomIndex(t)
|
||||
-- DCSEx.table.shuffle(t)
|
||||
@ -19,6 +21,7 @@ DCSEx.table = {}
|
||||
|
||||
-------------------------------------
|
||||
-- Returns true if table t contains value val
|
||||
-------------------------------------
|
||||
-- @param t A table
|
||||
-- @param val A value
|
||||
-- @return True if the table contains the value, false otherwise
|
||||
@ -35,6 +38,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns true if table t contains key k
|
||||
-------------------------------------
|
||||
-- @param t A table
|
||||
-- @param k A key
|
||||
-- @return True if the table contains the key, false otherwise
|
||||
@ -47,10 +51,11 @@ function DCSEx.table.containsKey(t, k)
|
||||
end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns true if table t contains all values in table values
|
||||
-- Returns true if table t contains ALL values from the "values" table
|
||||
-------------------------------------
|
||||
-- @param t A table
|
||||
-- @param values A table of values
|
||||
-- @return True if the table contains all values, false otherwise
|
||||
-- @return True if the table contains ALL values, false otherwise
|
||||
-------------------------------------
|
||||
function DCSEx.table.containsAll(t, values)
|
||||
if not t then return false end
|
||||
@ -65,10 +70,11 @@ function DCSEx.table.containsAll(t, values)
|
||||
end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns true if table t contains at least one value in table values
|
||||
-- Returns true if table t contains AT LEAST ONE value from the "values" table
|
||||
-------------------------------------
|
||||
-- @param t A table
|
||||
-- @param values A table of values
|
||||
-- @return True if the table contains at least one value, false otherwise
|
||||
-- @return True if the table contains AT LEAST ONE value, false otherwise
|
||||
-------------------------------------
|
||||
function DCSEx.table.containsAny(t, values)
|
||||
if not t then return false end
|
||||
@ -82,6 +88,13 @@ function DCSEx.table.containsAny(t, values)
|
||||
return false
|
||||
end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns true if table t contains ALL keys from the "keys" table
|
||||
-------------------------------------
|
||||
-- @param t A table
|
||||
-- @param keys A table of keys
|
||||
-- @return True if the table contains ALL keys, false otherwise
|
||||
-------------------------------------
|
||||
function DCSEx.table.containsAllKeys(t, keys)
|
||||
if not t then return false end
|
||||
|
||||
@ -94,6 +107,13 @@ function DCSEx.table.containsAllKeys(t, keys)
|
||||
return true
|
||||
end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns true if table t contains AT LEAST ONE key from the "keys" table
|
||||
-------------------------------------
|
||||
-- @param t A table
|
||||
-- @param values A table of keys
|
||||
-- @return True if the table contains AT LEAST ONE key, false otherwise
|
||||
-------------------------------------
|
||||
function DCSEx.table.containsAnyKeys(t, keys)
|
||||
if not t then return false end
|
||||
|
||||
@ -108,6 +128,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns the number of non-nils elements in a table
|
||||
-------------------------------------
|
||||
-- @param t A table
|
||||
-- @return A number
|
||||
-------------------------------------
|
||||
@ -122,6 +143,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns a deep copy of the table, doesn't work with recursive tables (code from http://lua-users.org/wiki/CopyTable)
|
||||
-------------------------------------
|
||||
-- @param orig A table
|
||||
-- @return A deep copied clone of the table
|
||||
-------------------------------------
|
||||
@ -142,6 +164,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Dumps the content of a table as a string
|
||||
-------------------------------------
|
||||
-- @param orig A table
|
||||
-- @return A string representaton of the table
|
||||
-------------------------------------
|
||||
@ -160,6 +183,7 @@ function DCSEx.table.dump(t)
|
||||
|
||||
-------------------------------------
|
||||
-- Returns the key associated to a value in a table, or nil if not found
|
||||
-------------------------------------
|
||||
-- @param t A table
|
||||
-- @param val A value
|
||||
-- @return The key associated to this value in the table, or nil
|
||||
@ -173,6 +197,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns all the keys in an associative table
|
||||
-------------------------------------
|
||||
-- @param t A table
|
||||
-- @return An array of keys
|
||||
-------------------------------------
|
||||
@ -191,6 +216,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns a random value from a numerically-indexed table
|
||||
-------------------------------------
|
||||
-- @param t A table
|
||||
-- @return A random element from the table
|
||||
-------------------------------------
|
||||
@ -200,6 +226,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns a random index from a numerically-indexed table
|
||||
-------------------------------------
|
||||
-- @param t A table
|
||||
-- @return A random index from the table
|
||||
-------------------------------------
|
||||
@ -209,6 +236,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Randomly shuffles a numerically-indexed table
|
||||
-------------------------------------
|
||||
-- @param t A table
|
||||
-- @return A table with shuffled values
|
||||
-------------------------------------
|
||||
|
||||
@ -1,3 +1,7 @@
|
||||
-- ====================================================================================
|
||||
-- DCSEX.UNITCALLSIGNMAKER - GENERATES CALLSIGNS FOR NEW UNITS
|
||||
-- ====================================================================================
|
||||
|
||||
DCSEx.unitCallsignMaker = {}
|
||||
|
||||
do
|
||||
|
||||
@ -1,16 +1,18 @@
|
||||
-- ====================================================================================
|
||||
-- DCSEX.UNITGROUMAKER - CREATES AND ADDS GROUPS TO THE GAME WORLD
|
||||
--
|
||||
-- DCSEX.UNITGROUPMAKER - CREATES AND ADDS GROUPS TO THE GAME WORLD
|
||||
-- ====================================================================================
|
||||
-- (local) createGroupTable(groupID, groupCategory, options)
|
||||
-- (local) getDefaultUnitSpread(groupCategory)
|
||||
-- (local) getNextGroupID()
|
||||
-- (local) getNextUnitID()
|
||||
-- (local) setAircraftTaskAwacs(groupTable)
|
||||
-- (local) setAircraftTaskCAP(groupTable)
|
||||
-- (local) setAircraftTaskFollow(groupTable, followedGroupID, xyDistance)
|
||||
-- (local) setAircraftTaskOrbit(groupTable, options)
|
||||
-- (local) setCommand(groupTable, actionID, actionValue)
|
||||
-- (local) setOption(groupTable, optionID, optionValue)
|
||||
-- DCSEx.unitGroupMaker.createStatic(side, point2, typeName, shapeName, heading, dead)
|
||||
-- DCSEx.unitGroupMaker.create(coalitionID, groupCategory, vec2, unitTypes, options)
|
||||
-- DCSEx.unitGroupMaker.initialize()
|
||||
-- ====================================================================================
|
||||
|
||||
DCSEx.unitGroupMaker = {}
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
-- ====================================================================================
|
||||
-- DCSEX.UNITNAMESMAKER - GENERATE CREDIBLE AND UNIT NAMES FOR UNIT GROUPS
|
||||
-- ====================================================================================
|
||||
DCSEx.unitNamesMaker = {}
|
||||
|
||||
do
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
-- ====================================================================================
|
||||
-- WORLDTOOLS - FUNCTIONS RELATED TO THE GAME WORLD
|
||||
-- DCSEX.WORLD - FUNCTIONS RELATED TO THE GAME WORLD
|
||||
-- ====================================================================================
|
||||
-- DCSEx.world.collidesWithScenery(vec2, radius)
|
||||
-- DCSEx.world.findSpawnPoint(vec2, minRadius, maxRadius, surfaceType, radiusWithoutScenery)
|
||||
|
||||
@ -1,24 +1,34 @@
|
||||
-- ====================================================================================
|
||||
-- ZONETOOLS - FUNCTIONS RELATED TO MAP TRIGGER ZONES
|
||||
-- DCSEX.ZONES - FUNCTIONS RELATED TO MAP TRIGGER ZONES
|
||||
-- ====================================================================================
|
||||
-- DCSEx.zones.drawOnMap(zoneTable, lineColor, fillColor, lineType, drawName, readonly)
|
||||
-- DCSEx.zones.drawOnMap(zoneTable, lineColor, fillColor, lineType, drawName, readOnly)
|
||||
-- DCSEx.zones.getAll()
|
||||
-- DCSEx.zones.getByName(name)
|
||||
-- DCSEx.zones.getCenter(zoneTable)
|
||||
-- DCSEx.zones.getProperty(zoneTable, propertyName)
|
||||
-- DCSEx.zones.getProperty(zoneTable, propertyName, defaultValue)
|
||||
-- DCSEx.zones.getPropertyBoolean(zoneTable, propertyName, defaultValue)
|
||||
-- DCSEx.zones.getPropertyFloat(zoneTable, propertyName, defaultValue, min, max)
|
||||
-- DCSEx.zones.getPropertyInt(zoneTable, propertyName, defaultValue, min, max)
|
||||
-- DCSEx.zones.getPropertyParse(zoneTable, propertyName, stringTable, valueTable, defaultValue)
|
||||
-- DCSEx.zones.getPropertyTable(zoneTable, propertyName)
|
||||
-- DCSEx.zones.getRadius(zoneTable, useMaxForQuads)
|
||||
-- DCSEx.zones.getRandomPointInside(zoneTable, surfaceType)
|
||||
-- DCSEx.zones.getSurfaceArea(zoneTable)
|
||||
-- DCSEx.zones.isPointInside(zoneTable, point)
|
||||
-- ====================================================================================
|
||||
|
||||
DCSEx.zones = { }
|
||||
|
||||
-- TODO: function description
|
||||
-------------------------------------
|
||||
-- Draws a zone on the F10, visible for all players
|
||||
-------------------------------------
|
||||
-- @param zoneTable The zone to draw
|
||||
-- @param lineColor Line color as a RGBA table
|
||||
-- @param fillColor Fill color as a RGBA table
|
||||
-- @param lineType Type of line from the DCSEx.enums.lineType enum
|
||||
-- @param drawName Should the name of the zone be drawn too (default: false)
|
||||
-- @param drawName Should the zone marker be read only? (default: true)
|
||||
-------------------------------------
|
||||
function DCSEx.zones.drawOnMap(zoneTable, lineColor, fillColor, lineType, drawName, readOnly)
|
||||
drawName = drawName or false
|
||||
readOnly = readOnly or true
|
||||
@ -64,6 +74,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns all trigger zones
|
||||
-------------------------------------
|
||||
-- @return Table of zones
|
||||
-------------------------------------
|
||||
function DCSEx.zones.getAll()
|
||||
@ -79,6 +90,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Finds and return a trigger zone by a certain name
|
||||
-------------------------------------
|
||||
-- @param name Case-insensitive name of the zone
|
||||
-- @return Zone table or nil if no zone with this name was found
|
||||
-------------------------------------
|
||||
@ -100,6 +112,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns the center of a zone
|
||||
-------------------------------------
|
||||
-- @param zoneTable The zone table, returned by TMMissionData.getZones() or TMMissionData.getZoneByName(name)
|
||||
-- @return A vec2
|
||||
-------------------------------------
|
||||
@ -119,6 +132,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns the value of the property of a trigger zone, as a string
|
||||
-------------------------------------
|
||||
-- @param zoneTable The zone table, returned by DCSEx.zones.getAll() or DCSEx.zones.getByName(name)
|
||||
-- @param propertyName Case-insensitive name of the property
|
||||
-- @return The value of the property or nil if it doesn't exist
|
||||
@ -141,6 +155,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns the value of the property of a trigger zone, parsed against a case-insensitive table of strings
|
||||
-------------------------------------
|
||||
-- @param zoneTable The zone table, returned by DCSEx.zones.getAll() or DCSEx.zones.getByName(name)
|
||||
-- @param propertyName Case-insensitive name of the property
|
||||
-- @param defaultValue Default value to return if no match was found
|
||||
@ -157,6 +172,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns the value of the property of a trigger zone, as a float
|
||||
-------------------------------------
|
||||
-- @param zoneTable The zone table, returned by DCSEx.zones.getAll() or DCSEx.zones.getByName(name)
|
||||
-- @param propertyName Case-insensitive name of the property
|
||||
-- @param defaultValue Default value to return if no match was found
|
||||
@ -174,6 +190,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns the value of the property of a trigger zone, as an integer
|
||||
-------------------------------------
|
||||
-- @param zoneTable The zone table, returned by DCSEx.zones.getAll() or DCSEx.zones.getByName(name)
|
||||
-- @param propertyName Case-insensitive name of the property
|
||||
-- @param defaultValue Default value to return if no match was found
|
||||
@ -189,6 +206,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Gets the value of a property of a trigger zone and parse it according to two correspondance tables
|
||||
-------------------------------------
|
||||
-- @param zoneTable The zone table, returned by DCSEx.zones.getAll() or DCSEx.zones.getByName(name)
|
||||
-- @param propertyName Case-insensitive name of the property
|
||||
-- @param stringTable A table of strings
|
||||
@ -211,6 +229,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns the value of the property of a trigger zone, as a table of comma-separated lowercase strings
|
||||
-------------------------------------
|
||||
-- @param zoneTable The zone table, returned by DCSEx.zones.getAll() or DCSEx.zones.getByName(name)
|
||||
-- @param propertyName Case-insensitive name of the property
|
||||
-- @return An table
|
||||
@ -223,6 +242,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns the radius of a zone, in meter
|
||||
-------------------------------------
|
||||
-- @param zoneTable The zone table, returned by DCSEx.zones.getAll() or DCSEx.zones.getByName(name)
|
||||
-- @param useMaxForQuads If true, return largest distance between the center and a vertex. If false (default value), returns the mean distance. Only used if the zone is a quad.
|
||||
-- @return An table
|
||||
@ -271,6 +291,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns the surface area of a zone
|
||||
-------------------------------------
|
||||
-- @param zoneTable The zone table, returned by TMMissionData.getZones() or TMMissionData.getZoneByName(name)
|
||||
-- @return A number, in squared meters
|
||||
-------------------------------------
|
||||
@ -289,6 +310,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns true if a point is inside a zone
|
||||
-------------------------------------
|
||||
-- @param zoneTable The zone table, returned by TMMissionData.getZones() or TMMissionData.getZoneByName(name)
|
||||
-- @param point A point, as a vec3 or vec2
|
||||
-- @return True if the point is inside the zone, false otherwise
|
||||
|
||||
@ -132,7 +132,7 @@ do
|
||||
groupInfo.unitsID = { DCSEx.unitGroupMaker.createStatic(TUM.settings.getEnemyCoalition(), objective.point2, units[1], "") }
|
||||
end
|
||||
else
|
||||
groupInfo = DCSEx.unitGroupMaker.create(TUM.settings.getEnemyCoalition(), DCSEx.dcs.getUnitTypeFromFamily(objectiveDB.targetFamilies[1]), objective.point2, units, groupOptions)
|
||||
groupInfo = DCSEx.unitGroupMaker.create(TUM.settings.getEnemyCoalition(), DCSEx.dcs.getUnitCategoryFromFamily(objectiveDB.targetFamilies[1]), objective.point2, units, groupOptions)
|
||||
end
|
||||
|
||||
if not groupInfo then
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user