mirror of
https://github.com/omltcat/dcs-lua-definitions.git
synced 2025-11-10 15:48:52 +00:00
Initial commit
This commit is contained in:
commit
89e8f40db9
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.vscode/
|
||||
44
README.md
Normal file
44
README.md
Normal file
@ -0,0 +1,44 @@
|
||||
# DCS World Lua Definitions
|
||||
This is a [definition addon](https://luals.github.io/wiki/definition-files/) for [VS Code Lua extension](https://marketplace.visualstudio.com/items?itemName=sumneko.lua). It provides types, classes, functions and enumerators from DCS World Scripting Engine, to help with code completion and prevent errors.
|
||||
|
||||
|
||||
```lua
|
||||
-- For example
|
||||
-- VS Code will now know this is a Unit object
|
||||
local tomcat = Unit.getByName("Colt 1-1")
|
||||
|
||||
-- And it will yell at you if you try to do this
|
||||
tomcat:getSize()
|
||||
-- Because getSize is a function for the Group class, not Unit
|
||||
```
|
||||
|
||||
## Credits
|
||||
These definitions are pulled from Hoggit Wiki [Simulator Scripting Engine Documentation](https://wiki.hoggitworld.com/view/Simulator_Scripting_Engine_Documentation) and permission was granted by Grimes before sharing or this repo. I take no credit for the content. I simply converted it to a format for Lua extension and did some structuring and cleaning.
|
||||
|
||||
## Current State
|
||||
At this point, *most* of the mission scripting environment definitions are in place. As I started with the most commonly used ones, some may still be missing. If you find any missing or incorrect definitions, you are welcome to open an issue or a pull request.
|
||||
|
||||
Other environments, like hooks and export are mostly uncharted territory. I will be working on when mission is complete. Naturally, I would appreciate any help at the mean time as I am not very familiar with them.
|
||||
|
||||
When this project is more complete, I will PR it to [LLS-Addons](https://github.com/LuaLS/LLS-Addons) so that it can be installed directly from the Lua extension's Addon Manager.
|
||||
|
||||
## Installation (for now)
|
||||
Install the [Lua extension](https://marketplace.visualstudio.com/items?itemName=sumneko.lua) for VS Code.
|
||||
|
||||
Create a folder somewhere to store all the Lua addons and clone this repo.
|
||||
```sh
|
||||
mkdir lua-addons
|
||||
cd lua-addons
|
||||
git clone https://github.com/omltcat/dcs-lua-definitions.git
|
||||
```
|
||||
|
||||
Then add it to VS Code settings:
|
||||
```json
|
||||
"Lua.workspace.userThirdParty": [
|
||||
"/path/to/lua-addons"
|
||||
]
|
||||
```
|
||||
|
||||
## Recommended Extensions
|
||||
- [DCS Lua Runner](https://marketplace.visualstudio.com/items?itemName=omltcat.dcs-lua-runner)
|
||||
- Made by me. Execute Lua code in running DCS missions straight from VS Code.
|
||||
21
config.json
Normal file
21
config.json
Normal file
@ -0,0 +1,21 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/LuaLS/LLS-Addons/main/schemas/addon_config.schema.json",
|
||||
"name": "DCS World",
|
||||
"words": [
|
||||
"Unit%.getByName",
|
||||
"Group%.getByName",
|
||||
"trigger%.action%."
|
||||
],
|
||||
"files": [
|
||||
"mist_.+%.lua",
|
||||
".+%.miz"
|
||||
],
|
||||
"settings": {
|
||||
"Lua.diagnostics.globals" : [
|
||||
"lfs",
|
||||
"io",
|
||||
"os",
|
||||
"mist"
|
||||
]
|
||||
}
|
||||
}
|
||||
11
library/export/always.lua
Normal file
11
library/export/always.lua
Normal file
@ -0,0 +1,11 @@
|
||||
---@meta
|
||||
|
||||
function LoGetPilotName() end
|
||||
function LoGetAltitude() end
|
||||
function LoGetNameByType() end
|
||||
function LoGeoCoordinatesToLoCoordinates() end
|
||||
function LoCoordinatesToGeoCoordinates() end
|
||||
function LoGetVersionInfo() end
|
||||
function LoGetWindAtPoint() end
|
||||
function LoGetModelTime() end
|
||||
function LoGetMissionStartTime() end
|
||||
4
library/export/object.lua
Normal file
4
library/export/object.lua
Normal file
@ -0,0 +1,4 @@
|
||||
---@meta
|
||||
|
||||
function LoGetObjectById() end
|
||||
function LoGetWorldObjects() end
|
||||
38
library/export/ownship.lua
Normal file
38
library/export/ownship.lua
Normal file
@ -0,0 +1,38 @@
|
||||
---@meta
|
||||
|
||||
function LoGetPlayerPlaneId() end
|
||||
function LoGetIndicatedAirSpeed() end
|
||||
function LoGetAngleOfAttack() end
|
||||
function LoGetAngleOfSideSlip() end
|
||||
function LoGetAccelerationUnits() end
|
||||
function LoGetVerticalVelocity() end
|
||||
function LoGetADIPitchBankYaw() end
|
||||
function LoGetTrueAirSpeed() end
|
||||
function LoGetAltitudeAboveSeaLevel() end
|
||||
function LoGetAltitudeAboveGroundLevel() end
|
||||
function LoGetMachNumber() end
|
||||
function LoGetRadarAltimeter() end
|
||||
function LoGetMagneticYaw() end
|
||||
function LoGetGlideDeviation() end
|
||||
function LoGetSideDeviation() end
|
||||
function LoGetSlipBallPosition() end
|
||||
function LoGetBasicAtmospherePressure() end
|
||||
function LoGetControlPanel_HSI() end
|
||||
function LoGetEngineInfo() end
|
||||
function LoGetSelfData() end
|
||||
function LoGetCameraPosition() end
|
||||
function LoSetCameraPosition() end
|
||||
function LoSetCommand() end
|
||||
function LoGetMCPState() end
|
||||
function LoGetRoute() end
|
||||
function LoGetNavigationInfo() end
|
||||
function LoGetPayloadInfo() end
|
||||
function LoGetWingInfo() end
|
||||
function LoGetMechInfo() end
|
||||
function LoGetRadioBeaconsStatus() end
|
||||
function LoGetVectorVelocity() end
|
||||
function LoGetVectorWindVelocity() end
|
||||
function LoGetSnares() end
|
||||
function LoGetAngularVelocity() end
|
||||
function LoGetHeightWithObjects() end
|
||||
function LoGetFMData() end
|
||||
8
library/export/sensor.lua
Normal file
8
library/export/sensor.lua
Normal file
@ -0,0 +1,8 @@
|
||||
---@meta
|
||||
|
||||
function LoGetTWSInfo() end
|
||||
function LoGetTargetInformation() end
|
||||
function LoGetLockedTargetInformation() end
|
||||
function LoGetF15_TWS_Contacts() end
|
||||
function LoGetSightingSystemInfo() end
|
||||
function LoGetWingTargets() end
|
||||
65
library/mission/coalition.lua
Normal file
65
library/mission/coalition.lua
Normal file
@ -0,0 +1,65 @@
|
||||
---@meta
|
||||
|
||||
---@class coalition
|
||||
coalition = {}
|
||||
---@enum coalition.side
|
||||
coalition.side = {
|
||||
NEUTRAL = 0,
|
||||
BLUE = 2,
|
||||
RED = 1
|
||||
}
|
||||
|
||||
---@enum coalition.service
|
||||
coalition.service = {
|
||||
AWACS = 1,
|
||||
FAC = 3,
|
||||
ATC = 0,
|
||||
MAX = 4,
|
||||
TANKER = 2
|
||||
}
|
||||
|
||||
|
||||
---Dynamically spawns a group of the specified category for the specified country. <br>
|
||||
---Group data table is in the same format as created by the mission editor.<br>
|
||||
---See country page and group class page for the list of countries by id and group categories.<br>
|
||||
---The coalition of the group is defined by the coalition its country belongs to.<br>
|
||||
---If the group or any unit within shares a name of an existing group or unit, the existing group or unit will be destroyed when the new group is created.<br>
|
||||
---Function can NOT spawn new aircraft with a skill level of "client". However in single player a group can be spawned with the skill level of "Player". When this occurs the existing player aircraft will be destroyed.<br>
|
||||
---If no groupId or unitId is specified or the Ids are shared with existing groups or units, a new Id will be created for the new group.
|
||||
---@param countryId country.id -- The id of the country.
|
||||
---@param groupCategory Group.Category -- The category of the group.
|
||||
---@param groupData table -- The data of the group.
|
||||
---@return Group -- The newly created group.
|
||||
function coalition.addGroup(countryId, groupCategory, groupData) end
|
||||
|
||||
---Dynamically spawns a static object belonging to the specified country into the mission. <br>
|
||||
---This function follows the same rules as coalition.addGroup except for the object table not perfectly matching the format of a static object as seen in the mission file.<br>
|
||||
---Static Objects name cannot be shared with an existing object, if it is the existing object will be destroyed on the spawning of the new object.<br>
|
||||
---If unitId is not specified or matches an existing object, a new Id will be generated.<br>
|
||||
---Coalition of the object is defined based on the country the object is spawning to.<br>
|
||||
---@param countryId country.id -- The id of the country.
|
||||
---@param groupData table -- The data of the group.
|
||||
---@return StaticObject -- The newly created static object.
|
||||
function coalition.addStaticObject(countryId, groupData) end
|
||||
|
||||
---Returns a table of unit objects that are currently occupied by players. Function is useful in multiplayer to easily filter client aircraft from everything else.
|
||||
---@param coalitionId coalition.side -- The id of the coalition.
|
||||
---@return Unit[] -- A table of unit objects that are currently occupied by players.
|
||||
function coalition.getPlayers(coalitionId) end
|
||||
|
||||
---Returns the enumerator coalitionId that a specified country belongs to.
|
||||
---@param countryId country.id -- The id of the country.
|
||||
---@return coalition.side -- The coalitionId that the specified country belongs to.
|
||||
function coalition.getCountryCoalition(countryId) end
|
||||
|
||||
---Returns a table of group objects belonging to the specified coalition. <br>
|
||||
---If the groupCategory enumerator is provided the table will only contain groups that belong to the specified category. If this optional variable is not provided, all group types will be returned.
|
||||
---@param coalitionId coalition.side -- The id of the coalition.
|
||||
---@param groupCategory Group.Category? -- Optional. The category of the group.
|
||||
---@return Group[] -- A table of group objects.
|
||||
function coalition.getGroups(coalitionId, groupCategory) end
|
||||
|
||||
---Returns a table of static objects (StaticObject[]) belonging to the specified coalition.
|
||||
---@param coalitionId coalition.side -- The id of the coalition.
|
||||
---@return StaticObject[] -- A table of static objects.
|
||||
function coalition.getStaticObjects(coalitionId) end
|
||||
45
library/mission/controller.lua
Normal file
45
library/mission/controller.lua
Normal file
@ -0,0 +1,45 @@
|
||||
---@meta
|
||||
|
||||
---@class Controller
|
||||
Controller = {}
|
||||
Controller.Detection = {
|
||||
VISUAL = 1,
|
||||
OPTIC = 2,
|
||||
RADAR = 4,
|
||||
IRST = 8,
|
||||
RWR = 16,
|
||||
DLINK = 32
|
||||
}
|
||||
|
||||
---Pushes the specified task to the front of the tasking queue. If no other tasks are currently active it will function effectively the same as `Controller.setTask()`.<br>
|
||||
---[Available Tasks](https://wiki.hoggitworld.com/view/DCS_func_pushTask)
|
||||
---@param task table -- The task to be pushed to the front of the queue.
|
||||
function Controller:pushTask(task) end
|
||||
|
||||
---Removes the top task from the tasking queue.<br>
|
||||
function Controller:popTask() end
|
||||
|
||||
---Resets the current task assigned to the controller.
|
||||
function Controller:resetTask() end
|
||||
|
||||
---Commands are instant actions that require zero time to perform. <br>
|
||||
---Commands may be used both for control unit/group behavior and control game mechanics. Setting a command will have no impact on active tasking.
|
||||
---[Available Commands](https://wiki.hoggitworld.com/view/DCS_func_command)
|
||||
---@param command table -- The command to be set.
|
||||
function Controller:setCommand(command) end
|
||||
|
||||
---Sets the controlled group to go the specified speed in meters per second.<br>
|
||||
---Optional boolean `keep` when set to true will maintain that speed on passing waypoints.<br>
|
||||
---If `keep` is not present or false, the controlled group will return to the speed as defined by their route.<br>
|
||||
---The following will set the tanker to fly slower at a speed an A-10 can achieve:<br>
|
||||
---```
|
||||
---Group.getByName("KC-135"):getController():setSpeed(125)
|
||||
---```
|
||||
---@param speed number -- The speed in meters per second.
|
||||
---@param keep boolean? -- Optional. If true, maintains the speed on passing waypoints.
|
||||
function Controller:setSpeed(speed, keep) end
|
||||
|
||||
---Sets the specified task to the units or groups associated with the controller object. Tasks must fit a specified format. <br>
|
||||
---[Available Tasks](https://wiki.hoggitworld.com/view/DCS_func_setTask)
|
||||
---@param task table -- The task to be set.
|
||||
function Controller:setTask(task) end
|
||||
193
library/mission/country.lua
Normal file
193
library/mission/country.lua
Normal file
@ -0,0 +1,193 @@
|
||||
---@meta
|
||||
|
||||
---@class country
|
||||
country = {}
|
||||
|
||||
---@enum country.id
|
||||
country.id = {
|
||||
["ITALIAN_SOCIAL_REPUBLIC"] = 69,
|
||||
["USSR"] = 68,
|
||||
["CJTF_BLUE"] = 80,
|
||||
["YEMEN"] = 48,
|
||||
["SOUTH_OSETIA"] = 19,
|
||||
["BOLIVIA"] = 86,
|
||||
["MOROCCO"] = 55,
|
||||
["ETHIOPIA"] = 62,
|
||||
["NORTH_KOREA"] = 38,
|
||||
["IRAQ"] = 35,
|
||||
["CJTF_RED"] = 81,
|
||||
["ITALY"] = 20,
|
||||
["SPAIN"] = 9,
|
||||
["SERBIA"] = 43,
|
||||
["MALAYSIA"] = 57,
|
||||
["SAUDI_ARABIA"] = 42,
|
||||
["NORWAY"] = 12,
|
||||
["ARGENTINA"] = 83,
|
||||
["LEBANON"] = 79,
|
||||
["ISRAEL"] = 15,
|
||||
["GERMANY"] = 6,
|
||||
["ECUADOR"] = 90,
|
||||
["AGGRESSORS"] = 7,
|
||||
["FRANCE"] = 5,
|
||||
["SLOVENIA"] = 85,
|
||||
["SOUTH_KOREA"] = 45,
|
||||
["ABKHAZIA"] = 18,
|
||||
["LIBYA"] = 58,
|
||||
["PERU"] = 89,
|
||||
["AUSTRALIA"] = 21,
|
||||
["THE_NETHERLANDS"] = 10,
|
||||
["GEORGIA"] = 16,
|
||||
["UN_PEACEKEEPERS"] = 82,
|
||||
["CHINA"] = 27,
|
||||
["VENEZUELA"] = 50,
|
||||
["PHILIPPINES"] = 54,
|
||||
["MEXICO"] = 56,
|
||||
["GHANA"] = 87,
|
||||
["BELGIUM"] = 11,
|
||||
["RUSSIA"] = 0,
|
||||
["GDR"] = 78,
|
||||
["ROMANIA"] = 41,
|
||||
["NIGERIA"] = 88,
|
||||
["BRAZIL"] = 64,
|
||||
["THAILAND"] = 52,
|
||||
["PORTUGAL"] = 77,
|
||||
["CUBA"] = 76,
|
||||
["INSURGENTS"] = 17,
|
||||
["INDIA"] = 33,
|
||||
["SOUTH_AFRICA"] = 75,
|
||||
["FINLAND"] = 30,
|
||||
["QATAR"] = 72,
|
||||
["OMAN"] = 73,
|
||||
["ALGERIA"] = 70,
|
||||
["PAKISTAN"] = 39,
|
||||
["JAPAN"] = 36,
|
||||
["TURKEY"] = 3,
|
||||
["YUGOSLAVIA"] = 67,
|
||||
["CANADA"] = 8,
|
||||
["JORDAN"] = 59,
|
||||
["USA"] = 2,
|
||||
["THIRDREICH"] = 66,
|
||||
["BULGARIA"] = 25,
|
||||
["BAHRAIN"] = 65,
|
||||
["CYPRUS"] = 84,
|
||||
["CROATIA"] = 28,
|
||||
["EGYPT"] = 29,
|
||||
["IRAN"] = 34,
|
||||
["DENMARK"] = 13,
|
||||
["VIETNAM"] = 49,
|
||||
["CHILE"] = 63,
|
||||
["UKRAINE"] = 1,
|
||||
["HUNGARY"] = 32,
|
||||
["INDONESIA"] = 60,
|
||||
["POLAND"] = 40,
|
||||
["SYRIA"] = 47,
|
||||
["SLOVAKIA"] = 44,
|
||||
["HONDURAS"] = 61,
|
||||
["SUDAN"] = 53,
|
||||
["SWITZERLAND"] = 22,
|
||||
["UK"] = 4,
|
||||
["GREECE"] = 31,
|
||||
["TUNISIA"] = 51,
|
||||
["AUSTRIA"] = 23,
|
||||
["CHEZH_REPUBLIC"] = 26,
|
||||
["SWEDEN"] = 46,
|
||||
["BELARUS"] = 24,
|
||||
["KAZAKHSTAN"] = 37,
|
||||
["UNITED_ARAB_EMIRATES"] = 74,
|
||||
["KUWAIT"] = 71
|
||||
}
|
||||
|
||||
country.name = {
|
||||
[1] = "UKRAINE",
|
||||
[2] = "USA",
|
||||
[3] = "TURKEY",
|
||||
[4] = "UK",
|
||||
[5] = "FRANCE",
|
||||
[6] = "GERMANY",
|
||||
[7] = "AGGRESSORS",
|
||||
[8] = "CANADA",
|
||||
[9] = "SPAIN",
|
||||
[10] = "THE_NETHERLANDS",
|
||||
[11] = "BELGIUM",
|
||||
[12] = "NORWAY",
|
||||
[13] = "DENMARK",
|
||||
[15] = "ISRAEL",
|
||||
[16] = "GEORGIA",
|
||||
[17] = "INSURGENTS",
|
||||
[18] = "ABKHAZIA",
|
||||
[19] = "SOUTH_OSETIA",
|
||||
[20] = "ITALY",
|
||||
[21] = "AUSTRALIA",
|
||||
[22] = "SWITZERLAND",
|
||||
[23] = "AUSTRIA",
|
||||
[24] = "BELARUS",
|
||||
[25] = "BULGARIA",
|
||||
[26] = "CHEZH_REPUBLIC",
|
||||
[27] = "CHINA",
|
||||
[28] = "CROATIA",
|
||||
[29] = "EGYPT",
|
||||
[30] = "FINLAND",
|
||||
[31] = "GREECE",
|
||||
[32] = "HUNGARY",
|
||||
[33] = "INDIA",
|
||||
[34] = "IRAN",
|
||||
[35] = "IRAQ",
|
||||
[36] = "JAPAN",
|
||||
[37] = "KAZAKHSTAN",
|
||||
[38] = "NORTH_KOREA",
|
||||
[39] = "PAKISTAN",
|
||||
[40] = "POLAND",
|
||||
[41] = "ROMANIA",
|
||||
[42] = "SAUDI_ARABIA",
|
||||
[43] = "SERBIA",
|
||||
[44] = "SLOVAKIA",
|
||||
[45] = "SOUTH_KOREA",
|
||||
[46] = "SWEDEN",
|
||||
[47] = "SYRIA",
|
||||
[48] = "YEMEN",
|
||||
[49] = "VIETNAM",
|
||||
[50] = "VENEZUELA",
|
||||
[51] = "TUNISIA",
|
||||
[52] = "THAILAND",
|
||||
[53] = "SUDAN",
|
||||
[54] = "PHILIPPINES",
|
||||
[55] = "MOROCCO",
|
||||
[56] = "MEXICO",
|
||||
[57] = "MALAYSIA",
|
||||
[58] = "LIBYA",
|
||||
[59] = "JORDAN",
|
||||
[60] = "INDONESIA",
|
||||
[61] = "HONDURAS",
|
||||
[62] = "ETHIOPIA",
|
||||
[63] = "CHILE",
|
||||
[64] = "BRAZIL",
|
||||
[65] = "BAHRAIN",
|
||||
[66] = "THIRDREICH",
|
||||
[67] = "YUGOSLAVIA",
|
||||
[68] = "USSR",
|
||||
[69] = "ITALIAN_SOCIAL_REPUBLIC",
|
||||
[70] = "ALGERIA",
|
||||
[71] = "KUWAIT",
|
||||
[72] = "QATAR",
|
||||
[73] = "OMAN",
|
||||
[74] = "UNITED_ARAB_EMIRATES",
|
||||
[75] = "SOUTH_AFRICA",
|
||||
[76] = "CUBA",
|
||||
[77] = "PORTUGAL",
|
||||
[78] = "GDR",
|
||||
[79] = "LEBANON",
|
||||
[80] = "CJTF_BLUE",
|
||||
[81] = "CJTF_RED",
|
||||
[82] = "UN_PEACEKEEPERS",
|
||||
[83] = "ARGENTINA",
|
||||
[84] = "CYPRUS",
|
||||
[85] = "SLOVENIA",
|
||||
[86] = "BOLIVIA",
|
||||
[87] = "GHANA",
|
||||
[88] = "NIGERIA",
|
||||
[89] = "PERU",
|
||||
[90] = "ECUADOR",
|
||||
[0] = "RUSSIA"
|
||||
}
|
||||
|
||||
country.names = country.name
|
||||
3
library/mission/enum.lua
Normal file
3
library/mission/enum.lua
Normal file
@ -0,0 +1,3 @@
|
||||
---@meta
|
||||
|
||||
---@class enum : integer
|
||||
39
library/mission/env.lua
Normal file
39
library/mission/env.lua
Normal file
@ -0,0 +1,39 @@
|
||||
---@meta
|
||||
|
||||
---@class env
|
||||
---@field mission table see [Miz mission structure](https://wiki.hoggitworld.com/view/Miz_mission_structure)
|
||||
---@field warehouse table see [Miz warehouses structure](https://wiki.hoggitworld.com/view/Miz_warehouses_structure)
|
||||
env = {}
|
||||
|
||||
---Prints the passed string to the dcs.log with a prefix of 'info'.<br>
|
||||
---If the second parameter is true, a message box will pop up when the logging occurs.
|
||||
---@param log string
|
||||
---@param showMessageBox boolean?
|
||||
function env.info(log, showMessageBox) end
|
||||
|
||||
---Prints the passed string to the dcs.log with a prefix of 'warning'.<br>
|
||||
---If the second parameter is true, a message box will pop up when the logging occurs.
|
||||
---@param log string
|
||||
---@param showMessageBox boolean?
|
||||
function env.warning(log, showMessageBox) end
|
||||
|
||||
---Prints the passed string to the dcs.log with a prefix of 'error'.<br>
|
||||
---If the second parameter is true, a message box will pop up when the logging occurs.
|
||||
---@param log string
|
||||
---@param showMessageBox boolean?
|
||||
function env.error(log, showMessageBox) end
|
||||
|
||||
---Sets the value for whether or not an error message box will be displayed if a lua error occurs.<br>
|
||||
---By default the error message box will appear.
|
||||
---@param toggle boolean
|
||||
function env.setErrorMessageBoxEnabled(toggle) end
|
||||
|
||||
---Returns a string associated with the passed dictionary key value.<br>
|
||||
---If the key is not found within the miz the function will return the string that was passed.<br>
|
||||
---Example usage:<br>
|
||||
---```
|
||||
---groupName = env.getValueDictByKey('DictKey_GroupName_5')
|
||||
---```
|
||||
---@param value string
|
||||
---@return string
|
||||
function env.getValueDictByKey(value) end
|
||||
71
library/mission/group.lua
Normal file
71
library/mission/group.lua
Normal file
@ -0,0 +1,71 @@
|
||||
---@meta
|
||||
|
||||
---@class Group
|
||||
---@field id_ integer
|
||||
Group = {}
|
||||
|
||||
---@enum Group.Category
|
||||
Group.Category = {
|
||||
AIRPLANE = 0,
|
||||
HELICOPTER = 1,
|
||||
GROUND = 2,
|
||||
SHIP = 3,
|
||||
TRAIN = 4
|
||||
}
|
||||
|
||||
---Returns the group object by its name
|
||||
---@param name string
|
||||
---@return Group
|
||||
function Group.getByName(name) end
|
||||
|
||||
---Destroys the group, physically removing it from the game world without creating an event. The entire group simply disappears.
|
||||
function Group:destroy() end
|
||||
|
||||
---Returns an enumerator of the category for the specific group. <br>
|
||||
---See enumerators Group.Category for further reference.
|
||||
---@return Group.Category -- The category and sub-category of the object.
|
||||
function Group:getCategory() end
|
||||
|
||||
---Returns an enumerator that defines the coalition that a group belongs to. Function also works with Unit, Static Object, Airbase, Weapon.
|
||||
---@return coalition.side -- Sides are as follows: 0 = neutral, 1 = red, 2 = blue.
|
||||
function Group:getCoalition() end
|
||||
|
||||
---Returns the controller of the specified object. <br>
|
||||
---Ships and ground units can only be controlled at a group level. Airplanes and helicopters can be controlled at both a group and unit level.
|
||||
---@return Controller
|
||||
function Group:getController() end
|
||||
|
||||
---Returns an enumerator that defines the country that a group belongs to. <br>
|
||||
---Function also works with Unit, Static Object, Airbase, Weapon.
|
||||
---@return country.id -- The country id that the group belongs to. See `country` enums for full listing of countries.
|
||||
function Group:getCountry() end
|
||||
|
||||
---Returns a number which defines the unique mission id of a given group.
|
||||
---@return integer
|
||||
function Group:getID() end
|
||||
|
||||
---Returns the initial size of the group as defined in the mission editor or if spawned via function. This number will not change as units are destroyed.
|
||||
---@return number
|
||||
function Group:getInitialSize() end
|
||||
|
||||
---Returns a string of the name of the group as defined by the mission editor or dynamic spawning functions.
|
||||
---@return string
|
||||
function Group:getName() end
|
||||
|
||||
---Returns the current size of the group. <br>
|
||||
---This value will change as units are destroyed. Can be used in combination with getUnit to not accidentally use too big a value for that function, or to access the last unit in the group.
|
||||
---@return number
|
||||
function Group:getSize() end
|
||||
|
||||
---Returns the unit object of the specified unitIndex within the group. If the index is not valid, this function will return nil.
|
||||
---@param UnitIndex number -- The index of the unit within the group.
|
||||
---@return Unit
|
||||
function Group:getUnit(UnitIndex) end
|
||||
|
||||
---Returns a table of unit objects indexed in unit order. Useful for getting unit specific data for every unit in the group.
|
||||
---@return Unit[] -- A table of Unit objects.
|
||||
function Group:getUnits() end
|
||||
|
||||
---Return a boolean value based on whether the group currently exists in the mission.
|
||||
---@return boolean
|
||||
function Group:isExist() end
|
||||
146
library/mission/land.lua
Normal file
146
library/mission/land.lua
Normal file
@ -0,0 +1,146 @@
|
||||
---@meta
|
||||
|
||||
---@class land
|
||||
land = {}
|
||||
|
||||
---@enum land.SurfaceType
|
||||
land.SurfaceType = {
|
||||
LAND = 1,
|
||||
SHALLOW_WATER = 2,
|
||||
WATER = 3,
|
||||
ROAD = 4,
|
||||
RUNWAY = 5,
|
||||
}
|
||||
|
||||
---Returns the distance from sea level (y-axis) of a given vec2 point.
|
||||
---
|
||||
---Example:
|
||||
---The following example will convert a vec3 point lacking y-axis data to a vec3 point at ground level.
|
||||
---```
|
||||
---newPoint= {x = point.x, y = land.getHeight({x = point.x, y = point.z}), z= point.z}
|
||||
---```
|
||||
---@param vec2 vec2|table
|
||||
---@return number
|
||||
---Return Example: 25
|
||||
function land.getHeight(vec2) end
|
||||
|
||||
---Returns the surface height and depth of a point. Useful for checking if the path is deep enough to support a given ship.<br>
|
||||
---Both values are positive. When checked over water at sea level the first value is always zero.<br>
|
||||
---When checked over water at altitude, for example the reservoir of the Inguri Dam, the first value is the corresponding altitude the water level is at.<br>
|
||||
---
|
||||
---Example:
|
||||
---The following will return a value of the depth at a trigger zone named thors twins.
|
||||
---```
|
||||
---local p = trigger.action.getZone("thors twins").point
|
||||
---local alt, depth = land.getSurfaceHeightWithSeabed({x = p.x, y = p.z})
|
||||
---```
|
||||
---@param vec2 vec2
|
||||
---@return number, number
|
||||
---Return Example: 0, 15
|
||||
function land.getSurfaceHeightWithSeabed(vec2) end
|
||||
|
||||
---Returns an enumerator for the surface type at a given point.<br>
|
||||
---Enumerator is as follows:<br>
|
||||
---```
|
||||
---land.SurfaceType
|
||||
--- LAND 1
|
||||
--- SHALLOW_WATER 2
|
||||
--- WATER 3
|
||||
--- ROAD 4
|
||||
--- RUNWAY 5
|
||||
---```
|
||||
---Example:
|
||||
---The following takes a number of trigger zones named "surf" with a suffix of 1 to 7 and returns the type of terrain enumerator ID and string to the dcs.log.
|
||||
---Note that the function accepts a vec2 point so it is needed to be converted from vec2 to vec3.
|
||||
---Can also be accomplished with a mist function mist.utils.makeVec2
|
||||
---```
|
||||
---for i = 1, 7 do
|
||||
--- local point = trigger.misc.getZone('surface'..i).point
|
||||
--- point.y = point.z
|
||||
--- local surfType = land.getSurfaceType(point)
|
||||
--- for str, ind in pairs(land.SurfaceType) do
|
||||
--- if ind == surfType then
|
||||
--- env.info('point ' .. i .. ' is type ' .. surfType .. ' String: ' .. str)
|
||||
--- end
|
||||
--- end
|
||||
---end
|
||||
---```
|
||||
---@param vec2 vec2
|
||||
---@return land.SurfaceType
|
||||
---Return Example: 1
|
||||
function land.getSurfaceType(vec2) end
|
||||
|
||||
---Returns the boolean value if there is a terrain intersection via drawing a virtual line from the origin to the destination.<br>
|
||||
---Used for determining line of sight.<br>
|
||||
---
|
||||
---Example:
|
||||
---The following example outputs text based on the Line of Sight between a stationary target and a moving group that is moving over the ridge towards a target.
|
||||
---```
|
||||
---local mover = Unit.getByName('mover'):getPosition().p
|
||||
---mover.y = mover.y + 3
|
||||
---local target = Unit.getByName('target'):getPosition().p
|
||||
---target.y = target.y + 1.8
|
||||
---trigger.action.outText('Is Visible: ' .. tostring(land.isVisible(mover, target)), 2)
|
||||
---```
|
||||
---@param origin vec3
|
||||
---@param destination vec3
|
||||
---@return boolean
|
||||
---Return Example: true or false
|
||||
function land.isVisible(origin, destination) end
|
||||
|
||||
---Returns an intercept point at which a ray drawn from the origin in the passed normalized direction for a specified distance.<br>
|
||||
---If no intersection found the function will return nil.<br>
|
||||
---
|
||||
---Example:
|
||||
---The following is a sample of a tracked weapon object that is checked periodically and updates the estimated impact point of the weapon.
|
||||
---```
|
||||
---for id, wpn in pairs(trackedWeapons) do
|
||||
--- local wpnData = {}
|
||||
--- wpnData.pos = wpn:getPosition().p
|
||||
--- wpnData.dir = wpn:getPosition().x
|
||||
--- wpn.ip = land.getIP(wpnData.pos, wpnData.dir, 20)
|
||||
---end
|
||||
---```
|
||||
---@param origin vec3
|
||||
---@param direction vec3
|
||||
---@param distance number
|
||||
---@return vec3
|
||||
---Return Example: vec3
|
||||
function land.getIP(origin, direction, distance) end
|
||||
|
||||
---Returns the X and Y values of a coordinate on the nearest road from the given point.<br>
|
||||
---NOTE that this function does not use vec2 or vec3. It uses individual values representing a vec2 for x and y.<br>
|
||||
---Valid road type values: 'roads' and 'railroads'<br>
|
||||
---
|
||||
---Example:
|
||||
---The following returns the closest road to a point.
|
||||
---```
|
||||
---local testPoint = trigger.misc.getZone('test').point
|
||||
---local x, y = land.getClosestPointOnRoads('roads',testPoint.x, testPoint.z)
|
||||
---```
|
||||
---@param roadType string
|
||||
---@param xCoord number
|
||||
---@param yCoord number
|
||||
---@return number, number
|
||||
---Return Example: 233324, 423423
|
||||
function land.getClosestPointOnRoads(roadType, xCoord, yCoord) end
|
||||
|
||||
---Returns a table of points along a that define a route from a starting point to a destination point.<br>
|
||||
---Returned table is a table of vec2 points indexed numerically from starting point to destination. Table can return a high number of points over a relatively short route. So expect to iterate through a large number of values.<br>
|
||||
---Roadtype can be 'railroads' or 'roads'<br>
|
||||
---NOTE!!! A bug exists where the value for railroads is actually `rails`. This is different from the sister function `getClosestPointOnRoads`!<br>
|
||||
---
|
||||
---Example:
|
||||
---The following returns the closest road to a point.
|
||||
---```
|
||||
---local testPoint = trigger.misc.getZone('test').point
|
||||
---local x, y = land.getClosestPointOnRoads('roads',testPoint.x, testPoint.z)
|
||||
---```
|
||||
---@param roadType string
|
||||
---@param xCoord number
|
||||
---@param yCoord number
|
||||
---@param destX number
|
||||
---@param destY number
|
||||
---@return vec2[]
|
||||
---Return Example: table
|
||||
function land.findPathOnRoads(roadType, xCoord, yCoord, destX, destY) end
|
||||
158
library/mission/missionCommands.lua
Normal file
158
library/mission/missionCommands.lua
Normal file
@ -0,0 +1,158 @@
|
||||
---@meta
|
||||
|
||||
---@class missionCommands
|
||||
missionCommands = {}
|
||||
|
||||
---Adds a command to the "F10 Other" radio menu allowing players to run specified scripting functions. Command is added for both teams. The string name is the text that will be displayed in the F10 Other menu and is also used in the function to remove the command from the menu.<br>
|
||||
---Path is an optional value that defines whether or not the command will be in a named submenu.<br>
|
||||
---FunctionToCall is the name of the function, with the optional argument value designating any passed values.<br>
|
||||
---Function returns a table indexed numerically indicating where in the F10 menu the command resides.<br>
|
||||
---Examples of return values:<br>
|
||||
---```
|
||||
---{
|
||||
--- [1] = "Negative Ghostrider",
|
||||
---}
|
||||
---{
|
||||
--- [1] = "SubMenuInRoot",
|
||||
--- [2] = "Command in the submenu",
|
||||
---}
|
||||
---{
|
||||
--- [1] = "SubMenuInRoot",
|
||||
--- [2] = "SubMenuInSubMenu",
|
||||
--- [3] = "Command in nested submenu",
|
||||
---}
|
||||
---```
|
||||
---The sample below will generate a base menu accessed via F10 called "Display Requests" for all users with two sub-items for a negative or positive response:<br>
|
||||
---```
|
||||
---local function displayRequests(vars)
|
||||
--- if vars.flyby == true then
|
||||
--- trigger.action.outText("Roger that Ghostrider, you may do a flyby.", 20)
|
||||
--- else
|
||||
--- trigger.action.outText("Negative Ghostrider, the pattern is full", 20)
|
||||
--- end
|
||||
---end
|
||||
---local displayRequests = missionCommands.addSubMenu( "Display Requests")
|
||||
---local negativeReply = missionCommands.addCommand( "Negative Ghostrider", displayRequests , displayMsg, {flyby = false})
|
||||
---local positiveReply = missionCommands.addCommand( "Roger Ghostrider", displayRequests , displayMsg, {flyby = true})
|
||||
---```
|
||||
---@param name string -- The name of the command to be displayed in the F10 Other menu.
|
||||
---@param path table | nil -- Defines whether the command will be in a named submenu.
|
||||
---@param functionToRun function -- The function to be run.
|
||||
---@param anyArguement any -- Optional. Any passed values.
|
||||
---@return table -- A table indicating where in the F10 menu the command resides.
|
||||
function missionCommands.addCommand(name, path, functionToRun, anyArguement) end
|
||||
|
||||
---Creates a submenu of a specified name for all players. Can be used to create nested submenus. If the path is not specified, submenu is added to the root menu.<br>
|
||||
---Function returns a table indexed numerically indicating where in the F10 menu the submenu resides.<br>
|
||||
---Example of return value:<br>
|
||||
---```
|
||||
---{
|
||||
--- [1] = "SubMenuInRoot",
|
||||
---}
|
||||
---```
|
||||
---The following creates a submenu named "Request Asset" and fills it with 3 options "SEAD", "CAS", and "CAP":<br>
|
||||
---```
|
||||
---local requestM = missionCommands.addSubMenu('Request Asset')
|
||||
---local rSead = missionCommands.addCommand('SEAD', requestM, doRequestFunction, {type = "SEAD"})
|
||||
---local rCAS = missionCommands.addCommand('CAS', requestM, doRequestFunction, {type = "CAS"})
|
||||
---local rCAP= missionCommands.addCommand('CAP', requestM, doRequestFunction, {type = "CAP"})
|
||||
---```
|
||||
---An example of how to create nested submenus:<br>
|
||||
---```
|
||||
---local subR = missionCommands.addSubMenu('Root SubMenu')
|
||||
---local subN1 = missionCommands.addSubMenu('SubMenu within RootSubmenu', subR)
|
||||
---local subN2 = missionCommands.addSubMenu('we must go deeper', subN1)
|
||||
---local subN3 = missionCommands.addSubMenu('Go take a UX class', subN2)
|
||||
---```
|
||||
---@param name string -- The name of the submenu.
|
||||
---@param path table? -- Optional. Defines whether the submenu will be in a named submenu.
|
||||
---@return table -- A table indicating where in the F10 menu the submenu resides.
|
||||
function missionCommands.addSubMenu(name, path) end
|
||||
|
||||
---Removes the item of the specified path from the F10 radio menu for all. If the value is nil all items will be removed from the radio menu. If the path given is a submenu then all items nested within will be removed.<br>
|
||||
---This function does not return a value.<br>
|
||||
---The following would remove a command named "Test Command" that is listed in the root menu:<br>
|
||||
---```
|
||||
---missionCommands.removeItem({[1] = "Test Command"})
|
||||
---```
|
||||
---Here is a relatively simple setup to save possibly multiple paths for commands generated for the purpose of removing it at a later time. When a command is created it is stored in the commandDB table. When the player selects "Warning Message" in their F10 menu the player will be informed that someone is taking the Hobbits to Isengard, repeatedly. At the end of the function it calls the removeItem function to remove the path with the name "Isengard" from the commandDB table:<br>
|
||||
---```
|
||||
---local commandDB = {}
|
||||
---local function removeItem(name)
|
||||
--- missionCommands.removeItem(commandDB[name])
|
||||
---end
|
||||
---local function loopMessage()
|
||||
--- for i = 1, 20 do
|
||||
--- trigger.action.outText('They are taking the Hobbits to Isengard', 2)
|
||||
--- end
|
||||
--- removeItem('Isengard')
|
||||
---end
|
||||
---commandDB['Isengard'] = missionCommands.addCommand('Warning Message', nil, loopMessage)
|
||||
---```
|
||||
---@param path table | nil -- The path of the item to be removed. If nil, all items will be removed.
|
||||
function missionCommands.removeItem(path) end
|
||||
|
||||
---Adds a command to the "F10 Other" radio menu allowing players to run specified scripting functions. Command is added for the specified coalition. The string name is the text that will be displayed in the F10 Other menu and is also used in the function to remove the command from the menu.<br>
|
||||
---Path is an optional value that defines whether or not the command will be in a named submenu.<br>
|
||||
---FunctionToCall is the name of the function, with the optional argument value designating any passed values.<br>
|
||||
---This function returns a table indicating where in the F10 menu the command resides.<br>
|
||||
---@param coalition coalition.side -- The coalition for which the command is added.
|
||||
---@param name string -- The name of the command.
|
||||
---@param path table | nil -- Optional. Defines whether the command will be in a named submenu.
|
||||
---@param functionToRun function -- The function to be run when the command is selected.
|
||||
---@param anyArguement any -- Optional. Any argument to be passed to the function.
|
||||
---@return table -- A table indicating where in the F10 menu the command resides.
|
||||
function missionCommands.addCommandForCoalition(coalition, name, path, functionToRun, anyArguement) end
|
||||
|
||||
---Creates a submenu of a specified name for the specified coalition. Can be used to create nested submenus. If the path is not specified, submenu is added to the root menu.<br>
|
||||
---This function returns a table indicating where in the F10 menu the submenu resides.<br>
|
||||
---@param coalition coalition.side -- The coalition for which the submenu is added.
|
||||
---@param name string -- The name of the submenu.
|
||||
---@param path table | nil -- Optional. Defines whether the submenu will be in a named submenu.
|
||||
---@return table -- A table indicating where in the F10 menu the submenu resides.
|
||||
function missionCommands.addSubMenuForCoalition(coalition, name, path) end
|
||||
|
||||
---Removes the item of the specified path from the F10 radio menu for the specified coalition. If the value is nil all items will be removed from the radio menu.<br>
|
||||
---This function does not return a value.<br>
|
||||
---@param coalition coalition.side -- The coalition for which the item is removed.
|
||||
---@param path table | nil -- The path of the item to be removed. If nil, all items will be removed.
|
||||
function missionCommands.removeItemForCoalition(coalition, path) end
|
||||
|
||||
---Adds a command to the "F10 Other" radio menu allowing players to run specified scripting functions. Command is added for the specified groupId. The string name is the text that will be displayed in the F10 Other menu and is also used in the function to remove the command from the menu.<br>
|
||||
---Path is an optional value that defines whether or not the command will be in a named submenu.<br>
|
||||
---FunctionToCall is the name of the function, with the optional argument value designating any passed values.<br>
|
||||
---This function returns a table indicating where in the F10 menu the command resides.<br>
|
||||
---The following iterates the table, finds their groupIds, and passes the groupName to the imLost function whenever someone from the group selects the F10 choice:<br>
|
||||
---```
|
||||
---local function imLost(gName)
|
||||
--- -- whatever
|
||||
---end
|
||||
---local tbl = {'group1', 'group2', 'group3', 'group4' ,'group5'}
|
||||
---for i = 1, #tbl do
|
||||
--- if Group.getByName(tbl[i]) then
|
||||
--- local groupId = Group.getByName(tbl[i]):getID
|
||||
--- missionCommands.addCommandForGroup(groupId, 'Halp', nil , imLost, tbl[i])
|
||||
--- end
|
||||
---end
|
||||
---```
|
||||
---@param groupId integer -- The groupId for which the command is added.
|
||||
---@param name string -- The name of the command.
|
||||
---@param path table | nil -- Optional. Defines whether the command will be in a named submenu.
|
||||
---@param functionToRun function -- The function to be run when the command is selected.
|
||||
---@param anyArguement any -- Optional. Any argument to be passed to the function.
|
||||
---@return table -- A table indicating where in the F10 menu the command resides.
|
||||
function missionCommands.addCommandForGroup(groupId, name, path, functionToRun, anyArguement) end
|
||||
|
||||
---Creates a submenu of a specified name for the specified group. Can be used to create nested submenus. If the path is not specified, submenu is added to the root menu.<br>
|
||||
---This function returns a table indicating where in the F10 menu the submenu resides.<br>
|
||||
---@param groupId integer -- The groupId for which the submenu is added.
|
||||
---@param name string -- The name of the submenu.
|
||||
---@param path table | nil -- Optional. Defines whether the submenu will be in a named submenu.
|
||||
---@return table -- A table indicating where in the F10 menu the submenu resides.
|
||||
function missionCommands.addSubMenuForGroup(groupId, name, path) end
|
||||
|
||||
---Removes the item of the specified path from the F10 radio menu for the specified group. If the value is nil all items will be removed from the radio menu.<br>
|
||||
---This function does not return a value.<br>
|
||||
---@param groupId number -- The groupId for which the item is removed.
|
||||
---@param path table | nil -- The path of the item to be removed. If nil, all items will be removed.
|
||||
function missionCommands.removeItemForGroup(groupId, path) end
|
||||
58
library/mission/net.lua
Normal file
58
library/mission/net.lua
Normal file
@ -0,0 +1,58 @@
|
||||
---@meta
|
||||
|
||||
---@class net
|
||||
net = {}
|
||||
|
||||
---Forces the player to occupy the set slot.<br>
|
||||
---SlotId matches unit Ids of client aircraft. The exception being Combined Arms slots and multicrew slots. The latter of which have "_X" appended to denote the seat.
|
||||
---SideID:
|
||||
--- - 0 : spectators
|
||||
--- - 1 : Red
|
||||
--- - 2 : Blue
|
||||
---@param playerID integer -- The id of the player.
|
||||
---@param sideId integer -- The id of the side.
|
||||
---@param slotId integer|string -- The id of the slot.
|
||||
---@return boolean
|
||||
function net.force_player_slot(playerID, sideId, slotId) end
|
||||
|
||||
---Returns the name of a given player.<br>Is the same as `net.get_player_info(playerID, 'name')`.
|
||||
---@param playerID integer -- from `net.get_player_list()`
|
||||
---@return string
|
||||
function net.get_name(playerID) end
|
||||
|
||||
---Returns a table of players currently connected to the server.
|
||||
---@return integer[]
|
||||
function net.get_player_list() end
|
||||
|
||||
---@class netPlayerInfo
|
||||
---@field id integer
|
||||
---@field name string
|
||||
---@field side integer|0|1|2
|
||||
---@field slot integer
|
||||
---@field ping integer
|
||||
---@field ipaddr string
|
||||
---@field ucid string
|
||||
|
||||
---Returns a table of attributes for a given playerId. If optional attribute present only that value is returned.
|
||||
---Attributes:
|
||||
--- - `id` : playerID
|
||||
--- - `name` : player name
|
||||
--- - `side` : 0 - spectators, 1 - red, 2 - blue
|
||||
--- - `slot` : slotID of the player
|
||||
--- - `ping` : ping of the player in ms
|
||||
--- - `ipaddr`: IP address of the player, SERVER ONLY
|
||||
--- - `ucid` : Unique Client Identifier, SERVER ONLY
|
||||
---@param playerID integer -- The id of the player.
|
||||
---@param attribute string? -- The attribute to be returned (optional).
|
||||
---@return netPlayerInfo -- The table of attributes for the player.
|
||||
function net.get_player_info(playerID, attribute) end
|
||||
|
||||
---Converts a lua value to a JSON string.
|
||||
---@param lua any
|
||||
---@return string
|
||||
function net.lua2json(lua) end
|
||||
|
||||
---Converts a JSON string to a lua table.
|
||||
---@param json string
|
||||
---@return table
|
||||
function net.json2lua(json) end
|
||||
111
library/mission/object.lua
Normal file
111
library/mission/object.lua
Normal file
@ -0,0 +1,111 @@
|
||||
---@meta
|
||||
|
||||
---@class Object
|
||||
Object = {}
|
||||
|
||||
---@enum Object.Category
|
||||
Object.Category = {
|
||||
UNIT = 1,
|
||||
WEAPON = 2,
|
||||
STATIC = 3,
|
||||
BASE = 4,
|
||||
SCENERY = 5,
|
||||
Cargo = 6,
|
||||
}
|
||||
|
||||
---@class ObjectDesc
|
||||
---@field typeName string
|
||||
---@field displayName string
|
||||
---@field category Object.Category
|
||||
---@field attributes table?
|
||||
|
||||
---Destroys the object, physically removing it from the game world without creating an event. The object simply disappears.
|
||||
function Object:destroy() end
|
||||
|
||||
---Returns an enumerator of the category for the specific object. <br>
|
||||
---The enumerator returned is dependent on the category of the object and how the function is called. As of DCS 2.9.2 when this function is called on an Object, Unit, Weapon, or Airbase a 2nd value will be returned which details the object sub-category value. See enumerators Group.Category, Object.Category, and Spot.Category for further reference.
|
||||
---@return Object.Category, Unit.Category? -- The category and sub-category of the object.
|
||||
function Object:getCategory() end
|
||||
|
||||
---Returns an enumerator of the category for the specific object.<br>
|
||||
---The enumerator returned is dependent on the category of the object and how the function is called. See enumerators Group.Category, Object.Category, and Spot.Category for further reference.<br>
|
||||
---Function also works with Unit, Weapon, Static Object, Scenery Object, Airbase. <br>
|
||||
---Unit.getCategoryEx(obj) will return the unit category.<br>
|
||||
---obj:getCategoryEx() will return the unit category.<br>
|
||||
---@return Unit.Category
|
||||
function Object:getCategoryEx() end
|
||||
|
||||
---Return a description table of the given object. Table entries are dependent on the category of object and the sub-categories that may exist within that object type.
|
||||
---@return table
|
||||
function Object:getDesc() end
|
||||
|
||||
---Returns a number which defines the unique mission id of a given object.
|
||||
---@return integer
|
||||
function Object:getID() end
|
||||
|
||||
---Returns a string of the name of the object as defined by the mission editor or dynamic spawning functions. <br>
|
||||
---When run as Object.getName(obj) the value can be different than if run via Unit.getName(obj) or obj:getName(). It appears to be returning the runtime Id.
|
||||
---@return string
|
||||
function Object:getName() end
|
||||
|
||||
---Returns a vec3 table of the x, y, and z coordinates for the position of the given object in 3D space. <br>
|
||||
---Coordinates are dependent on the position of the maps origin. In the case of the Caucuses theater, the origin is located in the Crimean region of the map.
|
||||
---@return vec3
|
||||
function Object:getPoint() end
|
||||
|
||||
---Returns a pos3 table of the objects current position and orientation in 3D space. <br>
|
||||
---X, Y, Z values are unit vectors defining the objects orientation. Coordinates are dependent on the position of the maps origin. In the case of the Caucuses theater, the origin is located in the Crimean region of the map. Function also works with Unit, Weapon, Static Object, Scenery Object, Airbase.
|
||||
---@return pos3
|
||||
function Object:getPosition() end
|
||||
|
||||
---Return a string of the object's type name.
|
||||
---@return string
|
||||
function Object:getTypeName() end
|
||||
|
||||
---Returns a vec3 table of the object's velocity vectors.
|
||||
---@return vec3
|
||||
function Object:getVelocity() end
|
||||
|
||||
---Returns a boolean value if the object in question is in the air.
|
||||
---@return boolean
|
||||
function Object:inAir() end
|
||||
|
||||
---Return a boolean value based on whether the object currently exists in the mission.
|
||||
---@return boolean
|
||||
function Object:isExist() end
|
||||
|
||||
---@class CoalitionObject: Object
|
||||
CoalitionObject = {}
|
||||
|
||||
---Returns an enumerator that defines the coalition that an object currently belongs to. Function also works with Unit, Static Object, Airbase, Weapon.
|
||||
---@return coalition.side -- Sides are as follows: 0 = neutral, 1 = red, 2 = blue. Airbase objects can return 3 if the base has red and blue coalition units within the capture perimeter.
|
||||
function CoalitionObject:getCoalition() end
|
||||
|
||||
---Returns an enumerator that defines the country that an object currently belongs to. <br>
|
||||
---Function also works with Unit, Static Object, Airbase, Weapon.
|
||||
---@return number -- The country id that the object belongs to. See `country` enums for full listing of countries.
|
||||
function CoalitionObject:getCountry() end
|
||||
|
||||
|
||||
---@class StaticObject: CoalitionObject
|
||||
StaticObject = {}
|
||||
|
||||
---Returns the static object by its name
|
||||
---@param name string
|
||||
---@return StaticObject
|
||||
function StaticObject.getByName(name) end
|
||||
|
||||
|
||||
---Returns a string of a cargo object's mass in the format ' mass kg'.
|
||||
---@return string
|
||||
function StaticObject:getCargoDisplayName() end
|
||||
|
||||
---Returns the current value for an animation argument on the external model of the given object.<br>
|
||||
---Each model animation has an id tied to with different values representing different states of the model.<br>
|
||||
---Animation arguments can be figured out by opening the respective 3d model in the modelviewer.<br>
|
||||
---For example, you can determine the rotation and orientation of the barrel of a Tank's cannon by checking its animation arguments.<br>
|
||||
---More practically, you can determine whether or not a helicopter's doors are open.<br>
|
||||
---If draw argument value is invalid for the unit in question a value of 0 will be returned.<br>
|
||||
---@param arg integer
|
||||
---@return number
|
||||
function StaticObject:getDrawArgumentValue(arg) end
|
||||
90
library/mission/timer.lua
Normal file
90
library/mission/timer.lua
Normal file
@ -0,0 +1,90 @@
|
||||
---@meta
|
||||
|
||||
---@alias time number
|
||||
|
||||
---@class timer
|
||||
timer = {}
|
||||
|
||||
---Returns the model time in seconds to 3 decimal places.<br>
|
||||
---This counts time once the simulator loads. So if a mission is paused, the time this function returns still moves forward.<br>
|
||||
---@return time
|
||||
function timer.getTime() end
|
||||
|
||||
---Returns the mission start time in seconds. Can be used with timer.getAbsTime() to see how much time has passed in the mission.
|
||||
---@return time
|
||||
function timer.getTime0() end
|
||||
|
||||
---Returns the game world time in seconds relative to time the mission started.<br>
|
||||
---Will always count up from when the mission started. If the value is above 86400 then it is the next day after the mission started.<br>
|
||||
---This function is useful in attaining the time of day.<br>
|
||||
---Assuming a mission started at noon the value returned would be 43200. (12*60*60). Midnight would be 0. Calling this function at 12:00:10 timer.getAbsTime will return 43210.xxx.
|
||||
---@return time
|
||||
function timer.getAbsTime() end
|
||||
|
||||
|
||||
---Schedules a function to run at a time in the future. This is a very powerful function.<br>
|
||||
---The function that is called is expected to return nil or a number which will indicate the next time the function will be rescheduled.<br>
|
||||
---Use the second argument in that function to retrieve the current time and add the desired amount of delay (expressed in seconds).<br>
|
||||
---
|
||||
---Example:
|
||||
---The following will run a function named "main" 120 seconds from one the code would run.
|
||||
---```
|
||||
---timer.scheduleFunction(main, {}, timer.getTime() + 120)
|
||||
---```
|
||||
---The following example sets up a repetitive call loop where function CheckStatus is called every 5 seconds or.
|
||||
---```
|
||||
---function CheckStatus(ourArgument, time)
|
||||
--- -- Do things to check, use ourArgument (which is the scheduleFunction's second argument)
|
||||
--- if ourArgument == 53 and someExternalCondition then
|
||||
--- -- Keep going
|
||||
--- return time + 5
|
||||
--- else
|
||||
--- -- That's it we're done looping
|
||||
--- return nil
|
||||
--- end
|
||||
---end
|
||||
---timer.scheduleFunction(CheckStatus, 53, timer.getTime() + 5)
|
||||
---```
|
||||
---@param functionToCall function
|
||||
---@param anyFunctionArguement any
|
||||
---@param modelTime time
|
||||
---@return integer functionId
|
||||
---Return Example: 3
|
||||
function timer.scheduleFunction(functionToCall, anyFunctionArguement, modelTime) end
|
||||
|
||||
---Removes a scheduled function as defined by the functionId from executing. Essentially will "destroy" the function.<br>
|
||||
---
|
||||
---Example:
|
||||
---The following will run a function named "main" 120 seconds from one the code would run.
|
||||
---```
|
||||
---local id = timer.scheduleFunction(main, {}, timer.getTime() + 120)
|
||||
---```
|
||||
---If further down in the code it was decided to stop main() from running it may look like this.
|
||||
---```
|
||||
---if abort == true then
|
||||
--- timer.removeFunction(id)
|
||||
---end
|
||||
---```
|
||||
---@param functionId integer
|
||||
---@return function
|
||||
---Return Example: none
|
||||
function timer.removeFunction(functionId) end
|
||||
|
||||
---Re-Schedules an already scheduled function to run at a different time in the future.<br>
|
||||
---
|
||||
---Example:
|
||||
---The following will run a function named "main" 120 seconds from one the code would run.
|
||||
---```
|
||||
---local id = timer.scheduleFunction(main, {}, timer.getTime() + 120)
|
||||
---```
|
||||
---If further down in the code it was decided to run the main() function sooner it could look like this.
|
||||
---```
|
||||
---if mustGoFaster == true then
|
||||
--- timer.setFunctionTime(id, timer.getTime() + 1)
|
||||
---end
|
||||
---```
|
||||
---@param functionId integer
|
||||
---@param modelTime time
|
||||
---@return function
|
||||
---Return Example: none
|
||||
function timer.setFunctionTime(functionId, modelTime) end
|
||||
317
library/mission/trigger.lua
Normal file
317
library/mission/trigger.lua
Normal file
@ -0,0 +1,317 @@
|
||||
---@meta
|
||||
|
||||
---@class trigger
|
||||
trigger = {}
|
||||
|
||||
---@enum trigger.smokeColor
|
||||
trigger.smokeColor = {
|
||||
Green = 0,
|
||||
Red = 1,
|
||||
White = 2,
|
||||
Orange = 3,
|
||||
Blue = 4
|
||||
}
|
||||
|
||||
---@enum trigger.flareColor
|
||||
trigger.flareColor = {
|
||||
Green = 0,
|
||||
Red = 1,
|
||||
White = 2,
|
||||
Yellow = 3
|
||||
}
|
||||
|
||||
---@class trigger.action
|
||||
trigger.action = {}
|
||||
---Creates an explosion at a given point at the specified power.
|
||||
---@param vec3 vec3
|
||||
---@param power number
|
||||
function trigger.action.explosion(vec3, power) end
|
||||
|
||||
---Creates a signal flare at the given point in the specified color. <br>
|
||||
---The flare will be launched in the direction of the azimuth variable. <br>
|
||||
---trigger.flareColor:
|
||||
--- - Green 0
|
||||
--- - Red 1
|
||||
--- - White 2
|
||||
--- - Yellow 3
|
||||
---@param vec3 vec3 -- The point where the flare will be launched.
|
||||
---@param flareColor trigger.flareColor -- The color of the flare.
|
||||
---@param azimuth number -- The direction in which the flare will be launched.
|
||||
function trigger.action.signalFlare(vec3, flareColor, azimuth) end
|
||||
|
||||
---Creates an arrow from the startPoint to the endPoint on the F10 map. The arrow will be "pointing at" the startPoint. There is no control over other dimensions of the arrow. <br>
|
||||
---Coalition Ids to be used:
|
||||
--- - -1 All
|
||||
--- - 0 Neutral
|
||||
--- - 1 Red
|
||||
--- - 2 Blue <br>
|
||||
---Id MUST be unique and is shared with the ids used with mark panels. <br>
|
||||
---Likewise trigger.action.removeMark is used to remove shapes created. <br>
|
||||
---startPoint and endPoint MUST be a vec3 table. {x, y z}. <br>
|
||||
---Color format is {r, g, b, a} with values 0 to 1. A red line with 50% alpha would be {1, 0, 0, 0.5} <br>
|
||||
---Color is the color used for the outline around the shape. <br>
|
||||
---Colorfill corresponds to the shading of the shape <br>
|
||||
---LineType corresponds to an enumerator value. LineTypes:
|
||||
--- - 0 No Line
|
||||
--- - 1 Solid
|
||||
--- - 2 Dashed
|
||||
--- - 3 Dotted
|
||||
--- - 4 Dot Dash
|
||||
--- - 5 Long Dash
|
||||
--- - 6 Two Dash <br>
|
||||
---readOnly denotes whether in the future if clients will be allowed to edit or remove the shape. <br>
|
||||
---Message corresponds to a message box that will appear when the shape is added.
|
||||
---@param coalition coalition.side|integer -- The coalition id.
|
||||
---@param id integer -- The unique id.
|
||||
---@param startPoint vec3 -- The start point of the arrow.
|
||||
---@param endPoint vec3 -- The end point of the arrow.
|
||||
---@param color table -- The color of the outline.
|
||||
---@param fillColor table -- The color used for shading the shape.
|
||||
---@param lineType integer -- The type of the line.
|
||||
---@param readOnly? boolean -- Whether the arrow is read only.
|
||||
---@param message? string -- The message to display when the arrow is added.
|
||||
function trigger.action.arrowToAll(coalition, id, startPoint, endPoint, color, fillColor, lineType, readOnly, message) end
|
||||
|
||||
---Creates a circle on the map with a given radius, color, fill color, and outline. <br>
|
||||
---Coalition Ids to be used:
|
||||
--- - -1 All
|
||||
--- - 0 Neutral
|
||||
--- - 1 Red
|
||||
--- - 2 Blue <br>
|
||||
---Id MUST be unique and is shared with the ids used with mark panels. <br>
|
||||
---Likewise trigger.action.removeMark is used to remove shapes created. <br>
|
||||
---center MUST be a vec3 table. {x, y z} <br>
|
||||
---radius is the radius of the circle in meters. <br>
|
||||
---Color format is {r, g, b, a} with values 0 to 1. A red line with 50% alpha would be {1, 0, 0, 0.5} <br>
|
||||
---Color is the color used for the outline around the shape. <br>
|
||||
---Colorfill corresponds to the shading of the shape <br>
|
||||
---LineType corresponds to an enumerator value. LineTypes:
|
||||
--- - 0 No Line
|
||||
--- - 1 Solid
|
||||
--- - 2 Dashed
|
||||
--- - 3 Dotted
|
||||
--- - 4 Dot Dash
|
||||
--- - 5 Long Dash
|
||||
--- - 6 Two Dash <br>
|
||||
---readOnly denotes whether in the future if clients will be allowed to edit or remove the shape. <br>
|
||||
---Message corresponds to a message box that will appear when the shape is added.
|
||||
---@param coalition coalition.side|integer -- The coalition id.
|
||||
---@param id integer -- The unique id.
|
||||
---@param center vec3 -- The center of the circle.
|
||||
---@param radius number -- The radius of the circle.
|
||||
---@param color table -- The color of the outline.
|
||||
---@param fillColor table -- The color used for shading the shape.
|
||||
---@param lineType integer -- The type of the line.
|
||||
---@param readOnly? boolean -- Whether the circle is read only.
|
||||
---@param message? string -- The message to display when the circle is added.
|
||||
function trigger.action.circleToAll(coalition, id, center, radius, color, fillColor, lineType, readOnly, message) end
|
||||
|
||||
---Creates a line on the F10 map from one point to another. <br>
|
||||
---Coalition Ids to be used:
|
||||
--- - -1 All
|
||||
--- - 0 Neutral
|
||||
--- - 1 Red
|
||||
--- - 2 Blue <br>
|
||||
---Id MUST be unique and is shared with the ids used with mark panels. <br>
|
||||
---Likewise trigger.action.removeMark is used to remove shapes created. <br>
|
||||
---startPoint and endPoint MUST be a vec3 table. {x, y z} <br>
|
||||
---Color format is {r, g, b, a} with values 0 to 1. A red line with 50% alpha would be {1, 0, 0, 0.5} <br>
|
||||
---LineType corresponds to an enumerator value. LineTypes:
|
||||
--- - 0 No Line
|
||||
--- - 1 Solid
|
||||
--- - 2 Dashed
|
||||
--- - 3 Dotted
|
||||
--- - 4 Dot Dash
|
||||
--- - 5 Long Dash
|
||||
--- - 6 Two Dash <br>
|
||||
---readOnly denotes whether in the future if clients will be allowed to edit or remove the shape. <br>
|
||||
---Message corresponds to a message box that will appear when the shape is added.
|
||||
---@param coalition coalition.side|integer -- The coalition id.
|
||||
---@param id integer -- The unique id.
|
||||
---@param startPoint vec3 -- The start point of the line.
|
||||
---@param endPoint vec3 -- The end point of the line.
|
||||
---@param color table -- The color of the line.
|
||||
---@param lineType integer -- The type of the line.
|
||||
---@param readOnly? boolean -- Whether the line is read only.
|
||||
---@param message? string -- The message to display when the line is added.
|
||||
function trigger.action.lineToAll(coalition, id, startPoint, endPoint, color, lineType, readOnly, message) end
|
||||
|
||||
---Creates a shape defined by the 4 points on the F10 map. <br>
|
||||
---Coalition Ids to be used:
|
||||
--- - -1 All
|
||||
--- - 0 Neutral
|
||||
--- - 1 Red
|
||||
--- - 2 Blue <br>
|
||||
---Id MUST be unique and is shared with the ids used with mark panels. <br>
|
||||
---Likewise trigger.action.removeMark is used to remove shapes created. <br>
|
||||
---Each point MUST be a vec3 table. {x, y z} <br>
|
||||
---Color format is {r, g, b, a} with values 0 to 1. A red line with 50% alpha would be {1, 0, 0, 0.5} <br>
|
||||
---Color is the color used for the outline around the shape. <br>
|
||||
---Colorfill corresponds to the shading of the shape <br>
|
||||
---LineType corresponds to an enumerator value. LineTypes:
|
||||
--- - 0 No Line
|
||||
--- - 1 Solid
|
||||
--- - 2 Dashed
|
||||
--- - 3 Dotted
|
||||
--- - 4 Dot Dash
|
||||
--- - 5 Long Dash
|
||||
--- - 6 Two Dash <br>
|
||||
---readOnly denotes whether in the future if clients will be allowed to edit or remove the shape. <br>
|
||||
---Message corresponds to a message box that will appear when the shape is added.
|
||||
---@param coalition coalition.side|integer -- The coalition id.
|
||||
---@param id integer -- The unique id.
|
||||
---@param point1 vec3 -- The first point of the shape.
|
||||
---@param point2 vec3 -- The second point of the shape.
|
||||
---@param point3 vec3 -- The third point of the shape.
|
||||
---@param point4 vec3 -- The fourth point of the shape.
|
||||
---@param color table -- The color of the outline.
|
||||
---@param fillColor table -- The color used for shading the shape.
|
||||
---@param lineType integer -- The type of the line.
|
||||
---@param readOnly? boolean -- Whether the shape is read only.
|
||||
---@param message? string -- The message to display when the shape is added.
|
||||
function trigger.action.quadToAll(coalition, id, point1, point2, point3, point4, color, fillColor, lineType, readOnly, message) end
|
||||
|
||||
---Creates a rectangle on the map from the startpoint in one corner to the endPoint in the opposite corner. <br>
|
||||
---Coalition Ids to be used:
|
||||
--- - -1 All
|
||||
--- - 0 Neutral
|
||||
--- - 1 Red
|
||||
--- - 2 Blue <br>
|
||||
---Id MUST be unique and is shared with the ids used with mark panels. <br>
|
||||
---Likewise trigger.action.removeMark is used to remove shapes created. <br>
|
||||
---startPoint and endPoint MUST be a vec3 table. {x, y z} <br>
|
||||
---Color format is {r, g, b, a} with values 0 to 1. A red line with 50% alpha would be {1, 0, 0, 0.5} <br>
|
||||
---Color is the color used for the outline around the shape. <br>
|
||||
---Colorfill corresponds to the shading of the shape <br>
|
||||
---LineType corresponds to an enumerator value. LineTypes:
|
||||
--- - 0 No Line
|
||||
--- - 1 Solid
|
||||
--- - 2 Dashed
|
||||
--- - 3 Dotted
|
||||
--- - 4 Dot Dash
|
||||
--- - 5 Long Dash
|
||||
--- - 6 Two Dash <br>
|
||||
---readOnly denotes whether in the future if clients will be allowed to edit or remove the shape. <br>
|
||||
---Message corresponds to a message box that will appear when the shape is added.
|
||||
---@param coalition coalition.side|integer -- The coalition id.
|
||||
---@param id integer -- The unique id.
|
||||
---@param startPoint vec3 -- The start point of the rectangle.
|
||||
---@param endPoint vec3 -- The end point of the rectangle.
|
||||
---@param color table -- The color of the outline.
|
||||
---@param fillColor table -- The color used for shading the shape.
|
||||
---@param lineType integer -- The type of the line.
|
||||
---@param readOnly? boolean -- Whether the rectangle is read only.
|
||||
---@param message? string -- The message to display when the rectangle is added.
|
||||
function trigger.action.rectToAll(coalition, id, startPoint, endPoint, color, fillColor, lineType, readOnly, message) end
|
||||
|
||||
---Adds a mark point to all on the F10 map with attached text. <br>
|
||||
---2.5 added the two new variables of readOnly and message. Read only if true will make it so users cannot remove the mark. Message is a message that is displayed when a mark is added. Set to for no message to be added.
|
||||
---@param id integer -- The id of the mark point.
|
||||
---@param text string -- The text to attach to the mark point.
|
||||
---@param vec3 table -- The 3D vector representing the position of the mark point.
|
||||
---@param readOnly? boolean -- Whether the mark point is read only.
|
||||
---@param message? string -- The message to display when a mark is added.
|
||||
function trigger.action.markToAll(id, text, vec3, readOnly, message) end
|
||||
|
||||
---Adds a mark point to a coalition on the F10 map with attached text. <br>
|
||||
---2.5 added the two new variables of readOnly and message. Read only if true will make it so users cannot remove the mark. Message is a message that is displayed when a mark is added. Set to for no message to be added.
|
||||
---@param id integer -- The id of the mark point.
|
||||
---@param text string -- The text to attach to the mark point.
|
||||
---@param vec3 vec3 -- The 3D vector representing the position of the mark point.
|
||||
---@param coalition coalition.side -- The id of the coalition.
|
||||
---@param readOnly boolean? -- Whether the mark point is read only.
|
||||
---@param message string? -- The message to display when a mark is added.
|
||||
function trigger.action.markToCoalition(id, text, vec3, coalition, readOnly, message) end
|
||||
|
||||
---Adds a mark point to a group on the F10 map with attached text. <br>
|
||||
---2.5 added the two new variables of readOnly and message. Read only if true will make it so users cannot remove the mark. Message is a message that is displayed when a mark is added. Set to for no message to be added.
|
||||
---@param id integer -- The id of the mark point.
|
||||
---@param text string -- The text to attach to the mark point.
|
||||
---@param vec3 table -- The 3D vector representing the position of the mark point.
|
||||
---@param groupId number -- The id of the group.
|
||||
---@param readOnly? boolean -- Whether the mark point is read only.
|
||||
---@param message? string -- The message to display when a mark is added.
|
||||
function trigger.action.markToGroup(id, text, vec3, groupId, readOnly, message) end
|
||||
|
||||
---Plays a sound file to all players on the specified coalition. The sound file must be placed inside of the miz file in order to be played.
|
||||
---@param coalition coalition.side -- The coalition of players.
|
||||
---@param soundfile string -- The sound file to play.
|
||||
function trigger.action.outSoundForCoalition(coalition, soundfile) end
|
||||
|
||||
---Plays a sound file to all players in the specified group. Group is specified by their groupId. The sound file must be placed inside of the miz file in order to be played.
|
||||
---@param groupId integer -- The id of the group.
|
||||
---@param soundfile string -- The sound file to play.
|
||||
function trigger.action.outSoundForGroup(groupId, soundfile) end
|
||||
|
||||
---Displays the passed string of text for the specified time to all players.
|
||||
---@param text string -- The text to be displayed to all players.
|
||||
---@param displayTime number -- The duration for which the text will be displayed.
|
||||
---@param clearview? boolean -- Defines whether or not to use the old message display format which overwrites existing messages.
|
||||
function trigger.action.outText(text, displayTime, clearview) end
|
||||
|
||||
---Displays the passed string of text for the specified time to all players belonging to the specified coalition.
|
||||
---@param coalition coalition.side -- The coalition of players.
|
||||
---@param text string -- The text to display.
|
||||
---@param displayTime number -- The time to display the text.
|
||||
---@param clearview? boolean -- Whether to use the old message display format.
|
||||
function trigger.action.outTextForCoalition(coalition, text, displayTime, clearview) end
|
||||
|
||||
---Displays the passed string of text for the specified time to all players in the specified group.
|
||||
---@param groupId integer -- The id of the group to which the text will be displayed.
|
||||
---@param text string -- The text to be displayed to the group.
|
||||
---@param displayTime number -- The duration for which the text will be displayed.
|
||||
---@param clearview? boolean -- Defines whether or not to use the old message display format which overwrites existing messages.
|
||||
function trigger.action.outTextForGroup(groupId, text, displayTime, clearview) end
|
||||
|
||||
--- Removes a mark panel from the F10 map.
|
||||
--- @param id integer
|
||||
function trigger.action.removeMark(id) end
|
||||
|
||||
---Updates the position of a mark that was defined at the first point given to create it. Can be used to "move" an existing mark from one place to the next without deleting it and creating a new one.
|
||||
---@param id integer -- The unique id of the mark to be updated.
|
||||
---@param vec3 table -- The new position for the mark in the form of a vec3 table {x, y, z}.
|
||||
function trigger.action.setMarkupPositionStart(id, vec3) end
|
||||
|
||||
---Updates the color of the specified mark to be the new value.
|
||||
---@param id integer -- The unique id of the mark to be updated.
|
||||
---@param color table -- The new color for the mark. Color format is {r, g, b, alpha} with values ranging from 0 to 1.
|
||||
function trigger.action.setMarkupColor(id, color) end
|
||||
|
||||
---Updates the colorfill of the specified mark to be the new value. Color format is {r, g, b, alpha} with values ranging from 0 to 1.
|
||||
---@param id number -- The id of the mark.
|
||||
---@param colorFill table -- The new colorfill for the mark.
|
||||
function trigger.action.setMarkupColorFill(id, colorFill) end
|
||||
|
||||
---Updates the text value of the passed mark to the passed text value. If the id of the passed mark does not have any text then nothing will happen.
|
||||
---@param id integer -- The unique id of the mark to be updated.
|
||||
---@param text string -- The new text value for the mark.
|
||||
function trigger.action.setMarkupText(id, text) end
|
||||
|
||||
---Creates a text imposed on the map at a given point. Text scales with the map.
|
||||
---@param coalition coalition.side|integer -- Coalition Ids to be used. -1 for All, 0 for Neutral, 1 for Red, 2 for Blue.
|
||||
---@param id integer -- Id MUST be unique and is shared with the ids used with mark panels. Likewise trigger.action.removeMark is used to remove shapes created.
|
||||
---@param point vec3 -- Point MUST be a vec3 table. {x, y z}
|
||||
---@param color table -- Color format is {r, g, b, a} with values 0 to 1. A red line with 50% alpha would be {1, 0, 0, 0.5}. It defines the color of the text to be displayed.
|
||||
---@param fillColor table -- colorFill will be the color of a rectangle over the area that the text covers.
|
||||
---@param fontSize number -- Size of the font to be used.
|
||||
---@param readOnly boolean -- readOnly denotes whether in the future if clients will be allowed to edit or remove the shape.
|
||||
---@param text string -- text corresponds to the message that is displayed on the map.
|
||||
function trigger.action.textToAll(coalition, id, point, color, fillColor, fontSize, readOnly, text) end
|
||||
|
||||
---@class trigger.misc
|
||||
trigger.misc = {}
|
||||
|
||||
---Returns the value of a user flag.
|
||||
---@param flagNumOrName string -- The number or name of the user flag.
|
||||
---@return integer -- The value of the user flag.
|
||||
function trigger.misc.getUserFlag(flagNumOrName) end
|
||||
|
||||
---Returns a trigger zone table of a given name.
|
||||
---@param zoneName string -- The name of the trigger zone.
|
||||
---@return zone -- The trigger zone table. Format: { point = vec3, radius = distance }
|
||||
function trigger.misc.getZone(zoneName) end
|
||||
|
||||
---Sets a user flag to the specified value.
|
||||
---@param flagNumOrName string -- The number or name of the user flag.
|
||||
---@param userFlagValue boolean|integer -- The value to set the user flag to.
|
||||
function trigger.action.setUserFlag(flagNumOrName, userFlagValue) end
|
||||
35
library/mission/types.lua
Normal file
35
library/mission/types.lua
Normal file
@ -0,0 +1,35 @@
|
||||
---@meta
|
||||
|
||||
---Object being called when a event handler is triggered.<br>
|
||||
---Depending on the event, the object may have different fields.<br>
|
||||
---@class event
|
||||
---@field id integer
|
||||
---@field time number
|
||||
---@field initiator Unit?
|
||||
---@field weapon Weapon?
|
||||
---@field weapon_name string?
|
||||
---@field target Unit?
|
||||
---@field comment string?
|
||||
---@field subPlace number?
|
||||
|
||||
---`vec2.x = vec3.x = north`<br>`vec2.y = vec3.z = east`
|
||||
---@class vec2
|
||||
---@field x number positive x is north
|
||||
---@field y number positive y is east
|
||||
|
||||
---`vec3.x = north`<br>`vec3.y = up`<br>`vec3.z = east`
|
||||
---@class vec3
|
||||
---@field x number positive x is north
|
||||
---@field y number positive y is up
|
||||
---@field z number positive z is east
|
||||
|
||||
---A table describing how a unit's local nose, up, right axes translate to world axes using three unit vectors. Also contains its location.<br>`pos.x = vec3` unit vector of nose direction<br>`pos.y = vec3` unit vector of up direction<br>`pos.z = vec3` unit vector of right direction<br>`pos.p = vec3` location of the object
|
||||
---@class pos3
|
||||
---@field x vec3 nose unit vector
|
||||
---@field y vec3 up unit vector
|
||||
---@field z vec3 right unit vector
|
||||
---@field p vec3 location vector
|
||||
|
||||
---@class zone
|
||||
---@field point vec3
|
||||
---@field radius number
|
||||
79
library/mission/unit.lua
Normal file
79
library/mission/unit.lua
Normal file
@ -0,0 +1,79 @@
|
||||
---@meta
|
||||
|
||||
---@class Unit: CoalitionObject
|
||||
---@field id_ integer
|
||||
Unit = {}
|
||||
---@enum Unit.Category
|
||||
Unit.Category = {
|
||||
AIRPLANE = 0,
|
||||
HELICOPTER = 1,
|
||||
GROUND_UNIT = 2,
|
||||
SHIP = 3,
|
||||
STRUCTURE = 4
|
||||
}
|
||||
|
||||
---Returns the unit object by its name (not player name)
|
||||
---@param name string
|
||||
---@return Unit
|
||||
function Unit.getByName(name) end
|
||||
|
||||
|
||||
---Returns an ammo table for all types of loaded ammunition on a given object.
|
||||
---@return table -- Ammo table is indexed by ammo type and contains a weapon description table and a count variable defining "how many" is on board.
|
||||
function Unit:getAmmo() end
|
||||
|
||||
---Returns a localized string of the unit's callsign.<br>
|
||||
---In the case of airbases, the callsign of world airbases is defined by the game. Callsigns for units, farps, or ships can be specified by the user with the mission editor or scripting engine.
|
||||
---@return string
|
||||
function Unit:getCallsign() end
|
||||
|
||||
---Returns the controller of the specified object. <br>
|
||||
---Ships and ground units can only be controlled at a group level. Airplanes and helicopters can be controlled at both a group and unit level.
|
||||
---@return Controller
|
||||
function Unit:getController() end
|
||||
|
||||
---Returns the current value for an animation argument on the external model of the given object.<br>
|
||||
---Each model animation has an id tied to with different values representing different states of the model.<br>
|
||||
---Animation arguments can be figured out by opening the respective 3d model in the modelviewer.<br>
|
||||
---For example, you can determine the rotation and orientation of the barrel of a Tank's cannon by checking its animation arguments.<br>
|
||||
---More practically, you can determine whether or not a helicopter's doors are open.<br>
|
||||
---If draw argument value is invalid for the unit in question a value of 0 will be returned.<br>
|
||||
---@param arg integer
|
||||
---@return number
|
||||
function Unit:getDrawArgumentValue(arg) end
|
||||
|
||||
---Returns the Group object that the Unit belongs to.
|
||||
---@return Group
|
||||
function Unit:getGroup() end
|
||||
|
||||
---Returns the current "life" of a unit, also referred to as "hit points".<br>
|
||||
---All units in DCS have a value that defines how much life is left.<br>
|
||||
---If this value is less than 1 the unit is considered "dead".<br>
|
||||
---Ground and ship units that are on fire and in the process of "cooking off" will return a life value of 0 until the object explodes.<br>
|
||||
---Aircraft are more complex due to sub-systems and damage models which will effect the life value.<br><br>
|
||||
---The following example will show the percentage of life left for a given unit. :<br>
|
||||
---```
|
||||
---local tank = Unit.getByName('tank1')
|
||||
---local life = tank:getLife()/tank:getLife0()
|
||||
---```
|
||||
---@return number
|
||||
function Unit:getLife() end
|
||||
|
||||
---Returns the initial life value of a unit.<br>
|
||||
---All units spawn with "max HP" and this value will never change.<br>
|
||||
---Can be used with Unit.getLife() to determine the percentage of a unit's life as each unit has a unique life value.<br><br>
|
||||
---The following example will show the percentage of life left for a given unit. :<br>
|
||||
---```
|
||||
---local tank = Unit.getByName('tank1')
|
||||
---local life = tank:getLife()/tank:getLife0()
|
||||
---```
|
||||
---@return number
|
||||
function Unit:getLife0() end
|
||||
|
||||
---Returns a string value of the name of the player if the unit is currently controlled by a player.
|
||||
---@return string -- The name of the player controlling the unit, or nil if the unit is controlled by AI.
|
||||
function Unit:getPlayerName() end
|
||||
|
||||
---Returns a boolean value if the unit is activated. Units set to late activation would return false if checked by this function.
|
||||
---@return boolean
|
||||
function Unit:isActive() end
|
||||
62
library/mission/weapon.lua
Normal file
62
library/mission/weapon.lua
Normal file
@ -0,0 +1,62 @@
|
||||
---@meta
|
||||
|
||||
---@class Weapon: CoalitionObject
|
||||
Weapon = {}
|
||||
|
||||
---@enum Weapon.Category
|
||||
Weapon.Category = {
|
||||
SHELL = 0,
|
||||
MISSILE = 1,
|
||||
ROCKET = 2,
|
||||
BOMB = 3,
|
||||
}
|
||||
|
||||
---@enum Weapon.GuidanceType
|
||||
Weapon.GuidanceType = {
|
||||
INS = 1,
|
||||
IR = 2,
|
||||
RADAR_ACTIVE = 3,
|
||||
RADAR_SEMI_ACTIVE = 4,
|
||||
RADAR_PASSIVE = 5,
|
||||
TV = 6,
|
||||
LASER = 7,
|
||||
TELE = 8
|
||||
}
|
||||
|
||||
---@enum Weapon.MissileCategory
|
||||
Weapon.MissileCategory = {
|
||||
AAM = 1,
|
||||
SAM = 2,
|
||||
BM = 3,
|
||||
ANTI_SHIP = 4,
|
||||
CRUISE = 5,
|
||||
OTHER = 6
|
||||
}
|
||||
|
||||
---@enum Weapon.WarheadType
|
||||
Weapon.WarheadType = {
|
||||
AP = 0,
|
||||
HE = 1,
|
||||
SHAPED_EXPLOSIVE = 2
|
||||
}
|
||||
|
||||
---@class WeaponDesc: ObjectDesc
|
||||
---@field category Weapon.Category
|
||||
---@field warhead WeaponDesc.warhead
|
||||
|
||||
---@class WeaponDesc.warhead
|
||||
---@field explosiveMass number?
|
||||
---@field type Weapon.WarheadType?
|
||||
---@field caliber number?
|
||||
---@field mass number
|
||||
|
||||
---Returns the Unit object that had launched the weapon.
|
||||
---@return Unit
|
||||
function Weapon:getLauncher() end
|
||||
|
||||
---Returns the target object that the weapon is guiding to.
|
||||
---@return Object
|
||||
function Weapon:getTarget() end
|
||||
|
||||
---@return WeaponDesc
|
||||
function Weapon:getDesc() end
|
||||
240
library/mission/world.lua
Normal file
240
library/mission/world.lua
Normal file
@ -0,0 +1,240 @@
|
||||
---@meta
|
||||
---@class world
|
||||
---@field eventHandlers table
|
||||
world = {}
|
||||
---@enum world.event
|
||||
world.event = {
|
||||
S_EVENT_INVALID = 0,
|
||||
S_EVENT_SHOT = 1,
|
||||
S_EVENT_HIT = 2,
|
||||
S_EVENT_TAKEOFF = 3,
|
||||
S_EVENT_LAND = 4,
|
||||
S_EVENT_CRASH = 5,
|
||||
S_EVENT_EJECTION = 6,
|
||||
S_EVENT_REFUELING = 7,
|
||||
S_EVENT_DEAD = 8,
|
||||
S_EVENT_PILOT_DEAD = 9,
|
||||
S_EVENT_BASE_CAPTURED = 10,
|
||||
S_EVENT_MISSION_START = 11,
|
||||
S_EVENT_MISSION_END = 12,
|
||||
S_EVENT_TOOK_CONTROL = 13,
|
||||
S_EVENT_REFUELING_STOP = 14,
|
||||
S_EVENT_BIRTH = 15,
|
||||
S_EVENT_HUMAN_FAILURE = 16,
|
||||
S_EVENT_DETAILED_FAILURE = 17,
|
||||
S_EVENT_ENGINE_STARTUP = 18,
|
||||
S_EVENT_ENGINE_SHUTDOWN = 19,
|
||||
S_EVENT_PLAYER_ENTER_UNIT = 20,
|
||||
S_EVENT_PLAYER_LEAVE_UNIT = 21,
|
||||
S_EVENT_PLAYER_COMMENT = 22,
|
||||
S_EVENT_SHOOTING_START = 23,
|
||||
S_EVENT_SHOOTING_END = 24,
|
||||
S_EVENT_MARK_ADDED = 25,
|
||||
S_EVENT_MARK_CHANGE = 26,
|
||||
S_EVENT_MARK_REMOVED = 27,
|
||||
S_EVENT_KILL = 28,
|
||||
S_EVENT_SCORE = 29,
|
||||
S_EVENT_UNIT_LOST = 30,
|
||||
S_EVENT_LANDING_AFTER_EJECTION = 31,
|
||||
S_EVENT_PARATROOPER_LENDING = 32,
|
||||
S_EVENT_DISCARD_CHAIR_AFTER_EJECTION = 33,
|
||||
S_EVENT_WEAPON_ADD = 34,
|
||||
S_EVENT_TRIGGER_ZONE = 35,
|
||||
S_EVENT_LANDING_QUALITY_MARK = 36,
|
||||
S_EVENT_BDA = 37,
|
||||
S_EVENT_AI_ABORT_MISSION = 38,
|
||||
S_EVENT_DAYNIGHT = 39,
|
||||
S_EVENT_FLIGHT_TIME = 40,
|
||||
S_EVENT_PLAYER_SELF_KILL_PILOT = 41,
|
||||
S_EVENT_PLAYER_CAPTURE_AIRFIELD = 42,
|
||||
S_EVENT_EMERGENCY_LANDING = 43,
|
||||
S_EVENT_UNIT_CREATE_TASK = 44,
|
||||
S_EVENT_UNIT_DELETE_TASK = 45,
|
||||
S_EVENT_SIMULATION_START = 46,
|
||||
S_EVENT_WEAPON_REARM = 47,
|
||||
S_EVENT_WEAPON_DROP = 48,
|
||||
S_EVENT_UNIT_TASK_TIMEOUT = 49,
|
||||
S_EVENT_UNIT_TASK_STAGE = 50,
|
||||
S_EVENT_MAC_SUBTASK_SCORE = 51,
|
||||
S_EVENT_MAC_EXTRA_SCORE = 52,
|
||||
S_EVENT_MISSION_RESTART = 53,
|
||||
S_EVENT_MISSION_WINNER = 54,
|
||||
S_EVENT_POSTPONED_TAKEOFF = 55,
|
||||
S_EVENT_POSTPONED_LAND = 56,
|
||||
S_EVENT_MAX = 57,
|
||||
}
|
||||
|
||||
---@enum world.VolumeType
|
||||
world.VolumeType = {
|
||||
SEGMENT = 0,
|
||||
BOX = 1,
|
||||
SPHERE = 2,
|
||||
PYRAMID = 3
|
||||
}
|
||||
|
||||
---@enum world.BirthPlace
|
||||
world.BirthPlace = {
|
||||
wsBirthPlace_Air = 1,
|
||||
wsBirthPlace_Ship = 3,
|
||||
wsBirthPlace_RunWay = 4,
|
||||
wsBirthPlace_Park = 5,
|
||||
wsBirthPlace_Heliport_Hot = 10,
|
||||
wsBirthPlace_Heliport_Cold = 11,
|
||||
wsBirthPlace_Ship_Cold = 12,
|
||||
wsBirthPlace_Ship_Hot = 13
|
||||
}
|
||||
|
||||
---Returns a table of airbase objects belonging to the specified coalition. Objects can be ships, static objects(FARP), or airbases on the map.<br>
|
||||
---When the function is run as world.getAirbases() no input values required, and the function returns all airbases, ships, and farps on the map.<br>
|
||||
---
|
||||
---Example:
|
||||
---The following iterates the returned airbases via world.getAirbases() and stores callsign, id, and other useful information in another table.
|
||||
---```
|
||||
---local base = world.getAirbases()
|
||||
---local myBaseTbl = {}
|
||||
---for i = 1, #base do
|
||||
--- local info = {}
|
||||
--- info.desc = Airbase.getDesc(base[i])
|
||||
--- info.callsign = Airbase.getCallsign(base[i])
|
||||
--- info.id = Airbase.getID(base[i])
|
||||
--- info.cat = Airbase.getCategory(base[i])
|
||||
--- info.point = Airbase.getPoint(base[i])
|
||||
--- if Airbase.getUnit(base[i]) then
|
||||
--- info.unitId = Airbase.getUnit(base[i]):getID()
|
||||
--- end
|
||||
---
|
||||
--- myBaseTbl[info.callsign] = info
|
||||
---end
|
||||
---```
|
||||
---@return table
|
||||
function world.getAirbases() end
|
||||
|
||||
---Returns a table of mark panels and drawn shapes indexed numerically that are present within the mission.<br>
|
||||
---Panel is designed with the mark points in mind, but still returns data for shapes created via markups.<br>
|
||||
---@return table
|
||||
---Return Example: Table indexed numerically.
|
||||
---```
|
||||
---[1] ={
|
||||
--- idx = idxMark(IDMark),
|
||||
--- time = Time,
|
||||
--- initiator = Unit,
|
||||
--- coalition = -1 (or RED/BLUE),
|
||||
--- groupID = -1 (or ID),
|
||||
--- text = markText,
|
||||
--- pos = vec3
|
||||
---}
|
||||
---```
|
||||
function world.getMarkPanels() end
|
||||
|
||||
---Returns a table of the single unit object in the game who's skill level is set as "Player".<br>
|
||||
---There is only a single player unit in a mission and in single player the user will always spawn into this unit automatically unless other client or Combined Arms slots are available.<br>
|
||||
---@return table
|
||||
function world.getPlayer() end
|
||||
|
||||
---Adds a function as an event handler that executes whenever a simulator event occurs.<br>
|
||||
---The most common uses of event handlers are to track statistics of units within a given scenario and to execute code based on certain events occurring.<br>
|
||||
---Handlers are passed event tables which contains numerous data regarding the event.<br>
|
||||
---For examples of the event tables returned, reference the event page on the wiki to get more information regarding the event.<br>
|
||||
---Event Types: shot, hit, takeoff, land, crash, ejection, refueling, dead, pilot_dead, base_captured, mission_start, mission_end, took_control, refueling_stop, birth, human_failure, detailed_failure, engine_startup, engine_shutdown, player_enter_unit, player_leave_unit, player_comment, shooting_start, shooting_end, mark_added, mark_change, mark_remove, kill, score, unit_lost, landing_after_ejection, discard_chair_after_ejection, weapon_add, landing_quality_mark, ai_abort_mission, weapon_drop<br>
|
||||
---
|
||||
---Example:
|
||||
---The following displays a message detailing the event that occurred:
|
||||
---```
|
||||
---local e = {}
|
||||
---function e:onEvent(event)
|
||||
--- local m = {}
|
||||
--- m[#m+1] = "Event ID: "
|
||||
--- m[#m+1] = event.id
|
||||
--- if event.initiator then
|
||||
--- m[#m+1] = "\nInitiator : "
|
||||
--- m[#m+1] = event.initiator:getName()
|
||||
--- end
|
||||
--- if event.weapon then
|
||||
--- m[#m+1] = "\nWeapon : "
|
||||
--- m[#m+1] = event.weapon :getTypeName()
|
||||
--- end
|
||||
--- if event.target then
|
||||
--- m[#m+1] = "\nTarget : "
|
||||
--- m[#m+1] = event.target :getName()
|
||||
--- end
|
||||
--- trigger.action.outText(table.concat(m), 60)
|
||||
---end
|
||||
---world.addEventHandler(e)
|
||||
---```
|
||||
---@param handler table
|
||||
---@return function
|
||||
function world.addEventHandler(handler) end
|
||||
|
||||
---Removes the specified event handler from handling events.<br>
|
||||
---Use this when an event handler has outlived its usefulness.<br>
|
||||
---@param handler EventHandler
|
||||
---@return function
|
||||
function world.removeEventHandler(handler) end
|
||||
|
||||
---Searches the defined area passed to the function to remove craters, object wreckage, and any other debris within the search volume.<br>
|
||||
---Will not remove wreckage of scenery objects.<br>
|
||||
---See pages for the correct format of each volume type: Volumes: segment, box, sphere, pyramid.<br>
|
||||
---
|
||||
---Example:
|
||||
---The following will remove wreckage, craters, and debris in the zone "trainingAirbase" where there surely will be wreckage, craters, and debris due to skill issues.
|
||||
---```
|
||||
---local sphere = trigger.misc.getZone('trainingAirbase')
|
||||
---sphere.point.y = land.getHeight({x = sphere.point.x, y = sphere.point.z})
|
||||
---local volS = {
|
||||
--- id = world.VolumeType.SPHERE,
|
||||
--- params = {
|
||||
--- point = sphere.point,
|
||||
--- radius = sphere.radius
|
||||
--- }
|
||||
---}
|
||||
---world.removeJunk(volS)
|
||||
---```
|
||||
---@param searchVolume volume
|
||||
---@return number
|
||||
---Return Example: 420
|
||||
function world.removeJunk(searchVolume) end
|
||||
|
||||
---Searches a defined volume of 3d space for the specified objects within it and then can run function on each returned object.<br>
|
||||
---Object category is either a single enum or a table of enums that defines the types of objects that will be searched for.<br>
|
||||
---Search volume is the defined 3d space that will be searched. See pages for the correct format of each volume type: Volumes: segment, box, sphere, pyramid.<br>
|
||||
---Handler is the function that will be run on each object that is found.<br>
|
||||
---Any data is a variable that is passed to the handler function, it can be anything.<br>
|
||||
---
|
||||
---Example:
|
||||
---The following example would populate the table "foundUnits" of any unit found within a sphere defined by the zone "town".
|
||||
---```
|
||||
---local foundUnits = {}
|
||||
---local sphere = trigger.misc.getZone('town')
|
||||
---local volS = {
|
||||
--- id = world.VolumeType.SPHERE,
|
||||
--- params = {
|
||||
--- point = sphere.point,
|
||||
--- radius = sphere.radius
|
||||
--- }
|
||||
---}
|
||||
---
|
||||
---local ifFound = function(foundItem, val)
|
||||
--- foundUnits[#foundUnits + 1] = foundItem:getName()
|
||||
--- return true
|
||||
---end
|
||||
---
|
||||
---world.searchObjects(Object.Category.UNIT, volS, ifFound)
|
||||
---```
|
||||
---@param objectCategory table|enum
|
||||
---@param searchVolume volume
|
||||
---@param Handler function
|
||||
---@param data any
|
||||
---@return table
|
||||
---Return Example: Object
|
||||
function world.searchObjects(objectCategory, searchVolume, Handler, data) end
|
||||
|
||||
---@class EventHandler: table
|
||||
---@field onEvent function
|
||||
|
||||
---@class volume
|
||||
---@field id world.VolumeType
|
||||
---@field params volume.params
|
||||
|
||||
---@class volume.params
|
||||
---@field point vec3
|
||||
---@field radius number
|
||||
3
library/server/DCS.lua
Normal file
3
library/server/DCS.lua
Normal file
@ -0,0 +1,3 @@
|
||||
---@meta
|
||||
|
||||
---@class DCS
|
||||
3
library/server/hook.lua
Normal file
3
library/server/hook.lua
Normal file
@ -0,0 +1,3 @@
|
||||
---@meta
|
||||
|
||||
---@class hook
|
||||
Loading…
x
Reference in New Issue
Block a user