From 677d9a99aa12d87d4cd55d4342736026e0aee605 Mon Sep 17 00:00:00 2001 From: omltcat <6239696+omltcat@users.noreply.github.com> Date: Sun, 7 Jul 2024 16:33:20 -0400 Subject: [PATCH] Add more trigger words. Add Controller:hasTask. Add function net.load_mission, net.load_next_mission, net.get_stat, net.send_chat, net.send_chat_to Add id_ field for all object Add Unit:enableEmission, Unit:getDescentCapacity, Unit:getNearestCargos --- config.json | 5 +++- library/mission/controller.lua | 4 ++++ library/mission/net.lua | 44 +++++++++++++++++++++++++++++++++- library/mission/object.lua | 1 + library/mission/unit.lua | 40 ++++++++++++++++++++++++++++++- 5 files changed, 91 insertions(+), 3 deletions(-) diff --git a/config.json b/config.json index a95ca48..852d5e5 100644 --- a/config.json +++ b/config.json @@ -2,9 +2,12 @@ "$schema": "https://raw.githubusercontent.com/LuaLS/LLS-Addons/main/schemas/addon_config.schema.json", "name": "DCS World", "words": [ + "onEvent", + "world%.addEventHandler", "Unit%.getByName", "Group%.getByName", - "trigger%.action%." + "trigger%.action", + "trigger%.misc" ], "files": [ "mist_.+%.lua", diff --git a/library/mission/controller.lua b/library/mission/controller.lua index 2922d0c..b8c22b5 100644 --- a/library/mission/controller.lua +++ b/library/mission/controller.lua @@ -12,6 +12,10 @@ Controller.Detection = { DLINK = 32 } +---Returns true if the controller currently has a task. +---@return boolean +function Controller:hasTask() end + ---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()`.
---[Available Tasks](https://wiki.hoggitworld.com/view/DCS_func_pushTask) ---@param task table -- The task to be pushed to the front of the queue. diff --git a/library/mission/net.lua b/library/mission/net.lua index ae0d186..6dd03cb 100644 --- a/library/mission/net.lua +++ b/library/mission/net.lua @@ -57,6 +57,23 @@ function net.get_player_list() end ---@return netPlayerInfo -- The table of attributes for the player. function net.get_player_info(playerID, attribute) end +--- Returns a statistic from a given player.
+--- Attributes: +---``` +--- net.PS_PING -- (0) ping (in ms) +--- net.PS_CRASH -- (1) number of crashes +--- net.PS_CAR -- (2) number of destroyed vehicles +--- net.PS_PLANE -- (3) number of destroyed planes/helicopters +--- net.PS_SHIP -- (4) number of destroyed ships +--- net.PS_SCORE -- (5) total score +--- net.PS_LAND -- (6) number of landings +--- net.PS_EJECT -- (7) number of ejects +---``` +--- @param playerID number The ID of the player. +--- @param statID number The ID of the statistic to retrieve. +--- @return number The requested statistic for the specified player. +function net.get_stat(playerID, statID) end + ---Converts a lua value to a JSON string. ---@param lua any ---@return string @@ -71,4 +88,29 @@ function net.json2lua(json) end ---@param playerId integer -- The id of the player to be kicked. ---@param message string? -- The message to player received after kicked. ---@return boolean -function net.kick(playerId, message) end \ No newline at end of file +function net.kick(playerId, message) end + +---Loads the specified mission.
+---Example: Loads a mission from your saved games/missions folder. +---``` +---net.load_mission(lfs.writeDir() .. 'Missions\\' .. 'MyTotallyAwesomeMission.miz') +---``` +---@param fileName string -- The path and name of the mission file to load. +---@return boolean -- True if the mission was successfully loaded, false otherwise. +function net.load_mission(fileName) end + +---Loads the next mission from the server mission list. +---@return boolean -- True if the next mission was successfully loaded, false if at the end of the list. +function net.load_next_mission() end + +---Sends a chat message. +---@param message string +---@param all boolean +function net.send_chat(message, all) end + +---Sends a chat message to the player with the passed id.
+---If the optional fromId is set, then the player will appear to receive a message from that player. +---@param message string +---@param playerId number +---@param fromId number? +function net.send_chat_to(message, playerId, fromId) end \ No newline at end of file diff --git a/library/mission/object.lua b/library/mission/object.lua index ff1cff6..c6d6922 100644 --- a/library/mission/object.lua +++ b/library/mission/object.lua @@ -1,6 +1,7 @@ ---@meta ---@class Object +---@field id_ integer Object = {} ---@enum Object.Category diff --git a/library/mission/unit.lua b/library/mission/unit.lua index 921ee57..0ab7747 100644 --- a/library/mission/unit.lua +++ b/library/mission/unit.lua @@ -1,7 +1,6 @@ ---@meta ---@class Unit: CoalitionObject ----@field id_ integer Unit = {} ---@enum Unit.Category Unit.Category = { @@ -12,6 +11,16 @@ Unit.Category = { STRUCTURE = 4 } +---Sets the radar emitters of the passed group or unit objects on or off.
+---Can be used on SAM sites, for example, to shut down the radar without setting AI off or changing the alarm state.
+---Example: +---``` +---local unit = Unit.getByName('samSiteUnit1') +---unit:enableEmission(false) -- Turns off the radar emitter +---``` +---@param setting boolean -- True to turn on the radar emitter, false to turn it off. +function Unit:enableEmission(setting) end + ---Returns the unit object by its name (not player name) ---@param name string ---@return Unit @@ -32,6 +41,21 @@ function Unit:getCallsign() end ---@return Controller function Unit:getController() end +---Returns the number of infantry that can be embarked onto the aircraft.
+---Only applicable to airplanes or helicopters. Returns nil for ground or ship units.
+---Example: +---``` +---local heli = Unit.getByName('transportHeli') +---local capacity = heli:getDescentCapacity() +---if capacity then +--- print("Capacity to embark infantry: " .. capacity) +---else +--- print("This unit cannot embark infantry.") +---end +---``` +---@return number? -- The number of infantry that can be embarked, or nil if not applicable. +function Unit:getDescentCapacity() end + ---Returns the current value for an animation argument on the external model of the given object.
---Each model animation has an id tied to with different values representing different states of the model.
---Animation arguments can be figured out by opening the respective 3d model in the modelviewer.
@@ -93,6 +117,20 @@ function Unit:getLife() end ---@return number function Unit:getLife0() end +---Returns a table of friendly cargo objects indexed numerically and sorted by distance from the helicopter.
+---Only applicable to helicopters. Returns nil for other unit types.
+---Example: +---``` +---local cargo = Unit.getByName('whoopwhoop'):getNearestCargos() +---for i = 1, #cargo do +--- if Object.getDesc(cargo[i]).typeName == 'ammo_cargo' then +--- return cargo[i] +--- end +---end +---``` +---@return table? -- A table of cargo objects sorted by distance, or nil if not applicable. +function Unit:getNearestCargos() 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