### Lua Mission Start Trigger Example Source: https://commandlua.github.io/assets/Wrappers Demonstrates a Lua script used for mission start triggers. The script must return a boolean to indicate if the trigger condition is met. This is part of the amphibious and operation planner configuration. ```lua function check_mission_start_condition() -- Example logic: return true if a certain condition is met return true end ``` -------------------------------- ### ScenEdit_SetStartTime Function Example Source: https://commandlua.github.io/oldsite/index Demonstrates setting the scenario's start time and duration using ScenEdit_SetStartTime, specifying date, time, and duration. ```lua ScenEdit_SetStartTime({Date="2.12.2007", Time="22.46.23", Duration="60.5:0:0"}) ``` -------------------------------- ### Set Mount Weapon Quantity Method Example Source: https://commandlua.github.io/assets/Wrappers Shows how to use the `setExactWeaponQuantity` method for a mount. This method takes a weapon GUID and a quantity to set the current load of that weapon on the mount. ```lua mount.setExactWeaponQuantity('weapon_guid_123', 50) ``` -------------------------------- ### Replenish Unit with Command Lua Source: https://commandlua.github.io/assets/Examples Demonstrates how to replenish a unit using the ReplenishUnit() function in Command Lua. It shows examples of using default replenishment, specifying a tanker unit by GUID, and replenishing from a set of missions. ```lua local u = ScenEdit_GetUnit({name='MiG-31BM Foxhound', guid='NZZYVJ-0HM0G1F7MPTLQ'}) -- use any available replenishment unit print( u:ReplenishUnit() ) -- use specific replenishment unit print( u:ReplenishUnit({ tanker = 'd5eedc59-2541-4b7a-b540-607e84e579f8'}) ) -- use any available replenishment unit from set of missions print( u:ReplenishUnit({ mission={'test support'}}) ) ``` -------------------------------- ### Get Unit Wrapper Properties Source: https://commandlua.github.io/oldsite/index Retrieves a unit's data using its GUID and iterates through its properties. It demonstrates how to access the list of available fields and print the values of properties starting with 'property_'. ```lua local a = ScenEdit_GetUnit({guid='8269b881-20ce-4f2e-baa0-6823e46d55a4'}) print(a.fields) -- show the values of each of the properties in the 'unit' wrapper for k,v in pairs(a.fields) do if string.find(k,'property_') ~= nil then local t = string.find(v," , ") -- location of first print("\r\n[object] = " .. string.sub(v,2,t-1) ) -- property name print( a[string.sub(v,2,t-1)] ) -- value of property end end ``` -------------------------------- ### Setting Unit Fuel Example (Lua) Source: https://commandlua.github.io/oldsite/index This example shows how to set the fuel quantity for a unit using ScenEdit_SetUnit. It illustrates using both fuel name strings and fuel type codes, and how to specify multiple fuel tanks. ```lua ScenEdit_SetUnit({ ..., fuel = {{ 'GasFuel', 1500 }, { 2001, 8000 }} ... }) ``` -------------------------------- ### Example: Defining an Area with Reference Points (Lua) Source: https://commandlua.github.io/assets/Tables This snippet shows how to define an area using a Lua table containing Reference Point names or GUIDs. This is a common way to specify geographical boundaries in the simulation. ```lua { 'RP-3137', 'RP-3139', 'RP-3136', 'RP-3138' } ``` -------------------------------- ### ScenEdit_GetUnit Example Source: https://commandlua.github.io/assets/Tables This example demonstrates how to retrieve unit information, specifically focusing on the mounts and weapons associated with a unit. It iterates through the mounts and their respective weapons, printing details such as mount name, status, weapon name, and current/default load. ```APIDOC ## ScenEdit_GetUnit ### Description Retrieves detailed information about a specific unit, including its mounts and the weapons attached to those mounts. ### Method LUA Function Call ### Endpoint N/A (Lua function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```lua local u = ScenEdit_GetUnit({name='LST 4001 Osumi', guid='8269b881-20ce-4f2e-baa0-6823e46d55a4'}) print( "Unit Mounts " ) for k,v in pairs(u.mounts) do local s = '' s = s .. k .. " - " .. v.mount_name .. " [ " .. v.mount_status .. ' ]\n' s = s .. "\t[ containing " .. #v.mount_weapons .. " weapon(s) ]\n" for k,v in pairs(v.mount_weapons) do s = s .. "\t\t" .. v.wpn_name .. " with load " .. v.wpn_current .. " of " .. v.wpn_default .. '\r\n' end print(s) end ``` ### Response #### Success Response (200) Returns a table containing unit information, including a `mounts` field. Each mount is a table with `mount_name`, `mount_status`, and a `mount_weapons` table. Each weapon in `mount_weapons` has `wpn_name`, `wpn_current`, and `wpn_default` fields. #### Response Example ```json { "unit_name": "LST 4001 Osumi", "guid": "8269b881-20ce-4f2e-baa0-6823e46d55a4", "mounts": [ { "mount_name": "12.7mm/50 MG", "mount_status": "Operational", "mount_weapons": [ { "wpn_name": "12.7mm/50 MG Burst [10 rnds]", "wpn_current": "10", "wpn_default": "10" } ] } // ... more mounts ] } ``` ``` -------------------------------- ### ScenEdit_SetReferencePoint Function Examples Source: https://commandlua.github.io/oldsite/index Demonstrates the usage of ScenEdit_SetReferencePoint to define reference points within a scenario. It shows examples with basic parameters, additional geographic coordinates, and highlighting options. ```lua ScenEdit_SetReferencePoint({side="United States", name="Downed Pilot", lat=0.5}) ScenEdit_SetReferencePoint({side="United States", name="Downed Pilot", lat=0.5, lon="N50.50.50", highlighted =true}) ScenEdit_SetReferencePoint({side="United States", area={"rp-100","rp-101","rp-102","rp-103","rp-104"}, highlighted =true}) ``` -------------------------------- ### ScenEdit_SetSideOptions Function Example Source: https://commandlua.github.io/oldsite/index Shows an example of using ScenEdit_SetSideOptions to configure side-specific options like awareness and proficiency. ```lua ScenEdit_SetSideOptions('{side='SideA',awareness='OMNI',PROFICIENCY='ace')' ``` -------------------------------- ### ScenEdit_SetUnitDamage Function Example Source: https://commandlua.github.io/oldsite/index Provides an example of using ScenEdit_SetUnitDamage to apply damage to a unit's components, specifying fire status and component types. ```lua ScenEdit_SetUnitDamage({side='SideA', unitname='Ship', fires=1, components={ {'rudder','Medium'}, {'type',type='sensor',1} } }) ``` -------------------------------- ### Set Scenario Start Time with ScenEdit_SetStartTime Source: https://commandlua.github.io/assets/Function_ScenEdit_SetStartTime This function sets the scenario's start date and time. It accepts a table with parameters for Date, Time, Duration, and an optional DateFormat to override the default 'MMDDYYYY' format. The date can be specified in 'MM:DD:YYYY' or 'MM.DD.YYYY' format, time in 'HH:MM:SS' or 'HH.MM.SS', and duration in 'days:hours:minutes'. ```Lua ScenEdit_SetStartTime({ Date = "2.12.2007", Time = "22.46.23", Duration = "60.5:0:0" }) ``` -------------------------------- ### Function Syntax Example in CommandLua Source: https://commandlua.github.io/assets/Function_UI_SelectUnitsPrompt_OwnSide Demonstrates the basic syntax for defining and using functions in CommandLua. It includes explanations of parameters and return values. ```CommandLua -- Function Syntax ( ... ) -- The function purpose -- Parameters -- * List the parameters as in the Syntax line -- Returns -- * Show the return value(s) -- Example -- Show an example of how to use the function. Explain it or add multiple examples to expand it ``` -------------------------------- ### Get Contact Details using VP_GetContact (Lua) Source: https://commandlua.github.io/assets/Function_VP_GetContact This function retrieves detailed information about a contact unit given its GUID. It's useful for accessing specific contact attributes beyond basic unit details. The example demonstrates how to first get a side, then a specific contact's GUID from that side's contact list, and finally use VP_GetContact to get the detailed contact object. ```lua local side = VP_GetSide( { name ="NATO" } ) local contacts = side.contacts --List Of contacts local con_guid = contacts[12].objectid -- GUID of a specific contact local a_contact = VP_GetContact( { guid = con_guid } ) -- details of contact as distinct to unit details ``` -------------------------------- ### Get and Modify Waypoint Type Source: https://commandlua.github.io/oldsite/index Shows how to retrieve a unit, access its waypoint, and change the waypoint's type. This example retrieves an aircraft, prints its course, gets a specific waypoint by GUID, and then modifies the waypoint type to 'manual plotted-course'. ```lua au = ScenEdit_GetUnit({name='AGM-158A JASSM [Penetrator] #967', guid='46skox-0hmf72m6q6bdj'}) print(au.course) wp = au:getwaypoint({GUID='46SKOX-0HMF72M6Q6L64'}) wp.type = 0 -- This changes the waypoint type, in this case to manual plotted-course waypoint print(wp.type) ``` -------------------------------- ### Get Unit by GUID - Lua Source: https://commandlua.github.io/oldsite/index Retrieves a unit object from the scenario editor using its unique GUID. This function returns detailed information about the specified unit. It requires a valid GUID string as input. ```lua local myUnit = ScenEdit_GetUnit({ guid = 'f4f9e0e0-15c2-4582-8e80-b827c2ec2f56' }) ( myUnit ) >> unit { type = 'Ship', subtype = '3106', name = 'CG 56 San Jacinto', side = 'United States', guid = 'f4f9e0e0-15c2-4582-8e80-b827c2ec2f56', class = 'CG 56 San Jacinto [Ticonderoga Baseline 3, VLS]', proficiency = 'Regular', latitude = '22.3252605703301', longitude = '62.1828983227462', altitude = '0', heading = '0', speed = '10', throttle = 'FullStop', autodetectable = 'False', group = 'Bush CSG', mounts = '25', magazines = '32', unitstate = 'Unassigned', fuelstate = 'None', weaponstate = 'None', } ``` -------------------------------- ### Get and Set Enablers in Lua Source: https://commandlua.github.io/assets/Tables Retrieves and modifies the enabler settings for a given side. This example shows how to get the current enabler status (e.g., GNSS systems) and then update specific enablers, such as disabling GLONASS. ```lua local side = VP_GetSide({side='BLUE'}) print(side.enablers) side.enablers = {GNSS_GLONASS=false} print(side.enablers) ``` -------------------------------- ### VP_GetSides Source: https://commandlua.github.io/oldsite/index Lists all available sides within the current scenario. ```APIDOC ## VP_GetSides ### Description List of sides in the scenario. ### Method Not specified (assumed to be a script function call) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```lua local sides_list = VP_GetSides() ``` ### Response #### Success Response (200) - **Table** - A table containing references to all sides in the scenario, including their name and GUID. #### Response Example (Response example not provided, returns a table of side references) ``` -------------------------------- ### Get Unit Magazine Information Source: https://commandlua.github.io/index Retrieves a specific magazine associated with a unit, identified by its GUID. If the magazine exists on the unit, it is returned. ```Lua Unit.getUnitMagazine(magazineguid) ``` -------------------------------- ### Get Bearing Between Points (Lua) Source: https://commandlua.github.io/oldsite/index Calculates the bearing between two points. Points can be represented by unit/contact GUIDs or latitude/longitude coordinates. ```lua Tool_Bearing('8269b881-20ce-4f2e-baa0-6823e46d55a4','004aa55d-d553-428d-a727-26853737c8f4' ) Tool_Bearing( {latitude='33.1991547589118', longitude='138.376876749942'},'8269b881-20ce-4f2e-baa0-6823e46d55a4' ) ``` -------------------------------- ### Unit Methods Source: https://commandlua.github.io/assets/Wrappers This section details the methods available to interact with and control Unit objects. ```APIDOC ## Unit Methods ### Description Methods that allow for direct interaction with and control of Unit objects within the simulation. ### Path Parameters None ### Query Parameters None ### Request Body None ### Methods #### `delete()` - **Description**: Immediately removes the unit object from the simulation. - **Parameters**: None - **Returns**: None #### `filterOnComponent(type)` - **Description**: Filters the unit's components based on the specified component type. - **Parameters**: - `type` (string) - The type of component to filter by. - **Returns**: A `Component` table. #### `getwaypoint(guid)` - **Description**: Retrieves a Waypoint object based on its GUID. - **Parameters**: - `guid` (string) - The GUID of the waypoint. - **Returns**: A `Waypoint` object. #### `inArea(area)` - **Description**: Checks if the unit is within a defined area. - **Parameters**: - `area` (table) - A table defining the area (e.g., a list of RPs). - **Returns**: `True` or `False`. #### `Launch(launch_state)` - **Description**: Triggers the unit to launch from base or abort a launch. - **Parameters**: - `launch_state` (boolean) - `True` to launch, `False` to abort. - **Returns**: None #### `rangetotarget(contactid)` - **Description**: Calculates the flat distance to a target's contact location. - **Parameters**: - `contactid` (string) - The ID of the target contact. - **Returns**: The calculated distance (number). #### `RTB()` - **Description**: Triggers the unit to return to base or cancels an existing RTB command. - **Parameters**: None - **Returns**: None #### `updateorbit(tle_data)` - **Description**: Updates the orbit for a satellite using TLE data. - **Parameters**: - `tle_data` (table) - A table containing TLE data (e.g., { TLE = "..." }). - **Returns**: None #### `createUnitCargo(type, dbid, customname)` - **Description**: Creates an item in the unit's cargo area. - **Parameters**: - `type` (string) - The type of cargo item. - `dbid` (number) - The database ID of the cargo item. - `customname` (string, optional) - A custom name for the cargo item. - **Returns**: The created cargo object. #### `deleteUnitCargo(guid)` - **Description**: Deletes a cargo item from the unit's cargo area by its GUID. - **Parameters**: - `guid` (string) - The GUID of the cargo item to delete. - **Returns**: `True` if successful, `False` otherwise. #### `deployDippingSonar(deploy_state)` - **Description**: Commands the unit to deploy its dipping sonar. - **Parameters**: - `deploy_state` (boolean) - Should be `True` to deploy. - **Returns**: None ### Request Example ```json { "method": "delete" } ``` ### Response #### Success Response (200) Indicates the method was executed successfully. #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### Create and Update Mission Flight Plans (CommandLua) Source: https://commandlua.github.io/assets/Wrappers Methods for managing mission flight plans. 'createFlightPlans' generates the initial flight plans, while 'updateWPtimes' refreshes waypoint times. ```lua createFlightPlans({}) updateWPtimes() ``` -------------------------------- ### Get Side Object with VP_GetSide - Lua Source: https://commandlua.github.io/assets/Function_VP_GetSide The VP_GetSide function retrieves a 'Side object' based on provided side name or GUID. It is crucial for accessing player-specific side data within the CommandLua environment. Ensure the input table contains either 'side' or 'guid' keys. ```lua local side = VP_GetSide( { Side ='sidea' } ) ``` -------------------------------- ### Standard Mission Options Source: https://commandlua.github.io/assets/Wrappers Retrieves the details and configuration options for a standard mission. ```APIDOC ## GET /websites/commandlua_github_io/mission ### Description Retrieves the details and configuration options for a standard mission. ### Method GET ### Endpoint /websites/commandlua_github_io/mission ### Parameters #### Query Parameters - **guid** (string) - Required - The GUID of the mission to retrieve. ### Response #### Success Response (200) - **aar** (AAR table) - A table of the air-to-air refueling options. READ ONLY - **assignedCargo** (CargoItem array) - Table of CargoItems assigned to be moved by this mission. READ ONLY - **doctrine** (Doctrine object) - READ ONLY - **endtime** (DateTime) - Time mission ends - **guid** (string) - The GUID of the mission. READ ONLY - **isactive** (boolean) - True if mission is currently active - **name** (string) - Name of mission - **OnDeactivateUassign** (boolean) - 'On mission deactivation unassign units' tick box - **OnDeactivateRTB** (boolean) - 'On mission deactivation RTB units' tick box - **OnDeactivateDelete** (boolean) - 'On mission deactivation delete mission' tick box - **side** (string) - Mission belongs to side - **starttime** (DateTime) - Time mission starts - **SISH** (boolean) - 'Scrub if side human' tick box - **targetlist** (string array) - A table of target GUIDs assigned to mission. READ ONLY - **TakeOffTime** (DateTime) - Time mission flights take off - **TimeOnTargetStation** (DateTime) - Time mission expects flights to be at target or on station - **type** (integer) - Mission class (e.g., Strike = 1, Patrol = 2) - **typeS** (string) - Mission class as a string - **unitlist** (string array) - A table of unit GUIDs assigned to mission. READ ONLY - **packagelist** (table) - A table with the missions in a task pool (only if wrapper is a taskpool) - **parentTaskPool** (string) - GUID of the parent taskpool (only if wrapper is a package - **cargomission** (CargoMission object) - A table of the mission specific options. READ ONLY - **ferrymission** (FerryMission object) - A table of the mission specific options. READ ONLY - **mineclearmission** (MineClearMission object) - A table of the mission specific options. READ ONLY - **minemission** (MineMission object) - A table of the mission specific options. READ ONLY - **strikemission** (StrikeMission object) - A table of the mission specific options. READ ONLY - **supportmission** (SupportMission object) - A table of the mission specific options. READ ONLY - **patrolmission** (PatrolMission object) - A table of the mission specific options. READ ONLY #### Response Example ```json { "aar": { ... }, "assignedCargo": [ ... ], "doctrine": { ... }, "endtime": "2023-10-27T10:00:00Z", "guid": "mission-guid-123", "isactive": true, "name": "Sample Mission", "OnDeactivateUassign": false, "OnDeactivateRTB": true, "OnDeactivateDelete": false, "side": "Red", "starttime": "2023-10-27T09:00:00Z", "SISH": false, "targetlist": ["target-guid-abc"], "TakeOffTime": "2023-10-27T08:30:00Z", "TimeOnTargetStation": "2023-10-27T09:30:00Z", "type": 1, "typeS": "Strike", "unitlist": ["unit-guid-xyz"], "packagelist": [], "parentTaskPool": null, "cargomission": null, "ferrymission": null, "mineclearmission": null, "minemission": null, "strikemission": { "strikeType": "Bombing" }, "supportmission": null, "patrolmission": null } ``` ``` -------------------------------- ### Get Unit Mount Magazine Source: https://commandlua.github.io/index Retrieves the magazine attached to a specific mount on a unit, identified by the mount's GUID. Returns the magazine if the mount exists on the unit. ```Lua Unit.getUnitMountMagazine(mountguid) ``` -------------------------------- ### Unit Avoid Cavitation and Ready Time Properties Source: https://commandlua.github.io/index New properties for the Unit wrapper include 'avoidCavitation' for managing cavitation avoidance, 'readytime' for determining readiness, 'unassign' for handling unassignment, and 'oldDamagePercent' for tracking historical damage. ```Lua Unit.avoidCavitation Unit.readytime Unit.unassign Unit.oldDamagePercent ``` -------------------------------- ### Get Range Between Points (Lua) Source: https://commandlua.github.io/oldsite/index Calculates the horizontal distance between two points in nautical miles. Points can be specified by unit/contact GUIDs or latitude/longitude coordinates. ```lua Tool_Range('8269b881-20ce-4f2e-baa0-6823e46d55a4','004aa55d-d553-428d-a727-26853737c8f4' ) Tool_Range( {latitude='33.1991547589118', longitude='138.376876749942'},'8269b881-20ce-4f2e-baa0-6823e46d55a4' ) ``` -------------------------------- ### Get Unit Magazine and Mount Magazine (Lua) Source: https://commandlua.github.io/index2 Retrieves a specific magazine from a unit using its GUID, or the magazine associated with a specific mount point on the unit. These methods are part of the 'Unit' wrapper. ```lua function getUnitMagazine(magazineguid) -- Implementation details not provided in the source text -- This is a placeholder for the actual function signature and behavior. return nil -- Placeholder return value end function getUnitMountMagazine(mountguid) -- Implementation details not provided in the source text -- This is a placeholder for the actual function signature and behavior. return nil -- Placeholder return value end ``` -------------------------------- ### Group and Loadout Management Source: https://commandlua.github.io/assets/Wrappers Endpoints for retrieving group information and managing weapon loadouts. ```APIDOC ## Group ### Description Group details. ### Fields - **doctrine** (Doctrine) - READ ONLY. - **guid** (string) - READ ONLY. - **lead** (string) - Group leader guid. - **name** (string) - Group/unit name. - **side** (string) - Name of the group side (READ ONLY). - **type** (string) - Type of group (READ ONLY). - **unitlist** ({ string, ... }) - A table of unit GUIDs assigned to the group (READ ONLY). ## Loadout ### Description Loadout details. ### Fields - **dbid** (string) - ID from database. - **name** (string) - Name of loadout. - **roles** ({ role, TOD, weather }) - Table of the loadout usage. - **weapons** ({ WeaponLoaded, ... }) - Table of weapons in loadout. ### Method - **setExactWeaponQuantity** (method(guid, quantity)) - Sets the current load of the weapon defined by 'guid' to the value 'quantity'. ``` -------------------------------- ### ScenEdit_SetTime Function Example Source: https://commandlua.github.io/oldsite/index Shows how to set the current scenario time using ScenEdit_SetTime, including date and time parameters. ```lua ScenEdit_SetTime({Date="2.12.2007", Time="22.46.23"}) ``` -------------------------------- ### ScenEdit_SetStartTime Source: https://commandlua.github.io/assets/Function_ScenEdit_SetStartTime Sets the scenario start date and time. Allows for custom date formats and duration. ```APIDOC ## ScenEdit_SetStartTime ### Description This function Sets the scenario start date/time. The default format of the date is MMDDYYYY. It can be changed by using the 'dateformat' parameter. ### Method N/A (Function Call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **table** (object) - Required - Contains scenario date, time, duration, and date format. - **date** (string) - Optional - Scenario start date. Accepted formats: 'MM:DD:YYYY', 'MM.DD.YYYY'. - **time** (string) - Optional - Scenario start time. Accepted formats: 'HH:MM:SS', 'HH.MM.SS'. - **duration** (string) - Optional - Length of scenario in the format 'days:hours:minutes'. - **dateformat** (string) - Optional - Overrides the default date format. Accepted values: "DDMMYYYY", "MMDDYYYY", "YYYYMMDD". ### Request Example ```json { "date": "2.12.2007", "time": "22.46.23", "duration": "60.5:0:0", "dateformat": "MMDDYYYY" } ``` ### Response #### Success Response (200) - **return value** (number) - Scenario start time in seconds. #### Response Example ```json 1197495983 ``` ``` -------------------------------- ### NewUnit Source: https://commandlua.github.io/assets/Selectors Specifies parameters for creating a new unit, including type, name, side, and location. ```APIDOC ## NewUnit ### Description New unit selector. Specifies parameters for creating a new unit, including type, name, side, and location. ### Parameters #### Request Body - **type** (string) - Required - The type of unit (Ship, Sub, Aircraft, Facility, Satellite, Weapon). - **unitname** (string) - Required - The name of the unit. - **side** (string) - Required - The side name or GUID to add unit to. - **dbid** (number) - Required - The database id of the unit. - **latitude** (number) - Optional - Latitude. Not required if a `base` is defined. - **longitude** (number) - Optional - Longitude. Not required if a `base` is defined. - **base** (string) - Optional - Unit base name or GUID where the unit will be 'hosted' (applicable to AIR, SHIP, SUB). - **loadoutid** (number) - Optional - Aircraft database loadout id (applicable to AIR). - **altitude** (number) - Optional - Unit altitude (applicable to AIR). - **depth** (number) - Optional - Unit depth (applicable to SUBMARINE - note no sign). - **orbit** (number) - Optional - Orbit index (applicable to SATELLITE). - **guid** (string) - Optional - Optional custom GUID to override auto one. ``` -------------------------------- ### Get Unit by Side and Name - Lua Source: https://commandlua.github.io/oldsite/index Retrieves a unit object by specifying its side and name. This is useful for targeting specific units when their GUID is not known. It requires the unit's side and name as string inputs. ```lua local myUnit = ScenEdit_GetUnit({ side = 'United States', name = 'CG 56 San Jacinto' }) ( myUnit ) >> unit { type = 'Ship', subtype = '3106', name = 'CG 56 San Jacinto', side = 'United States', guid = 'f4f9e0e0-15c2-4582-8e80-b827c2ec2f56', class = 'CG 56 San Jacinto [Ticonderoga Baseline 3, VLS]', proficiency = 'Regular', latitude = '22.3252605703301', longitude = '62.1828983227462', altitude = '0', heading = '0', speed = '10', throttle = 'FullStop', autodetectable = 'False', group = 'Bush CSG', mounts = '25', magazines = '32', unitstate = 'Unassigned', fuelstate = 'None', weaponstate = 'None', } ``` -------------------------------- ### Doctrine and Event Information Source: https://commandlua.github.io/assets/Wrappers Provides details on weapon release authority doctrine and event configurations. ```APIDOC ## DoctrineWRA ### Description Weapon Release Authority Doctrine options as defined by the combination of target type and weapon. Options cannot be changed through the wrapper. ### Fields - **level** (string) - The doctrine selected (at unit/mission/side) - useful for using GUIDs. - **target_type** (TargetTypeWRA) - Type of applicable target. - **wra_?** ({ WRA }) - The WRA weapon settings for the various weapon systems. ## Event ### Description Event details. ### Fields - **actions** (table) - The details of the actions in the event (READ ONLY). - **conditions** (table) - The details of the conditions in the event (READ ONLY). - **description** (string) - The event description/name. - **details** (table) - The complete details of the event in one table. Includes triggers/conditions/actions (READ ONLY). - **guid** (string) - The event GUID (READ ONLY). - **isActive** (Yes/No) - Indicates if the event is active. - **isRepeatable** (True/False) - Indicates if the event repeats. - **isShown** (True/False) - Indicates if the event shows on the log. - **name** (string) - The event name (currently not used). - **probability** (string) - The event chance to occur (0-100). - **triggers** (table) - The details of the triggers in the event (READ ONLY). ``` -------------------------------- ### Get Point From Bearing Source: https://commandlua.github.io/oldsite/index Calculates a new location based on a starting point, distance, and bearing. It takes a table containing latitude, longitude, distance, and bearing as input and returns a table representing the new point. ```lua local position = World_GetPointFromBearing({latitude = '-37.8307390636104',longitude = '144.932549348204', distance = 12, bearing = 90}) ``` -------------------------------- ### Get Contact Details in Lua Source: https://commandlua.github.io/assets/Tables Retrieves detailed information about a specific contact using its side and GUID. The output includes potential matches for the contact, such as its database ID, category, subtype, type, missile defense capabilities, and name. ```lua local u = ScenEdit_GetContact( { side='united states', guid='Y5QK8V-0HM1KMFEQFV13'} ) print(u.potentialmatches) ``` -------------------------------- ### List Sides in Scenario (Lua) Source: https://commandlua.github.io/oldsite/index Returns a table containing references (name and GUID) for all sides present in the scenario. ```lua VP_GetSides () ``` -------------------------------- ### Get Selected Units and Contacts (Lua) Source: https://commandlua.github.io/assets/Function_ScenEdit_SelectedUnits This function retrieves a list of currently selected units and contacts, returning their names and GUIDs. It is useful for interacting with the user's current selection within the ScenEdit environment. The function takes no parameters. ```lua local selected = ScenEdit_SelectedUnits( ) print(selected.units) -- list of selected units ``` -------------------------------- ### Tool_EmulateNoConsole Source: https://commandlua.github.io/oldsite/index Emulates the behavior of running event code without a console, useful for testing how code behaves in an event context. ```APIDOC ## Tool_EmulateNoConsole ### Description Emulates no console. Useful for running event code in the console and seeing how it behaves as an 'event'. ### Method Not specified (assumed to be a script function call) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **mode** (string) - Optional - Mode for emulation (details not specified). ### Request Example ```lua Tool_EmulateNoConsole() ``` ### Response #### Success Response (200) - **boolean** - Returns true if interactive, false otherwise. #### Response Example (Response example not provided, returns a boolean) ``` -------------------------------- ### Get Contact Emissions in Lua Source: https://commandlua.github.io/assets/Tables Fetches the emission details for a given contact, identified by its side and GUID. This function returns a table containing information about each sensor associated with the contact, including its role, database ID, type, maximum range, name, and age. ```lua local u = ScenEdit_GetContact({side='united states',guid='Y5QK8V-0HM1KMFEQFV13'}) print(u.emissions) ``` -------------------------------- ### Calculate Distance Between Points with Tool_Range (Lua) Source: https://commandlua.github.io/assets/Function_Tool_Range This Lua code snippet demonstrates the usage of the Tool_Range function to calculate distances between different types of points. It shows calculations using GUIDs, latitude/longitude objects, and includes an example for calculating slant distance by providing the 'useSlant' parameter. ```lua local d = Tool_Range('8269b881-20ce-4f2e-baa0-6823e46d55a4', '004aa55d-d553-428d-a727-26853737c8f4' ) local d = Tool_Range( { latitude='33.1991547589118', longitude='138.376876749942' }, '8269b881-20ce-4f2e-baa0-6823e46d55a4') -- variable f and t are two units to measure distance from local fromHereT = {lat = f.latitude, lon = f.longitude, alt = f.altitude} local toHereT = {lat = t.latitude, lon = t.longitude, alt = t.altitude} print(fromHereT); print(toHereT); local r = Tool_Range(fromHereT, toHereT ) print('Horizontal = ' .. r .. ' NM') local s = Tool_Range(fromHereT, toHereT, true) print('Slant = ' .. s .. ' NM') ``` -------------------------------- ### Unpause Simulation with VP_RunSimulation Source: https://commandlua.github.io/assets/Function_VP_RunSimulation The VP_RunSimulation function is used to unpause the simulation, effectively pressing the 'play' button. This function is exclusive to PRO users and requires no parameters. It does not return any values. ```lua VP_RunSimulation( ) ``` -------------------------------- ### VPContactSelector API Source: https://commandlua.github.io/assets/Selectors Selects a contact based on its GUID. Contact GUIDs are distinct from unit GUIDs. ```APIDOC ## VPContactSelector ### Description Select a contact using its GUID. ### Method GET (assumed, as it retrieves information) ### Endpoint `/websites/commandlua_github_io/api/contact/select` (example endpoint) ### Parameters #### Path Parameters None #### Query Parameters - **guid** (string) - Required - The GUID of the contact. **Note:** A unit and its contact GUIDs are different for the same physical unit. ### Request Example ```json { "guid": "contact-guid-abc123" } ``` ### Response #### Success Response (200) - **contactId** (string) - The identifier of the selected contact. #### Response Example ```json { "contactId": "contact-guid-abc123" } ``` ``` -------------------------------- ### Weapon State Management Source: https://commandlua.github.io/assets/Wrappers Endpoints for managing weapon states like RTB initiation, withdrawal conditions, and target priority. ```APIDOC ## Weapon State Definitions ### `weapon_state_rtb` **Description:** Action to take when RTB (Return To Base) is initiated due to weapons. ### `withdraw_on_attack` **Description:** Level of attacking weapons to cause withdrawal. **Values:** - `valueIgnore = 0` - `Exhausted = 1` - `Percent25 = 2` - `Percent50 = 3` - `Percent75 = 4` - `Percent100 = 5` ### `withdraw_on_damage` **Description:** Level of damage to cause withdrawal. **Values:** - `valueIgnore = 0` - `Percent5 = 1` - `Percent25 = 2` - `Percent50 = 3` - `Percent75 = 4` ### `withdraw_on_defence` **Description:** Level of defending weapons to cause withdrawal. **Values:** - `valueIgnore = 0` - `Exhausted = 1` - `Percent25 = 2` - `Percent50 = 3` - `Percent75 = 4` - `Percent100 = 5` ### `withdraw_on_fuel` **Description:** Level of fuel to cause withdrawal. **Values:** - `valueIgnore = 0` - `Bingo = 1` - `Percent25 = 2` - `Percent50 = 3` - `Percent75 = 4` - `Percent100 = 5` ## Target Priority Management ### `TargetPriority` **Description:** Represents the target priority list. This is a read-only field. ### `deleteTargetPriorityEntry` **Description:** Deletes an entry from the target priority list. **Method:** `method(listIndex)` **Returns:** `{ TargetPriority }` ### `addTargetPriorityEntry` **Description:** Adds an entry to the target priority list. **Method:** `method(type, subtype, isfixedfacilitysubtype, dbid, listIndex)` **Returns:** `{ TargetPriority }` ``` -------------------------------- ### Get Side Posture - Lua Source: https://commandlua.github.io/assets/Function_ScenEdit_GetSidePosture The ScenEdit_GetSidePosture function retrieves the posture of one side relative to another. It takes two string arguments representing side names or GUIDs and returns a string indicating the posture ('N', 'F', 'H', or 'A'), or an empty string if the posture is unknown. This function is useful for understanding strategic relationships between entities. ```lua local u = ScenEdit_GetSidePosture( 'NATO', 'Russia' ) ``` -------------------------------- ### AttackOptions API Source: https://commandlua.github.io/assets/Selectors Defines the parameters for specifying weapon attacks, including targeting mode, mount, weapon, and quantity. ```APIDOC ## AttackOptions ### Description Specifies what weapons to attack with. ### Parameters - **mode** (TargetingMode) - Targeting mode. - **mount** (number) - The attacker's mount DBID. - **weapon** (number) - The attacker's weapon DBID. - **qty** (number) - How many to allocate. ``` -------------------------------- ### Get Unit Information using VP_GetUnit Source: https://commandlua.github.io/assets/Function_VP_GetUnit The VP_GetUnit function retrieves details about an active unit or a contact's actual unit. It accepts a table with parameters like 'side', 'unitname', or 'guid' to identify the target. The function returns a unit wrapper, which represents the actual unit if a contact was specified. Ensure that the provided identifier is valid for the system. ```lua local unit = VP_GetUnit( { guid = 'f4f9e0af-15c2-4582-8e80-b827c2ec2f56' } ) ``` -------------------------------- ### Add Mission Example in Lua Source: https://commandlua.github.io/oldsite/index This Lua code snippet demonstrates how to add a new mission using the ScenEdit_AddMission function. It includes error handling for the mission creation process. The code relies on the ScenEdit_AddMission function and global error variables _errnum_ and _errmsg_. ```lua local mission = ScenEdit_AddMission( 'USA', 'Marker strike', 'strike', { type = 'land' } ) if mission == then if _errnum_ ~= 0 then print( 'Failed to add:' .. _errmsg_ ) else print( 'Something else' ) end else print( mission) end ``` -------------------------------- ### Retrieve Unit Mount Details with Lua Source: https://commandlua.github.io/assets/Examples This script retrieves details about a unit's mounts, including their name and current status. It iterates through each mount and lists the weapons it contains, along with their current and default loads. The script utilizes `ScenEdit_GetUnit` to get unit data and `getUnitMount` to access mount information. Note that the `setExactWeaponQuantity` function is commented out in this snippet. ```lua local u = ScenEdit_GetUnit({name='LST 4001 Osumi', guid='8269b881-20ce-4f2e-baa0-6823e46d55a4'}) print( "Unit Mounts ") for k,v in pairs(u.mounts) do local s = '' local m = u:getUnitMount(v.mount_guid) -- details on mount s = s .. k .. " - " .. m.name .. " [ " .. v.mount_status .. ' ]\r\n' s = s .. "\t[ containing " .. #m.weapons .. " weapon(s) ]\r\n" for k,v in pairs(m.weapons) do s = s .. "\t\t" .. v.wpn_name .. " with load " .. v.wpn_current .. " of " .. v.wpn_default .. '\r\n' --m:setExactWeaponQuantity(v.wpn_guid, v.wpn_default) -- set the current load back to full if any have been expended end print(s) end ``` -------------------------------- ### Get Unit Formation Properties with ScenEdit_GetFormation Source: https://commandlua.github.io/assets/Function_ScenEdit_GetFormation Retrieves the properties of a unit's formation using its side, name, or GUID. This function returns a unit wrapper object containing formation details or nil if the unit is not found. It's important to note that running this interactively might raise an exception if the unit doesn't exist, which can be handled with Tool_EmulateNoConsole(). ```lua local formation = ScenEdit_GetFormation({side='Blue', name='Group 16'}) print(formation) ``` -------------------------------- ### VP_GetScenario Source: https://commandlua.github.io/oldsite/index Retrieves information about the current scenario. ```APIDOC ## VP_GetScenario ### Description Exposes current scenario information. ### Method Not specified (assumed to be a script function call) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```lua local scenario_info = VP_GetScenario() ``` ### Response #### Success Response (200) - **Scenario** (table) - An object containing details about the current scenario. #### Response Example (Response example not provided, returns a Scenario object) ``` -------------------------------- ### Get Time of Day at Location - Lua Source: https://commandlua.github.io/assets/Function_ScenEdit_GetTimeOfDay Retrieves the current time of day for a given location specified by side, unit name, GUID, latitude, or longitude. It returns details like time of day number, local time, Zulu time, and a text representation of the time of day. This function is useful for scenario editing and game logic related to time. ```lua local u = ScenEdit_GetTimeOfDay( {side='NATO', unitname='FFG Dispair'} ) ``` -------------------------------- ### ContactSelector for Units Source: https://commandlua.github.io/oldsite/index Used to select specific contacts associated with a unit. Requires the 'side' and the contact's 'guid'. Contact GUIDs are distinct from unit GUIDs. ```lua -- ContactSelector Example local contactSelector = { side = 'Red', guid = 'contact-guid-for-unit' } -- local contacts = ScenEdit_GetContacts(contactSelector.side) -- Hypothetical function to get contacts -- local selectedContact = SE_SelectContact(contactSelector) -- Hypothetical function to select contact ``` -------------------------------- ### Mount Configuration Source: https://commandlua.github.io/assets/Tables This section describes the properties of a weapon mount, including its database ID, GUID, name, status, and associated weapons. ```APIDOC ## Mount Configuration ### Description Details about a weapon mount, similar to a magazine, referring to the actual loads on a weapon. ### Parameters #### Request Body - **mount_dbid** (string) - Database ID of the mount. - **mount_GUID** (string) - GUID of the mount. - **mount_name** (string) - Name of the mount. - **mount_status** (string) - Current status of the mount (e.g., operational, damaged). - **mount_statusR** (string) - Reason why the mount is inoperative, if applicable. - **mount_damage** (string) - Severity of damage to the mount, if not operational. - **mount_weapons** (WeaponLoaded) - A table containing the weapon loads on the mount. ### Request Example ```json { "mount_dbid": "12345", "mount_GUID": "a1b2c3d4-e5f6-7890-1234-567890abcdef", "mount_name": "Launcher Mount", "mount_status": "Operational", "mount_statusR": null, "mount_damage": null, "mount_weapons": [ { "weapon_name": "Missile", "count": 4 } ] } ``` ### Response #### Success Response (200) - **status** (string) - Indicates if the operation was successful. #### Response Example ```json { "status": "success" } ``` ```