From 1a1de5c9563001eb72973b2e2f50d9bfc4f892a9 Mon Sep 17 00:00:00 2001 From: leniver Date: Thu, 8 Sep 2022 12:02:37 +0200 Subject: [PATCH 01/14] Adding Entity structure --- api-mockup/construct.lua | 4 ++-- api-mockup/radar.lua | 2 +- api-mockup/structures/entity.lua | 12 ++++++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 api-mockup/structures/entity.lua diff --git a/api-mockup/construct.lua b/api-mockup/construct.lua index 1b6850e..ae4902a 100644 --- a/api-mockup/construct.lua +++ b/api-mockup/construct.lua @@ -24,10 +24,10 @@ function Construct() ---@return integer function self.getId() end --- Returns the owner entity - ---@return table entity The owner entity table with fields {[int] id, [bool] isOrganization} describing the owner. Use system.getPlayerName(id) and system.getOrganization(id) to retrieve info about it + ---@return Entity entity The owner entity table with fields {[int] id, [bool] isOrganization} describing the owner. Use system.getPlayerName(id) and system.getOrganization(id) to retrieve info about it function self.getOwner() end --- Returns the creator entity - ---@return integer entity The owner entity table with fields {[int] id, [bool] isOrganization} describing the owner. Use system.getPlayerName(id) and system.getOrganization(id) to retrieve info about it + ---@return Entity entity The owner entity table with fields {[int] id, [bool] isOrganization} describing the owner. Use system.getPlayerName(id) and system.getOrganization(id) to retrieve info about it function self.getCreator() end diff --git a/api-mockup/radar.lua b/api-mockup/radar.lua index d5af670..f0c4e23 100644 --- a/api-mockup/radar.lua +++ b/api-mockup/radar.lua @@ -78,7 +78,7 @@ function Radar() --- Returns a table with id of the owner entity (player or organization) of the given construct, if in range and if active transponder tags match for owned dynamic constructs. ---@param id integer The ID of the construct - ---@return table entity A table with fields {[int] id, [bool] isOrganization} describing the owner. Use system.getPlayerName(id) and system.getOrganization(id) to retrieve info about it + ---@return Entity entity A table with fields {[int] id, [bool] isOrganization} describing the owner. Use system.getPlayerName(id) and system.getOrganization(id) to retrieve info about it function self.getConstructOwnerEntity(id) end ---@deprecated Radar.getConstructOwner(id) is deprecated, use Radar.getConstructOwnerEntity(id) instead. function self.getConstructOwner() error("Radar.getConstructOwner(id) is deprecated, use Radar.getConstructOwnerEntity(id) instead.") end diff --git a/api-mockup/structures/entity.lua b/api-mockup/structures/entity.lua new file mode 100644 index 0000000..f288a8b --- /dev/null +++ b/api-mockup/structures/entity.lua @@ -0,0 +1,12 @@ +-- ################################################################################ +-- # Copyright 2014-2022 Novaquark SAS # +-- ################################################################################ + +----------------------------------------------------------------------------------- +-- Entity +-- +-- Entity represents a player or an organization +----------------------------------------------------------------------------------- +---@class Entity +---@field id integer ID of the entity, Use system.getPlayerName(id) and system.getOrganization(id) to retrieve info about it +---@field isOrganization boolean True if the entity is an organization \ No newline at end of file From 78908d9a7855e8daf4799c88c28656e47b9dc10e Mon Sep 17 00:00:00 2001 From: leniver Date: Thu, 8 Sep 2022 12:13:06 +0200 Subject: [PATCH 02/14] Adding ItemQuantity structure --- api-mockup/container.lua | 2 +- api-mockup/industry.lua | 2 +- api-mockup/structures/itemquantity.lua | 12 ++++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 api-mockup/structures/itemquantity.lua diff --git a/api-mockup/container.lua b/api-mockup/container.lua index be73e52..eb7a9e1 100644 --- a/api-mockup/container.lua +++ b/api-mockup/container.lua @@ -33,7 +33,7 @@ function Container() function self.getMaxVolume() end --- Returns a table describing the contents of the container, as a pair itemId and quantity per slot. - ---@return table content The content of the container as a table with fields {[int] id, [float] quantity} per slot + ---@return ItemQuantity[] content The content of the container as a table with fields {[int] id, [float] quantity} per slot function self.getContent() end ---@deprecated Container.getItemsList() is deprecated, use Container.getContent() instead. function self.getItemsList() error("Container.getItemsList() is deprecated, use Container.getContent() instead.") end diff --git a/api-mockup/industry.lua b/api-mockup/industry.lua index 96242ae..77b576d 100644 --- a/api-mockup/industry.lua +++ b/api-mockup/industry.lua @@ -90,7 +90,7 @@ function Industry() function self.updateBank() end --- Returns a table describing the contents of the schematic bank, as a pair itemId and quantity per slot - ---@return table content The content of the schematic bank as a table with fields {[int] id, [float] quantity} per slot + ---@return ItemQuantity[] content The content of the schematic bank as a table with fields {[int] id, [float] quantity} per slot function self.getBank() end diff --git a/api-mockup/structures/itemquantity.lua b/api-mockup/structures/itemquantity.lua new file mode 100644 index 0000000..2240970 --- /dev/null +++ b/api-mockup/structures/itemquantity.lua @@ -0,0 +1,12 @@ +-- ################################################################################ +-- # Copyright 2014-2022 Novaquark SAS # +-- ################################################################################ + +----------------------------------------------------------------------------------- +-- ItemQuantity +-- +-- ItemQuantity represents an item and its quantity +----------------------------------------------------------------------------------- +---@class ItemQuantity +---@field id integer ID of the item, Use system.getItem(id) to retrieve info about it +---@field quantity number The quantity of this item \ No newline at end of file From 0687055c982de1e1a2bc8fde589e110cbce194c3 Mon Sep 17 00:00:00 2001 From: leniver Date: Thu, 8 Sep 2022 12:33:12 +0200 Subject: [PATCH 03/14] Adding IndustryInfo structure --- api-mockup/coreunit.lua | 2 +- api-mockup/industry.lua | 2 +- api-mockup/structures/industryinfo.lua | 21 +++++++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 api-mockup/structures/industryinfo.lua diff --git a/api-mockup/coreunit.lua b/api-mockup/coreunit.lua index 3282473..e3a29c7 100644 --- a/api-mockup/coreunit.lua +++ b/api-mockup/coreunit.lua @@ -224,7 +224,7 @@ function CoreUnit() --- Returns the status of the Industry Unit Element, identified by its local ID ---@param localId integer The local ID of the Element - ---@return table info If the Element is an Industry Unit, a table with fields {[int] state, [bool] stopRequested, [int] schematicId (deprecated = 0), [int] schematicsRemaining, [int] unitsProduced, [int] remainingTime, [int] batchesRequested, [int] batchesRemaining, [float] maintainProductAmount, [int] currentProductAmount, [table] currentProducts:{{[int] id, [double] quantity},...}} + ---@return IndustryInfo info If the Element is an Industry Unit, a table with fields {[int] state, [bool] stopRequested, [int] schematicId (deprecated = 0), [int] schematicsRemaining, [int] unitsProduced, [int] remainingTime, [int] batchesRequested, [int] batchesRemaining, [float] maintainProductAmount, [int] currentProductAmount, [table] currentProducts:{{[int] id, [double] quantity},...}} function self.getElementIndustryInfoById(localId) end ---@deprecated CoreUnit.getElementIndustryStatusById(localId) is deprecated, use CoreUnit.getElementIndustryInfoById(localId) instead. function self.getElementIndustryStatusById(localId) error("CoreUnit.getElementIndustryStatusById(localId) is deprecated, use CoreUnit.getElementIndustryInfoById(localId) instead.") end diff --git a/api-mockup/industry.lua b/api-mockup/industry.lua index 77b576d..5972068 100644 --- a/api-mockup/industry.lua +++ b/api-mockup/industry.lua @@ -49,7 +49,7 @@ function Industry() function self.getStatus() error("Industry.getStatus() is deprecated, use Industry.getState() instead.") end --- Returns the complete information of the industry - ---@return integer value The complete state of the industry, a table with fields {[int] state, [bool] stopRequested, [int] schematicId (deprecated = 0), [int] schematicsRemaining, [int] unitsProduced, [int] remainingTime, [int] batchesRequested, [int] batchesRemaining, [float] maintainProductAmount, [int] currentProductAmount, [table] currentProducts:{{[int] id, [double] quantity},...}} + ---@return IndustryInfo value The complete state of the industry, a table with fields {[int] state, [bool] stopRequested, [int] schematicId (deprecated = 0), [int] schematicsRemaining, [int] unitsProduced, [int] remainingTime, [int] batchesRequested, [int] batchesRemaining, [float] maintainProductAmount, [int] currentProductAmount, [table] currentProducts:{{[int] id, [double] quantity},...}} function self.getInfo() end --- Get the count of completed cycles since the player started the unit diff --git a/api-mockup/structures/industryinfo.lua b/api-mockup/structures/industryinfo.lua new file mode 100644 index 0000000..6f3cecd --- /dev/null +++ b/api-mockup/structures/industryinfo.lua @@ -0,0 +1,21 @@ +-- ################################################################################ +-- # Copyright 2014-2022 Novaquark SAS # +-- ################################################################################ + +----------------------------------------------------------------------------------- +-- IndustryInfo +-- +-- IndustryInfo represents all information about an industry unit +----------------------------------------------------------------------------------- +---@class IndustryInfo +---@field state integer ID of the item, Use system.getItem(id) to retrieve info about it +---@field stopRequested boolean True if stop a stop has been requested +---@field schematicId integer ---@deprecated +---@field schematicsRemaining integer Number of schematic remaining in the industry unit's bank +---@field unitsProduced integer Number of units produced since the start of the industry unit +---@field remainingTime integer Time until next unit is completed +---@field batchesRequested integer Number of batches requested to be produced +---@field batchesRemaining integer Number of batches remaining to be produced +---@field maintainProductAmount number Amount of unit to maintain in the output container +---@field currentProductAmount number Amount of unit existing in the output container +---@field currentProducts ItemQuantity[] List of items in production From e2a0cd4d49c81f6b6fa1ca6dee7e346ae53cf1b4 Mon Sep 17 00:00:00 2001 From: leniver Date: Thu, 8 Sep 2022 12:43:07 +0200 Subject: [PATCH 04/14] Adding OrePool structure --- api-mockup/miningunit.lua | 2 +- api-mockup/plasmaextractor.lua | 2 +- api-mockup/spaceminingunit.lua | 2 +- api-mockup/structures/orepool.lua | 13 +++++++++++++ 4 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 api-mockup/structures/orepool.lua diff --git a/api-mockup/miningunit.lua b/api-mockup/miningunit.lua index 6beaa2a..1b80d2d 100644 --- a/api-mockup/miningunit.lua +++ b/api-mockup/miningunit.lua @@ -32,7 +32,7 @@ function MiningUnit() function self.getActiveOre() end --- Returns the list of available ore pools - ---@return table pool A list of tables composed with {[int] oreId, [float] available, [float] maximum); + ---@return OrePool[] pool A list of tables composed with {[int] oreId, [float] available, [float] maximum); function self.getOrePools() end --- Returns the base production rate of the mining unit. diff --git a/api-mockup/plasmaextractor.lua b/api-mockup/plasmaextractor.lua index 7dfc026..ecfee00 100644 --- a/api-mockup/plasmaextractor.lua +++ b/api-mockup/plasmaextractor.lua @@ -26,7 +26,7 @@ function PlasmaExtractor() function self.getRemainingTime() end --- Returns the list of available plasma pools - ---@return table pool A list of tables composed with {[int] oreId, [float] available, [float] maximum); + ---@return OrePool[] pool A list of tables composed with {[int] oreId, [float] available, [float] maximum); function self.getPlasmaPools() end --- Emitted when the plasma extractor started a new extraction process diff --git a/api-mockup/spaceminingunit.lua b/api-mockup/spaceminingunit.lua index 144b70a..aea835b 100644 --- a/api-mockup/spaceminingunit.lua +++ b/api-mockup/spaceminingunit.lua @@ -32,7 +32,7 @@ function SpaceMiningUnit() function self.getActiveOre() end --- Returns the list of available ore pools - ---@return table pool A list of tables composed with {[int] oreId, [float] available, [float] maximum); + ---@return OrePool[] pool A list of tables composed with {[int] oreId, [float] available, [float] maximum); function self.getOrePools() end --- Returns the base production rate of the space mining unit. diff --git a/api-mockup/structures/orepool.lua b/api-mockup/structures/orepool.lua new file mode 100644 index 0000000..27d2f49 --- /dev/null +++ b/api-mockup/structures/orepool.lua @@ -0,0 +1,13 @@ +-- ################################################################################ +-- # Copyright 2014-2022 Novaquark SAS # +-- ################################################################################ + +----------------------------------------------------------------------------------- +-- OrePool +-- +-- OrePool represents a pool of ore available for an extractor. +----------------------------------------------------------------------------------- +---@class OrePool +---@field oreId integer ID of the ore. Use system.getItem(oreId) to retrieve info about it +---@field available number Quantity available to be extracted +---@field maximum number Maximum quantity available \ No newline at end of file From 4a7c0bc143679453514abf60c4d75b15b6831ec5 Mon Sep 17 00:00:00 2001 From: leniver Date: Thu, 8 Sep 2022 13:46:27 +0200 Subject: [PATCH 05/14] Adding Item structure --- api-mockup/structures/item.lua | 26 ++++++++++++++++++++++++++ api-mockup/system.lua | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 api-mockup/structures/item.lua diff --git a/api-mockup/structures/item.lua b/api-mockup/structures/item.lua new file mode 100644 index 0000000..c5bbc65 --- /dev/null +++ b/api-mockup/structures/item.lua @@ -0,0 +1,26 @@ +-- ################################################################################ +-- # Copyright 2014-2022 Novaquark SAS # +-- ################################################################################ + +----------------------------------------------------------------------------------- +-- Item +-- +-- Item represents an item in the game +----------------------------------------------------------------------------------- +---@class Item +---@field id integer ID of the item. +---@field name string Internal name of the item +---@field displayName string Name for display +---@field locDisplayName string Name for display in the player's language +---@field displayNameWithSize string Name for display with additional size information +---@field locDisplayNameWithSize string Name for display with additional size information in the player's language +---@field description string Description of the item +---@field locDescription string Description of the item in player's language +---@field type string Type of item +---@field unitMass number The mass of the item +---@field unitVolume number The volue of the item +---@field tier integer Item's tier +---@field scale string +---@field iconPath string Path to the item's icon. It can be display on a screen. +---@field schematics integer[] List item IDs of schematics producing this item, if the item can be produced into an industry unit. +---@field products integer[] List product item IDs if the item is a schematic diff --git a/api-mockup/system.lua b/api-mockup/system.lua index 868ee00..7256707 100644 --- a/api-mockup/system.lua +++ b/api-mockup/system.lua @@ -319,7 +319,7 @@ function System() --- Return the item table corresponding to the given item ID. ---@param id integer The ID of the item - ---@return table value An item table with fields: {[int] id, [string] name, [string] displayName, [string] locDisplayName, [string] displayNameWithSize, [string] locDisplayNameWithSize, [string] description, [string] locDescription, [string] type, [number] unitMass, [number] unitVolume, [integer] tier, [string] scale, [string] iconPath, [table] schematics, [table] products} + ---@return Item value An item table with fields: {[int] id, [string] name, [string] displayName, [string] locDisplayName, [string] displayNameWithSize, [string] locDisplayNameWithSize, [string] description, [string] locDescription, [string] type, [number] unitMass, [number] unitVolume, [integer] tier, [string] scale, [string] iconPath, [table] schematics, [table] products} function self.getItem(id) end --- Returns a list of recipes producing the given item from its id. From b18ab03e7274d467085205ca2763434c5badfe37 Mon Sep 17 00:00:00 2001 From: leniver Date: Thu, 8 Sep 2022 13:55:24 +0200 Subject: [PATCH 06/14] Adding Recipe structure --- api-mockup/structures/recipe.lua | 16 ++++++++++++++++ api-mockup/system.lua | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 api-mockup/structures/recipe.lua diff --git a/api-mockup/structures/recipe.lua b/api-mockup/structures/recipe.lua new file mode 100644 index 0000000..1cebead --- /dev/null +++ b/api-mockup/structures/recipe.lua @@ -0,0 +1,16 @@ +-- ################################################################################ +-- # Copyright 2014-2022 Novaquark SAS # +-- ################################################################################ + +----------------------------------------------------------------------------------- +-- Recipe +-- +-- Recipe represents a recipe used to produce an item +----------------------------------------------------------------------------------- +---@class Recipe +---@field id integer ID of the recipe +---@field tier integer Which tier is the recipe +---@field time number Time to craft the item +---@field nanocraftable boolean True if this item be crafted into the nanopack +---@field products ItemQuantity[] List of product produced by this recipe. The first product of the list is the main product. +---@field ingredients ItemQuantity[] List of ingredients needed to craft the product diff --git a/api-mockup/system.lua b/api-mockup/system.lua index 7256707..9896ef4 100644 --- a/api-mockup/system.lua +++ b/api-mockup/system.lua @@ -324,7 +324,7 @@ function System() --- Returns a list of recipes producing the given item from its id. ---@param itemId integer The ID of the item - ---@return table value A list of recipe table with field: {[int] id, [int] tier,[double] time, [bool] nanocraftable, [table] products:{{[int] id, [double] quantity},...}, [table] ingredients:{{[int] id, [double] quantity},...}} + ---@return Recipe[] value A list of recipe table with field: {[int] id, [int] tier,[double] time, [bool] nanocraftable, [table] products:{{[int] id, [double] quantity},...}, [table] ingredients:{{[int] id, [double] quantity},...}} function self.getRecipes(itemId) end ---@deprecated System.getSchematic(id) is deprecated, use System.getRecipes(itemId).tag. function self.getSchematic(id) error("System.getSchematic(id) is deprecated, use System.getRecipes(itemId) instead.") end From 457c2dee7dadba9e59cef76701fdf615bb8fca15 Mon Sep 17 00:00:00 2001 From: leniver Date: Thu, 8 Sep 2022 18:25:00 +0200 Subject: [PATCH 07/14] Adding vec3 class --- api-mockup/adjustor.lua | 8 +-- api-mockup/airfoil.lua | 8 +-- api-mockup/brakeengine.lua | 4 +- api-mockup/construct.lua | 78 ++++++++++++------------- api-mockup/controlunit.lua | 6 +- api-mockup/coreunit.lua | 12 ++-- api-mockup/cpml/vec3.lua | 110 ++++++++++++++++++++++++++++++++++++ api-mockup/element.lua | 18 +++--- api-mockup/fueledengine.lua | 8 +-- api-mockup/library.lua | 20 +++---- api-mockup/light.lua | 2 +- api-mockup/miningunit.lua | 2 +- api-mockup/player.lua | 26 ++++----- api-mockup/radar.lua | 8 +-- api-mockup/system.lua | 18 +++--- api-mockup/telemeter.lua | 8 +-- 16 files changed, 223 insertions(+), 113 deletions(-) create mode 100644 api-mockup/cpml/vec3.lua diff --git a/api-mockup/adjustor.lua b/api-mockup/adjustor.lua index 477ae59..43dd9e0 100644 --- a/api-mockup/adjustor.lua +++ b/api-mockup/adjustor.lua @@ -48,21 +48,21 @@ function Adjustor() function self.getMaxThrustBase() error("Adjustor.getMaxThrustBase() is deprecated, use Adjustor.getMaxThrust().") end --- Returns the adjustor exhaust thrust direction in construct local coordinates - ---@return table + ---@return vec3 function self.getThrustAxis() end --- Returns the adjustor torque axis in construct local coordinates - ---@return table + ---@return vec3 function self.getTorqueAxis() end --- Returns the adjustor exhaust thrust direction in world coordinates - ---@return table + ---@return vec3 function self.getWorldThrustAxis() end ---@deprecated Adjustor.thrustAxis() is deprecated, use Adjustor.getWorldThrustAxis(). function self.thrustAxis() error("Adjustor.thrustAxis() is deprecated, use Adjustor.getWorldThrustAxis().") end --- Returns the adjustor torque axis in world coordinates - ---@return table + ---@return vec3 function self.getWorldTorqueAxis() end ---@deprecated Adjustor.torqueAxis() is deprecated, use Adjustor.getWorldTorqueAxis(). function self.torqueAxis() error("Adjustor.torqueAxis() is deprecated, use Adjustor.getWorldTorqueAxis().") end diff --git a/api-mockup/airfoil.lua b/api-mockup/airfoil.lua index 9dd152d..7e8af24 100644 --- a/api-mockup/airfoil.lua +++ b/api-mockup/airfoil.lua @@ -62,21 +62,21 @@ function Airfoil() function self.getMaxThrustEfficiency() error("Airfoil.getMaxThrustEfficiency() is deprecated, use Airfoil.getMaxLiftEfficiency().") end --- Returns the airfoil lift direction in construct local coordinates - ---@return table + ---@return vec3 function self.getLiftAxis() end --- Returns the airfoil torque axis in construct local coordinates - ---@return table + ---@return vec3 function self.getTorqueAxis() end --- Returns the airfoil lift direction in world coordinates - ---@return table + ---@return vec3 function self.getWorldLiftAxis() end ---@deprecated Airfoil.thrustAxis() is deprecated, use Airfoil.getWorldLiftAxis(). function self.thrustAxis() error("Airfoil.thrustAxis() is deprecated, use Airfoil.getWorldLiftAxis().") end --- Returns the adjustor torque axis in world coordinates - ---@return table + ---@return vec3 function self.getWorldTorqueAxis() end ---@deprecated Airfoil.torqueAxis() is deprecated, use Airfoil.getWorldTorqueAxis(). function self.torqueAxis() error("Airfoil.torqueAxis() is deprecated, use Airfoil.getWorldTorqueAxis().") end diff --git a/api-mockup/brakeengine.lua b/api-mockup/brakeengine.lua index 6b97568..90b0cde 100644 --- a/api-mockup/brakeengine.lua +++ b/api-mockup/brakeengine.lua @@ -68,11 +68,11 @@ function BrakeEngine() function self.getMaxThrustEfficiency() end --- Returns the brake thrust direction in construct local coordinates - ---@return table + ---@return vec3 function self.getThrustAxis() end --- Returns the brake thrust direction in world coordinates - ---@return table + ---@return vec3 function self.getWorldThrustAxis() end ---@deprecated BrakeEngine.thrustAxis() is deprecated, use BrakeEngine.getWorldThrustAxis(). function self.thrustAxis() error("BrakeEngine.thrustAxis() is deprecated, use BrakeEngine.getWorldThrustAxis().") end diff --git a/api-mockup/construct.lua b/api-mockup/construct.lua index ae4902a..4b348dc 100644 --- a/api-mockup/construct.lua +++ b/api-mockup/construct.lua @@ -60,22 +60,22 @@ function Construct() ---@return table function self.getInertialTensor() end --- Returns the position of the center of mass of the construct, in local construct coordinates - ---@return table + ---@return vec3 function self.getCenterOfMass() end --- Returns the position of the center of mass of the construct, in world coordinates - ---@return table + ---@return vec3 function self.getWorldCenterOfMass() end --- Returns the construct's cross sectional surface in the current direction of movement ---@return number value The construct's surface exposed in the current direction of movement in meters square function self.getCrossSection() end --- Returns the size of the building zone of the construct - ---@return table + ---@return vec3 function self.getSize() end --- Returns the size of the bounding box of the construct - ---@return table + ---@return vec3 function self.getBoundingBoxSize() end --- Returns the position of the center of bounding box of the construct in local construct coordinates - ---@return table + ---@return vec3 function self.getBoundingBoxCenter() end @@ -97,7 +97,7 @@ function Construct() --- orientation, obstruction, engine damage, etc) --- This is typically used in conjunction with the Control Unit throttle to setup the desired forward acceleration ---@param taglist string Comma (for union) or space (for intersection) separated list of tags. You can set tags directly on the engines in the right-click menu - ---@param CRefAxis table Axis along which to compute the max force (in construct reference) + ---@param CRefAxis vec3 Axis along which to compute the max force (in construct reference) ---@return table value The kinematics parameters in Newtons in the order: atmoRange.FMaxPlus, atmoRange.FMaxMinus, spaceRange.FMaxPlus, spaceRange.FMaxMinus function self.getMaxThrustAlongAxis(taglist, CRefAxis) end --- Returns the current braking force generated by construct brakes @@ -108,87 +108,87 @@ function Construct() function self.getMaxBrake() end --- Returns the world position of the construct - ---@return table value The xyz world coordinates of the construct center position in meters + ---@return vec3 value The xyz world coordinates of the construct center position in meters function self.getWorldPosition() end --- The construct's linear velocity, relative to its parent, in construct local coordinates - ---@return table value Relative linear velocity vector, in construct local coordinates in m/s + ---@return vec3 value Relative linear velocity vector, in construct local coordinates in m/s function self.getVelocity() end --- The construct's linear velocity, relative to its parent, in world coordinates - ---@return table value Relative linear velocity vector, in world coordinates in m/s + ---@return vec3 value Relative linear velocity vector, in world coordinates in m/s function self.getWorldVelocity() end --- The construct's absolute linear velocity, in construct local coordinates - ---@return table value Absolute linear velocity vector, in construct local coordinates in m/s + ---@return vec3 value Absolute linear velocity vector, in construct local coordinates in m/s function self.getAbsoluteVelocity() end --- The construct's absolute linear velocity, in world coordinates - ---@return table value Absolute linear velocity vector, in world coordinates in m/s + ---@return vec3 value Absolute linear velocity vector, in world coordinates in m/s function self.getWorldAbsoluteVelocity() end --- The construct's linear acceleration, in construct local coordinates - ---@return table value Linear acceleration vector, in construct local coordinates in m/s2 + ---@return vec3 value Linear acceleration vector, in construct local coordinates in m/s2 function self.getAcceleration() end --- The construct's linear acceleration, in world coordinates - ---@return table value Linear acceleration vector, in world coordinates in m/s2 + ---@return vec3 value Linear acceleration vector, in world coordinates in m/s2 function self.getWorldAcceleration() end --- The construct's angular velocity, in construct local coordinates - ---@return table value Angular velocity vector, in construct local coordinates in rad/s + ---@return vec3 value Angular velocity vector, in construct local coordinates in rad/s function self.getAngularVelocity() end --- The construct's angular velocity, in world coordinates - ---@return table value Angular velocity vector, in world coordinates in rad/s + ---@return vec3 value Angular velocity vector, in world coordinates in rad/s function self.getWorldAngularVelocity() end --- The construct's angular acceleration, in construct local coordinates - ---@return table value Angular acceleration vector, in construct local coordinates in rad/s2 + ---@return vec3 value Angular acceleration vector, in construct local coordinates in rad/s2 function self.getAngularAcceleration() end --- The construct's angular acceleration, in world coordinates - ---@return table value Angular acceleration vector, in world coordinates in rad/s2 + ---@return vec3 value Angular acceleration vector, in world coordinates in rad/s2 function self.getWorldAngularAcceleration() end --- Returns the acceleration generated by air resistance - ---@return table value The xyz world acceleration generated by air resistance + ---@return vec3 value The xyz world acceleration generated by air resistance function self.getWorldAirFrictionAcceleration() end --- Returns the acceleration torque generated by air resistance - ---@return table value The xyz world acceleration torque generated by air resistance + ---@return vec3 value The xyz world acceleration torque generated by air resistance function self.getWorldAirFrictionAngularAcceleration() end --- Returns the speed at which your construct will suffer damage due to friction with the air ---@return number value The construct speed to get damages due to friction in m/s function self.getFrictionBurnSpeed() end --- Returns the forward vector of the construct coordinates system - ---@return table value The forward vector of the construct coordinates system. It's a static value equal to (0,1,0) + ---@return vec3 value The forward vector of the construct coordinates system. It's a static value equal to (0,1,0) function self.getForward() end --- Returns the right vector of the construct coordinates system - ---@return table value The right vector of the construct coordinates system. It's a static value equal to (1,0,0) + ---@return vec3 value The right vector of the construct coordinates system. It's a static value equal to (1,0,0) function self.getRight() end --- Returns the up direction vector of the construct coordinates system - ---@return table value The up vector of the construct coordinates system.. It's a static value equal to (0,0,1) + ---@return vec3 value The up vector of the construct coordinates system.. It's a static value equal to (0,0,1) function self.getUp() end --- Returns the forward direction vector of the construct, in world coordinates - ---@return table value The forward direction vector of the construct, in world coordinates + ---@return vec3 value The forward direction vector of the construct, in world coordinates function self.getWorldForward() end --- Returns the right direction vector of the construct, in world coordinates - ---@return table value The right direction vector of the construct, in world coordinates + ---@return vec3 value The right direction vector of the construct, in world coordinates function self.getWorldRight() end --- Returns the up direction vector of the construct, in world coordinates - ---@return table value The up direction vector of the construct, in world coordinates + ---@return vec3 value The up direction vector of the construct, in world coordinates function self.getWorldUp() end --- Returns the local id of the current active orientation unit (core unit or gyro unit) ---@return integer value local id of the current active orientation unit (core unit or gyro unit) function self.getOrientationUnitId() end --- Returns the forward direction vector of the active orientation unit, in construct local coordinates - ---@return table value Forward direction vector of the active orientation unit, in construct local coordinates + ---@return vec3 value Forward direction vector of the active orientation unit, in construct local coordinates function self.getOrientationForward() end --- Returns the right direction vector of the active orientation unit, in construct local coordinates - ---@return table value Right direction vector of the active orientation unit, in construct local coordinates + ---@return vec3 value Right direction vector of the active orientation unit, in construct local coordinates function self.getOrientationRight() end --- Returns the up direction vector of the active orientation unit, in construct local coordinates - ---@return table value Up direction vector of the active orientation unit, in construct local coordinates + ---@return vec3 value Up direction vector of the active orientation unit, in construct local coordinates function self.getOrientationUp() end --- Returns the forward direction vector of the active orientation unit, in world coordinates - ---@return table value Forward direction vector of the active orientation unit, in world coordinates + ---@return vec3 value Forward direction vector of the active orientation unit, in world coordinates function self.getWorldOrientationForward() end --- Returns the right direction vector of the active orientation unit, in world coordinates - ---@return table value Right direction vector of the active orientation unit, in world coordinates + ---@return vec3 value Right direction vector of the active orientation unit, in world coordinates function self.getWorldOrientationRight() end --- Returns the up direction vector of the active orientation unit, in world coordinates - ---@return table value Up direction vector of the active orientation unit, in world coordinates + ---@return vec3 value Up direction vector of the active orientation unit, in world coordinates function self.getWorldOrientationUp() end --- Returns the id of the parent construct of our active construct @@ -202,28 +202,28 @@ function Construct() function self.getCloseParents() end --- Returns the position of the construct's parent when docked in local coordinates - ---@return table value The position of the construct's parent in local coordinates + ---@return vec3 value The position of the construct's parent in local coordinates function self.getParentPosition() end --- Returns the position of the construct's parent when docked in world coordinates - ---@return table value The position of the construct's parent in world coordinates + ---@return vec3 value The position of the construct's parent in world coordinates function self.getParentWorldPosition() end --- Returns the construct's parent forward direction vector, in local coordinates - ---@return table value The construct's parent forward direction vector, in local coordinates + ---@return vec3 value The construct's parent forward direction vector, in local coordinates function self.getParentForward() end --- Returns the construct's parent right direction vector, in construct local coordinates - ---@return table value The construct's parent right direction vector, in construct local coordinates + ---@return vec3 value The construct's parent right direction vector, in construct local coordinates function self.getParentRight() end --- Returns the construct's parent up direction vector, in construct local coordinates - ---@return table value The construct's parent up direction vector, in construct local coordinates + ---@return vec3 value The construct's parent up direction vector, in construct local coordinates function self.getParentUp() end --- Returns the construct's parent forward direction vector, in world coordinates - ---@return table value The construct's parent forward direction vector, in world coordinates + ---@return vec3 value The construct's parent forward direction vector, in world coordinates function self.getParentWorldForward() end --- Returns the construct's parent right direction vector, in world coordinates - ---@return table value The construct's parent right direction vector, in world coordinates + ---@return vec3 value The construct's parent right direction vector, in world coordinates function self.getParentWorldRight() end --- Returns the construct's parent up direction vector, in world coordinates - ---@return table value The construct's parent up direction vector, in world coordinates + ---@return vec3 value The construct's parent up direction vector, in world coordinates function self.getParentWorldUp() end diff --git a/api-mockup/controlunit.lua b/api-mockup/controlunit.lua index 2bcb81c..1b12e35 100644 --- a/api-mockup/controlunit.lua +++ b/api-mockup/controlunit.lua @@ -92,8 +92,8 @@ function ControlUnit() --- to approximate it --- This function must be used on a piloting controller in onFlush event ---@param taglist string Comma (for union) or space (for intersection) separated list of tags. You can set tags directly on the engines in the right-click menu - ---@param acceleration table The desired acceleration expressed in world coordinates in m/s2 - ---@param angularAcceleration table The desired angular acceleration expressed in world coordinates in rad/s2 + ---@param acceleration vec3 The desired acceleration expressed in world coordinates in m/s2 + ---@param angularAcceleration vec3 The desired angular acceleration expressed in world coordinates in rad/s2 ---@param keepForceCollinearity boolean Forces the resulting acceleration vector to be collinear to the acceleration parameter ---@param keepTorqueCollinearity boolean Forces the resulting angular acceleration vector to be collinear to the angular acceleration parameter ---@param priority1SubTags string Comma (for union) or space (for intersection) separated list of tags of included engines to use as priority 1 @@ -112,7 +112,7 @@ function ControlUnit() --- Returns the total thrust values of all engines in the tag list --- This function must be used on a piloting controller ---@param taglist string Comma separated list of tags. You can set tags directly on the engines in the right-click menu - ---@return table The total thrust in newtons + ---@return vec3 The total thrust in newtons function self.getEngineThrust(taglist) end --- Set the value of throttle in the cockpit, which will be displayed in the cockpit widget when flying diff --git a/api-mockup/coreunit.lua b/api-mockup/coreunit.lua index e3a29c7..e9db984 100644 --- a/api-mockup/coreunit.lua +++ b/api-mockup/coreunit.lua @@ -204,22 +204,22 @@ function CoreUnit() --- Returns the position of the Element, identified by its local ID, in construct local coordinates. ---@param localId integer The local ID of the Element - ---@return table + ---@return vec3 function self.getElementPositionById(localId) end --- Returns the up direction vector of the Element, identified by its local ID, in construct local coordinates ---@param localId integer The local ID of the Element - ---@return table + ---@return vec3 function self.getElementUpById(localId) end --- Returns the right direction vector of the Element, identified by its local ID, in construct local coordinates ---@param localId integer The local ID of the Element - ---@return table + ---@return vec3 function self.getElementRightById(localId) end --- Returns the forward direction vector of the Element, identified by its local ID, in construct local coordinates ---@param localId integer The local ID of the Element - ---@return table + ---@return vec3 function self.getElementForwardById(localId) end --- Returns the status of the Industry Unit Element, identified by its local ID @@ -246,11 +246,11 @@ function CoreUnit() function self.g() error("CoreUnit.g() is deprecated, use CoreUnit.getGravityIntensity() instead.") end --- Returns the local gravity vector in world coordinates - ---@return table + ---@return vec3 function self.getWorldGravity() end --- Returns the vertical unit vector along gravity, in world coordinates (0 in space) - ---@return table + ---@return vec3 function self.getWorldVertical() end --- Returns the id of the current close stellar body diff --git a/api-mockup/cpml/vec3.lua b/api-mockup/cpml/vec3.lua new file mode 100644 index 0000000..788e253 --- /dev/null +++ b/api-mockup/cpml/vec3.lua @@ -0,0 +1,110 @@ +---@class vec3 +---@field x number X Value +---@field y number Y Value +---@field z number Z Value +vec3 = {} +vec3.__index = vec3 + + +---Create a new vector containing the same data. +---@return vec3 +function vec3:clone() end + +---Unpack the vector into its components. +---@return number +---@return number +---@return number +function vec3:unpack() end + +---Dot product. +---@param a vec3 first vec3 to dot with +---@param b vec3 second vec3 to dot with +---@return number +function vec3.dot(a, b) end + +--- @return number +function vec3:len2() end + +---Vector length/magnitude. +---@return number +function vec3:len() end + +---Distance between two points. +---@param a vec3 first point +---@param b vec3 second point +---@return number +function vec3.dist(a, b) end + +---Squared distance between two points. +---@param a vec3 first point +---@param b vec3 second point +---@return number +function vec3.dist2(a, b) end + +---Normalize vector. Scales the vector in place such that its length is 1. +---@return vec3 +function vec3:normalize_inplace() end + +---Normalize vector. Returns a copy of the vector scaled such that its length is 1. +---@return vec3 +function vec3:normalize() end + +---Rotate vector about an axis. +---@param phi number Amount to rotate, in radians +---@param axis number Axis to rotate by +---@return vec3 Return rotated vector +function vec3:rotate(phi, axis) end + +---@return vec3 Return perpendicular vector +function vec3:perpendicular() end + +---@param v vec3 +---@return vec3 Projection of the vector on target +function vec3:project_on(v) end + +---Project on plane containing origin +---@param plane_normal vec3 +---@return vec3 Projection of the vector on target +function vec3:project_on_plane(plane_normal) end + +---Does the reverse of projectOn. +---@param v vec3 +---@return vec3 +function vec3:project_from(v) end + +---Mirror the vector. +---@param v vec3 +---@return vec3 +function vec3:mirror_on(v) end + +---Cross product. +---@param v vec3 Vector to cross with +---@return vec3 +function vec3:cross(v) end + +---@param maxLen number +---@return vec3 +function vec3:trim_inplace(maxLen) end + +---@param maxLen number +---@return vec3 +function vec3:trim(maxLen) end + +---Angle to other vector. Only makes sense in 2D. +---@param other vec3 +---@return number +function vec3:angle_to(other) end + +---Angle between both vector. +---@param other vec3 +---@return number +function vec3:angle_between(other) end + +---@return vec3 +function vec3:orientation_to_direction(orientation) end + +---@param a vec3 +---@param b vec3 +---@param s number +---@return vec3 +function vec3.lerp(a, b, s) end diff --git a/api-mockup/element.lua b/api-mockup/element.lua index eb017f7..bca6c4d 100644 --- a/api-mockup/element.lua +++ b/api-mockup/element.lua @@ -87,39 +87,39 @@ function Element() function self.getMaxRestorations() end --- Returns the position of the Element in construct local coordinates. - ---@return table + ---@return vec3 function self.getPosition() end --- Returns the bounding box dimensions of the element. - ---@return table + ---@return vec3 function self.getBoundingBoxSize() end --- Returns the position of the center of bounding box of the element in local construct coordinates. - ---@return table + ---@return vec3 function self.getBoundingBoxCenter() end --- Returns the up direction vector of the Element in construct local coordinates - ---@return table + ---@return vec3 function self.getUp() end --- Returns the right direction vector of the Element in construct local coordinates - ---@return table + ---@return vec3 function self.getRight() end --- Returns the forward direction vector of the Element in construct local coordinates - ---@return table + ---@return vec3 function self.getForward() end --- Returns the up direction vector of the Element in world coordinates - ---@return table + ---@return vec3 function self.getWorldUp() end --- Returns the right direction vector of the Element in world coordinates - ---@return table + ---@return vec3 function self.getWorldRight() end --- Returns the forward direction vector of the Element in world coordinates - ---@return table + ---@return vec3 function self.getWorldForward() end --- Set the value of a signal in the specified IN plug of the Element. diff --git a/api-mockup/fueledengine.lua b/api-mockup/fueledengine.lua index c8f1d6b..931043a 100644 --- a/api-mockup/fueledengine.lua +++ b/api-mockup/fueledengine.lua @@ -77,21 +77,21 @@ function FueledEngine() --- Returns the engine thrust direction in construct local coordinates - ---@return table + ---@return vec3 function self.getThrustAxis() end --- Returns the engine torque axis in construct local coordinates - ---@return table + ---@return vec3 function self.getTorqueAxis() end --- Returns the engine exhaust thrust direction in world coordinates - ---@return table + ---@return vec3 function self.getWorldThrustAxis() end ---@deprecated FueledEngine.thrustAxis() is deprecated, use FueledEngine.getWorldThrustAxis(). function self.thrustAxis() error("FueledEngine.thrustAxis() is deprecated, use FueledEngine.getWorldThrustAxis().") end --- Returns the engine torque axis in world coordinates - ---@return table + ---@return vec3 function self.getWorldTorqueAxis() end ---@deprecated FueledEngine.torqueAxis() is deprecated, use FueledEngine.getWorldTorqueAxis(). function self.torqueAxis() error("FueledEngine.torqueAxis() is deprecated, use FueledEngine.getWorldTorqueAxis().") end diff --git a/api-mockup/library.lua b/api-mockup/library.lua index 9493cb2..2175c43 100644 --- a/api-mockup/library.lua +++ b/api-mockup/library.lua @@ -20,23 +20,23 @@ function Library() --- Solve the 3D linear system M*x=c0 where M is defined by its column vectors c1,c2,c3 - ---@param c1 table The first column of the matrix M - ---@param c2 table The second column of the matrix M - ---@param c3 table The third column of the matrix M - ---@param c0 table The target column vector of the system - ---@return table value The vec3 solution of the above system + ---@param c1 vec3 The first column of the matrix M + ---@param c2 vec3 The second column of the matrix M + ---@param c3 vec3 The third column of the matrix M + ---@param c0 vec3 The target column vector of the system + ---@return vec3 value The vec3 solution of the above system function self.systemResolution3(c1,c2,c3,c0) end --- Solve the 2D linear system M*x=c0 where M is defined by its column vectors c1,c2 - ---@param c1 table The first column of the matrix M - ---@param c2 table The second column of the matrix M - ---@param c0 table The target column vector of the system + ---@param c1 vec3 The first column of the matrix M + ---@param c2 vec3 The second column of the matrix M + ---@param c0 vec3 The target column vector of the system ---@return table value The vec2 solution of the above system function self.systemResolution2(c1,c2,c0) end --- Returns the position of the given point in world coordinates system, on the game screen - ---@param worldPos table: The world position of the point - ---@return table value The position in percentage (between 0 and 1) of the screen resolution as vec3 with {x, y, depth} + ---@param worldPos vec3: The world position of the point + ---@return vec3 value The position in percentage (between 0 and 1) of the screen resolution as vec3 with {x, y, depth} function self.getPointOnScreen(worldPos) end diff --git a/api-mockup/light.lua b/api-mockup/light.lua index 74b501b..763b94a 100644 --- a/api-mockup/light.lua +++ b/api-mockup/light.lua @@ -42,7 +42,7 @@ function Light() function self.setRGBColor(r,g,b) error("Light.setRGBColor(r,g,b) is deprecated, use Light.setColor(r,g,b) instead.") end --- Returns the light color in RGB - ---@return table color A vec3 for the red, blue and green components of the light, with values between 0.0 and 1.0, up to 5.0. + ---@return vec3 color A vec3 for the red, blue and green components of the light, with values between 0.0 and 1.0, up to 5.0. function self.getColor() end ---@deprecated Light.getRGBColor() is deprecated, use Light.getColor() instead. function self.getRGBColor() error("Light.getRGBColor() is deprecated, use Light.getColor() instead.") end diff --git a/api-mockup/miningunit.lua b/api-mockup/miningunit.lua index 1b80d2d..f7676f9 100644 --- a/api-mockup/miningunit.lua +++ b/api-mockup/miningunit.lua @@ -60,7 +60,7 @@ function MiningUnit() function self.getAdjacencyBonus() end --- Returns the position of the last calibration excavation, in world coordinates. - ---@return table + ---@return vec3 function self.getLastExtractionPosition() end --- Returns the ID of the last player who calibrated the mining unit. diff --git a/api-mockup/player.lua b/api-mockup/player.lua index 165b2e2..992fe8c 100644 --- a/api-mockup/player.lua +++ b/api-mockup/player.lua @@ -41,45 +41,45 @@ function Player() ---@return table value The list of organization IDs function self.getOrgIds() end --- Returns the position of the player, in construct local coordinates - ---@return table value The position in construct local coordinates + ---@return vec3 value The position in construct local coordinates function self.getPosition() end --- Returns the position of the player, in world coordinates - ---@return table value The position in world coordinates + ---@return vec3 value The position in world coordinates function self.getWorldPosition() end --- Returns the position of the head of the player's character, in construct local coordinates - ---@return table value The position of the head in construct local coordinates + ---@return vec3 value The position of the head in construct local coordinates function self.getHeadPosition() end --- Returns the position of the head of the player's character, in world coordinates - ---@return table value The position of the head in world coordinates + ---@return vec3 value The position of the head in world coordinates function self.getWorldHeadPosition() end --- Returns the velocity vector of the player, in construct local coordinates - ---@return table value The velocity vector in construct local coordinates + ---@return vec3 value The velocity vector in construct local coordinates function self.getVelocity() end --- Returns the velocity vector of the player, in world coordinates - ---@return table value The velocity vector in world coordinates + ---@return vec3 value The velocity vector in world coordinates function self.getWorldVelocity() end --- Returns the absolute velocity vector of the player, in world coordinates - ---@return table value The velocity absolute vector in world coordinates + ---@return vec3 value The velocity absolute vector in world coordinates function self.getAbsoluteVelocity() end --- Returns the forward direction vector of the player, in construct local coordinates - ---@return table value The forward direction vector in construct local coordinates + ---@return vec3 value The forward direction vector in construct local coordinates function self.getForward() end --- Returns the right direction vector of the player, in construct local coordinates - ---@return table value The right direction vector in construct local coordinates + ---@return vec3 value The right direction vector in construct local coordinates function self.getRight() end --- Returns the up direction vector of the player, in construct local coordinates - ---@return table value The up direction vector in construct local coordinates + ---@return vec3 value The up direction vector in construct local coordinates function self.getUp() end --- Returns the forward direction vector of the player, in world coordinates - ---@return table value The forward direction vector in world coordinates + ---@return vec3 value The forward direction vector in world coordinates function self.getWorldForward() end --- Returns the right direction vector of the player, in world coordinates - ---@return table value The right direction vector in world coordinates + ---@return vec3 value The right direction vector in world coordinates function self.getWorldRight() end --- Returns the up direction vector of the player, in world coordinates - ---@return table value The up direction vector in world coordinates + ---@return vec3 value The up direction vector in world coordinates function self.getWorldUp() end --- Returns the id of the planet the player is located on diff --git a/api-mockup/radar.lua b/api-mockup/radar.lua index f0c4e23..5378a9c 100644 --- a/api-mockup/radar.lua +++ b/api-mockup/radar.lua @@ -97,22 +97,22 @@ function Radar() --- Returns the position of the given construct in construct local coordinates, if active transponder tags match for owned dynamic constructs ---@param id integer The ID of the construct - ---@return table + ---@return vec3 function self.getConstructPos(id) end --- Returns the position of the given construct in world coordinates, if in range and if active transponder tags match for owned dynamic constructs ---@param id integer The ID of the construct - ---@return table + ---@return vec3 function self.getConstructWorldPos(id) end --- Returns the velocity vector of the given construct in construct local coordinates, if identified and if active transponder tags match for owned dynamic constructs ---@param id integer The ID of the construct - ---@return table + ---@return vec3 function self.getConstructVelocity(id) end --- Returns the velocity vector of the given construct in world coordinates, if identified and if active transponder tags match for owned dynamic constructs ---@param id integer The ID of the construct - ---@return table + ---@return vec3 function self.getConstructWorldVelocity(id) end --- Returns the mass of the given construct, if identified for owned dynamic constructs diff --git a/api-mockup/system.lua b/api-mockup/system.lua index 9896ef4..6df8f6d 100644 --- a/api-mockup/system.lua +++ b/api-mockup/system.lua @@ -220,35 +220,35 @@ function System() function self.isFirstPerson() end --- Returns the position of the camera, in construct local coordinates. - ---@return table value Camera position in construct local coordinates. + ---@return vec3 value Camera position in construct local coordinates. function self.getCameraPos() end --- Returns the position of the camera, in world coordinates. - ---@return table value Camera position in world coordinates. + ---@return vec3 value Camera position in world coordinates. function self.getCameraWorldPos() end --- Returns the forward direction vector of the active camera, in world coordinates. - ---@return table value Camera forward direction vector in world coordinates. + ---@return vec3 value Camera forward direction vector in world coordinates. function self.getCameraWorldForward() end --- Returns the right direction vector of the active camera, in world coordinates. - ---@return table value Camera right direction vector in world coordinates. + ---@return vec3 value Camera right direction vector in world coordinates. function self.getCameraWorldRight() end --- Returns the up direction vector of the active camera, in world coordinates. - ---@return table value Camera up direction vector in world coordinates. + ---@return vec3 value Camera up direction vector in world coordinates. function self.getCameraWorldUp() end --- Returns the forward direction vector of the active camera, in construct local coordinates. - ---@return table value Camera forward direction vector in construct local coordinates. + ---@return vec3 value Camera forward direction vector in construct local coordinates. function self.getCameraForward() end --- Returns the right direction vector of the active camera, in construct local coordinates. - ---@return table value Camera right direction vector in construct local coordinates. + ---@return vec3 value Camera right direction vector in construct local coordinates. function self.getCameraRight() end --- Returns the up direction vector of the active camera, in construct local coordinates. - ---@return table value Camera up direction vector in construct local coordinates. + ---@return vec3 value Camera up direction vector in construct local coordinates. function self.getCameraUp() end --- Return the current value of the mouse wheel (for the throttle speedUp/speedDown action) @@ -314,7 +314,7 @@ function System() --- Return the world position of the given player, if in range of visibility ---@param id integer The ID of the player - ---@return table value The coordinates of the player in world coordinates + ---@return vec3 value The coordinates of the player in world coordinates function self.getPlayerWorldPos(id) end --- Return the item table corresponding to the given item ID. diff --git a/api-mockup/telemeter.lua b/api-mockup/telemeter.lua index 056411e..9a1e587 100644 --- a/api-mockup/telemeter.lua +++ b/api-mockup/telemeter.lua @@ -25,19 +25,19 @@ function Telemeter() function self.raycast() end --- Returns telemeter raycast origin in local construct coordinates - ---@return table + ---@return vec3 function self.getRayOrigin() end --- Returns telemeter raycast origin in world coordinates - ---@return table + ---@return vec3 function self.getRayWorldOrigin() end --- Returns telemeter raycast axis in local construct coordinates - ---@return table + ---@return vec3 function self.getRayAxis() end --- Returns telemeter raycast axis in world coordinates - ---@return table + ---@return vec3 function self.getRayWorldAxis() end --- Returns the max distance from which an obstacle can be detected (default is 100m) From d5eb96753fa0d9836cb18a756da2fb53f90c7314 Mon Sep 17 00:00:00 2001 From: leniver Date: Thu, 8 Sep 2022 18:30:52 +0200 Subject: [PATCH 08/14] Adding Raycast structure TODO: Validate that the 'point' parameter is really in world coordinates --- api-mockup/structures/raycast.lua | 13 +++++++++++++ api-mockup/telemeter.lua | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 api-mockup/structures/raycast.lua diff --git a/api-mockup/structures/raycast.lua b/api-mockup/structures/raycast.lua new file mode 100644 index 0000000..da1d2bb --- /dev/null +++ b/api-mockup/structures/raycast.lua @@ -0,0 +1,13 @@ +-- ################################################################################ +-- # Copyright 2014-2022 Novaquark SAS # +-- ################################################################################ + +----------------------------------------------------------------------------------- +-- Raycast +-- +-- Raycast represents the restult of a raycast done by a telemeter +----------------------------------------------------------------------------------- +---@class Raycast +---@field hit boolean True if the ray has hit something +---@field distance number Distance to closest object in front +---@field point vec3 Position of the hit in world coordinates \ No newline at end of file diff --git a/api-mockup/telemeter.lua b/api-mockup/telemeter.lua index 9a1e587..cbfd101 100644 --- a/api-mockup/telemeter.lua +++ b/api-mockup/telemeter.lua @@ -21,7 +21,7 @@ function Telemeter() function self.getDistance() error("Telemeter.getDistance() is deprecated, use Telemeter.raycast().distance instead.") end --- Emits a raycast from the telemeter, returns a raycastHit object - ---@return table hit A table with fields : {[bool] hit, [float] distance, [vec3] point} + ---@return Raycast hit A table with fields : {[bool] hit, [float] distance, [vec3] point} function self.raycast() end --- Returns telemeter raycast origin in local construct coordinates From 50d68bc320f3d43b2ae5485f1795301177dbd65b Mon Sep 17 00:00:00 2001 From: leniver Date: Thu, 8 Sep 2022 18:51:56 +0200 Subject: [PATCH 09/14] Adding Organization structure --- api-mockup/structures/organization.lua | 12 ++++++++++++ api-mockup/system.lua | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 api-mockup/structures/organization.lua diff --git a/api-mockup/structures/organization.lua b/api-mockup/structures/organization.lua new file mode 100644 index 0000000..ac88373 --- /dev/null +++ b/api-mockup/structures/organization.lua @@ -0,0 +1,12 @@ +-- ################################################################################ +-- # Copyright 2014-2022 Novaquark SAS # +-- ################################################################################ + +----------------------------------------------------------------------------------- +-- Organization +-- +-- Organization represents an organization in game +----------------------------------------------------------------------------------- +---@class Organization +---@field name string Full name of the organization +---@field tag string Short tag of the organization \ No newline at end of file diff --git a/api-mockup/system.lua b/api-mockup/system.lua index 6df8f6d..621749c 100644 --- a/api-mockup/system.lua +++ b/api-mockup/system.lua @@ -332,7 +332,7 @@ function System() --- Returns the corresping organization to the given organization id, if known, e.g. broadcasted by a transponder ---@param id integer The ID of the organization - ---@return table value A table containing information about the given organization {[string] name, [string] tag} + ---@return Organization value A table containing information about the given organization {[string] name, [string] tag} function self.getOrganization(id) end ---@deprecated System.getOrganizationName() is deprecated, use System.getOrganization(id).name . function self.getOrganizationName() error("System.getOrganizationName() is deprecated, use System.getOrganization(id).name instead.") end From 55645bc00b0f83509892ed69a418818eb577ca59 Mon Sep 17 00:00:00 2001 From: leniver Date: Thu, 8 Sep 2022 20:23:32 +0200 Subject: [PATCH 10/14] Replace 'table' by its corresponding typed array --- api-mockup/baseshieldgenerator.lua | 6 +++--- api-mockup/construct.lua | 14 +++++++------- api-mockup/controlunit.lua | 4 ++-- api-mockup/coreunit.lua | 2 +- api-mockup/databank.lua | 2 +- api-mockup/detectionzone.lua | 2 +- api-mockup/industry.lua | 4 ++-- api-mockup/player.lua | 2 +- api-mockup/radar.lua | 8 ++++---- api-mockup/receiver.lua | 4 ++-- api-mockup/shieldgenerator.lua | 6 +++--- api-mockup/transponder.lua | 4 ++-- 12 files changed, 29 insertions(+), 29 deletions(-) diff --git a/api-mockup/baseshieldgenerator.lua b/api-mockup/baseshieldgenerator.lua index d05e1ce..476f53c 100644 --- a/api-mockup/baseshieldgenerator.lua +++ b/api-mockup/baseshieldgenerator.lua @@ -74,7 +74,7 @@ function BaseShieldGenerator() function self.getMaxShieldHitpoints() end --- Returns distribution of resistance pool over resistance types - ---@return table resistances Resistance to damage type {antimatter, electromagnetic, kinetic, thermic} + ---@return number[] resistances Resistance to damage type {antimatter, electromagnetic, kinetic, thermic} function self.getResistances() end --- Distribute the resistance pool according to damage type @@ -102,11 +102,11 @@ function BaseShieldGenerator() function self.getResistancesRemaining() end --- Returns ratio per damage type of recent weapon impacts after applying resistance - ---@return table stress Stress ratio due to damage type {antimatter, electromagnetic, kinetic, thermic} + ---@return number[] stress Stress ratio due to damage type {antimatter, electromagnetic, kinetic, thermic} function self.getStressRatio() end --- Returns ratio per damage type of recent weapon impacts without resistance - ---@return table stress Stress ratio due to damage type {antimatter, electromagnetic, kinetic, thermic} + ---@return number[] stress Stress ratio due to damage type {antimatter, electromagnetic, kinetic, thermic} function self.getStressRatioRaw() end --- Returns stress, that is the total hit points of recent weapon impacts after applying resistance diff --git a/api-mockup/construct.lua b/api-mockup/construct.lua index 4b348dc..25c14e1 100644 --- a/api-mockup/construct.lua +++ b/api-mockup/construct.lua @@ -57,7 +57,7 @@ function Construct() ---@return number function self.getInertialMass() end --- Returns the inertial tensor of the construct - ---@return table + ---@return number[] function self.getInertialTensor() end --- Returns the position of the center of mass of the construct, in local construct coordinates ---@return vec3 @@ -86,7 +86,7 @@ function Construct() ---@return number value The max angular speed in rad/s function self.getMaxAngularSpeed() end --- Returns the max speed per axis - ---@return table value The max speed along axes {x, -x, y, -y, z, -z} in m/s + ---@return number[] value The max speed along axes {x, -x, y, -y, z, -z} in m/s function self.getMaxSpeedPerAxis() end --- Returns the construct max kinematics parameters in both atmo and space range, in newtons. Kinematics --- parameters designate here the maximal positive and negative base force the construct is capable of producing along the chosen @@ -98,7 +98,7 @@ function Construct() --- This is typically used in conjunction with the Control Unit throttle to setup the desired forward acceleration ---@param taglist string Comma (for union) or space (for intersection) separated list of tags. You can set tags directly on the engines in the right-click menu ---@param CRefAxis vec3 Axis along which to compute the max force (in construct reference) - ---@return table value The kinematics parameters in Newtons in the order: atmoRange.FMaxPlus, atmoRange.FMaxMinus, spaceRange.FMaxPlus, spaceRange.FMaxMinus + ---@return number[] value The kinematics parameters in Newtons in the order: atmoRange.FMaxPlus, atmoRange.FMaxMinus, spaceRange.FMaxPlus, spaceRange.FMaxMinus function self.getMaxThrustAlongAxis(taglist, CRefAxis) end --- Returns the current braking force generated by construct brakes ---@return number value The current braking force in Newtons @@ -198,7 +198,7 @@ function Construct() ---@return integer function self.getClosestParent() end --- Returns the list of ids of nearby constructs, on which the construct can dock - ---@return table + ---@return integer[] function self.getCloseParents() end --- Returns the position of the construct's parent when docked in local coordinates @@ -228,10 +228,10 @@ function Construct() --- Returns the list of player IDs on board the construct - ---@return table + ---@return integer[] function self.getPlayersOnBoard() end --- Returns the list of player ids on board the construct inside a VR Station - ---@return table + ---@return integer[] function self.getPlayersOnBoardInVRStation() end --- Checks if the given player is on board in the construct ---@param id integer The player id @@ -251,7 +251,7 @@ function Construct() function self.getBoardedInVRStationAvatarMass(id) end --- Returns the list of IDs of constructs docked to the construct - ---@return table + ---@return integer[] function self.getDockedConstructs() end --- Checks if the given construct is docked to the construct ---@param id integer The construct id diff --git a/api-mockup/controlunit.lua b/api-mockup/controlunit.lua index 1b12e35..e9eaddf 100644 --- a/api-mockup/controlunit.lua +++ b/api-mockup/controlunit.lua @@ -132,7 +132,7 @@ function ControlUnit() --- These properties will be used to display the command in UI ---@param axis integer Longitudinal = 0, lateral = 1, vertical = 2 ---@param commandType integer By throttle = 0, by target speed = 1, hidden = 2 - ---@param targetSpeedRanges table This is to specify the cruise control target speed ranges (for now, only for the longitudinal axis) in m/s + ---@param targetSpeedRanges number[] This is to specify the cruise control target speed ranges (for now, only for the longitudinal axis) in m/s function self.setupAxisCommandProperties(axis, commandType, targetSpeedRanges) end --- Returns the current control mode. The mode is set by clicking the UI button or using the associated keybinding @@ -180,7 +180,7 @@ function ControlUnit() --- Returns ground engine stabilization altitude capabilities (lower and upper ranges) --- This function must be used on a piloting controller - ---@return table range Stabilization altitude capabilities for the least powerful engine and the most powerful engine + ---@return number[] range Stabilization altitude capabilities for the least powerful engine and the most powerful engine function self.computeGroundEngineAltitudeStabilizationCapabilities() end --- Return the current throttle value diff --git a/api-mockup/coreunit.lua b/api-mockup/coreunit.lua index e9db984..8404614 100644 --- a/api-mockup/coreunit.lua +++ b/api-mockup/coreunit.lua @@ -162,7 +162,7 @@ function CoreUnit() --- Returns the list of all the local IDs of the Elements of this construct - ---@return table + ---@return integer[] function self.getElementIdList() end --- Returns the name of the Element, identified by its local ID diff --git a/api-mockup/databank.lua b/api-mockup/databank.lua index 56670aa..38e861a 100644 --- a/api-mockup/databank.lua +++ b/api-mockup/databank.lua @@ -25,7 +25,7 @@ function Databank() function self.getNbKeys() end --- Returns all the keys in the Databank - ---@return table value The key list, as a list of string + ---@return string[] value The key list, as a list of string function self.getKeyList() end ---@deprecated Databank.getKeys() is deprecated, use Databank.getKeyList(). function self.getKeys() error("Databank.getKeys() is deprecated, use Databank.getKeyList().") end diff --git a/api-mockup/detectionzone.lua b/api-mockup/detectionzone.lua index dcfe552..99712bd 100644 --- a/api-mockup/detectionzone.lua +++ b/api-mockup/detectionzone.lua @@ -22,7 +22,7 @@ function DetectionZone() function self.getRadius() end --- Returns the list of ids of the players in the detection zone - ---@return table + ---@return integer[] function self.getPlayers() end --- Emitted when a player enters in the detection zone diff --git a/api-mockup/industry.lua b/api-mockup/industry.lua index 5972068..ba17ca3 100644 --- a/api-mockup/industry.lua +++ b/api-mockup/industry.lua @@ -68,11 +68,11 @@ function Industry() --- Returns the list of items required to run the selected output product. - ---@return table outputs Returns the list of products + ---@return ItemQuantity[] outputs Returns the list of products function self.getInputs() end --- Returns the list of id of the items currently produced. - ---@return table outputs The first entry in the table is always the main product produced + ---@return ItemQuantity[] outputs The first entry in the table is always the main product produced function self.getOutputs() end ---@deprecated Industry.getCurrentSchematic() is deprecated. function self.getCurrentSchematic() error("Industry.getCurrentSchematic() is deprecated.") end diff --git a/api-mockup/player.lua b/api-mockup/player.lua index 992fe8c..99e4565 100644 --- a/api-mockup/player.lua +++ b/api-mockup/player.lua @@ -38,7 +38,7 @@ function Player() function self.getNanopackMaxVolume() end --- Returns the list of organization IDs of the player - ---@return table value The list of organization IDs + ---@return integer[] value The list of organization IDs function self.getOrgIds() end --- Returns the position of the player, in construct local coordinates ---@return vec3 value The position in construct local coordinates diff --git a/api-mockup/radar.lua b/api-mockup/radar.lua index 5378a9c..c4d5397 100644 --- a/api-mockup/radar.lua +++ b/api-mockup/radar.lua @@ -29,15 +29,15 @@ function Radar() function self.getRange() end --- Returns ranges to identify a target based on its core size - ---@return table ranges The list of float values for ranges in meters as { xsRange, sRange, mRange, lRange } + ---@return number[] ranges The list of float values for ranges in meters as { xsRange, sRange, mRange, lRange } function self.getIdentifyRanges() end --- Returns the list of construct IDs in the scan range - ---@return table + ---@return integer[] function self.getConstructIds() end --- Returns the list of identified construct IDs - ---@return table + ---@return integer[] function self.getIdentifiedConstructIds() end --- Returns the ID of the target construct @@ -85,7 +85,7 @@ function Radar() --- Return the size of the bounding box of the given construct, if in range ---@param id integer The ID of the construct - ---@return table + ---@return vec3 function self.getConstructSize(id) end --- Return the kind of the given construct diff --git a/api-mockup/receiver.lua b/api-mockup/receiver.lua index e78c4e9..0e3d5fc 100644 --- a/api-mockup/receiver.lua +++ b/api-mockup/receiver.lua @@ -34,14 +34,14 @@ function Receiver() function self.hasChannel(channel) end --- Set the channels list - ---@param channels table The channels list as Lua table + ---@param channels string[] The channels list as Lua table ---@return integer 1 if the channels list has been successfully set function self.setChannelList(channels) end ---@deprecated Receiver.setChannels(channels) is deprecated, use Receiver.setChannelList(channels) instead. function self.setChannels(channels) error("Receiver.setChannels(channels) is deprecated, use Receiver.setChannelList(channels) instead.") end ---Returns the channels list - ---@return table channels The channels list as Lua table + ---@return string[] channels The channels list as Lua table function self.getChannelList() end ---@deprecated Receiver.getChannels() is deprecated, use Receiver.getChannelList() instead. function self.getChannels(channels) error("Receiver.getChannels() is deprecated, use Receiver.getChannelList() instead.") end diff --git a/api-mockup/shieldgenerator.lua b/api-mockup/shieldgenerator.lua index 6205cd8..225ab7b 100644 --- a/api-mockup/shieldgenerator.lua +++ b/api-mockup/shieldgenerator.lua @@ -94,7 +94,7 @@ function ShieldGenerator() --- Returns distribution of resistance pool over resistance types - ---@return table resistances Resistance to damage type {antimatter, electromagnetic, kinetic, thermic} + ---@return number[] resistances Resistance to damage type {antimatter, electromagnetic, kinetic, thermic} function self.getResistances() end --- Distribute the resistance pool according to damage type @@ -122,11 +122,11 @@ function ShieldGenerator() function self.getResistancesRemaining() end --- Returns ratio per damage type of recent weapon impacts after applying resistance - ---@return table stress Stress ratio due to damage type {antimatter, electromagnetic, kinetic, thermic} + ---@return number[] stress Stress ratio due to damage type {antimatter, electromagnetic, kinetic, thermic} function self.getStressRatio() end --- Returns ratio per damage type of recent weapon impacts without resistance - ---@return table stress Stress ratio due to damage type {antimatter, electromagnetic, kinetic, thermic} + ---@return number[] stress Stress ratio due to damage type {antimatter, electromagnetic, kinetic, thermic} function self.getStressRatioRaw() end --- Returns stress, that is the total hit points of recent weapon impacts after applying resistance diff --git a/api-mockup/transponder.lua b/api-mockup/transponder.lua index c0ce181..ca77da7 100644 --- a/api-mockup/transponder.lua +++ b/api-mockup/transponder.lua @@ -34,12 +34,12 @@ function Transponder() --- Set the tags list with up to 8 entries. Returns 1 if the application was successful, 0 if the tag --- format is invalid. - ---@param tags table List of up to 8 transponder tag strings + ---@param tags string[] List of up to 8 transponder tag strings ---@return integer function self.setTags(tags) end --- Returns the tag list - ---@return table tags List of up to 8 transponder tag strings + ---@return string[] tags List of up to 8 transponder tag strings function self.getTags() end --- Emitted when the transponder is started or stopped From 2be130b9833af2a277797ae48885fdc2d11f2b5d Mon Sep 17 00:00:00 2001 From: leniver Date: Thu, 8 Sep 2022 20:23:43 +0200 Subject: [PATCH 11/14] Adding vec2 class --- api-mockup/cpml/vec2.lua | 89 ++++++++++++++++++++++++++++++++++++++++ api-mockup/library.lua | 2 +- 2 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 api-mockup/cpml/vec2.lua diff --git a/api-mockup/cpml/vec2.lua b/api-mockup/cpml/vec2.lua new file mode 100644 index 0000000..2ad17f8 --- /dev/null +++ b/api-mockup/cpml/vec2.lua @@ -0,0 +1,89 @@ +---@class vec2 +vec2 = vec2() +vec2.__index = vec2 + + +---Create a new vector containing the same data. +---@return vec2 +function vec2:clone() end + +---Unpack the vector into its components. +---@return number +---@return number +function vec2:unpack() end + +---Dot product. +---@param a vec2 first vec2 to dot with +---@param b vec2 second vec2 to dot with +---@return number +function vec2.dot(a, b) end + +--- @return number +function vec2:len2() end + +---Vector length/magnitude. +---@return number +function vec2:len() end + +---Distance between two points. +---@param a vec2 first point +---@param b vec2 second point +---@return number +function vec2.dist(a, b) end + +---Squared distance between two points. +---@param a vec2 first point +---@param b vec2 second point +---@return number +function vec2.dist2(a, b) end + +---Normalize vector. Scales the vector in place such that its length is 1. +---@return vec2 +function vec2:normalize_inplace() end + +---Normalize vector. Returns a copy of the vector scaled such that its length is 1. +---@return vec2 +function vec2:normalize() end + +---Rotate vector about an axis. +---@param phi number Amount to rotate, in radians +---@return vec2 Return rotated vector +function vec2:rotate_inplace(phi) end + +---Rotate vector about an axis. +---@param phi number Amount to rotate, in radians +---@return vec2 Return rotated vector +function vec2:rotate(phi) end + +---@return vec2 Return perpendicular vector +function vec2:perpendicular() end + +---Mirror the vector. +---@param v vec2 +---@return vec2 +function vec2:mirror_on(v) end + +---Cross product. +---@param v vec2 Vector to cross with +---@return vec2 +function vec2:cross(v) end + +---@param maxLen number +---@return vec2 +function vec2:trim_inplace(maxLen) end + +---@param maxLen number +---@return vec2 +function vec2:trim(maxLen) end + +---Angle to other vector. Only makes sense in 2D. +---@param other vec2 +---@return number +function vec2:angle_to(other) end + +---@param a vec2 +---@param b vec2 +---@param s number +---@return vec2 +function vec2.lerp(a, b, s) end + diff --git a/api-mockup/library.lua b/api-mockup/library.lua index 2175c43..cf956a3 100644 --- a/api-mockup/library.lua +++ b/api-mockup/library.lua @@ -31,7 +31,7 @@ function Library() ---@param c1 vec3 The first column of the matrix M ---@param c2 vec3 The second column of the matrix M ---@param c0 vec3 The target column vector of the system - ---@return table value The vec2 solution of the above system + ---@return vec2 value The vec2 solution of the above system function self.systemResolution2(c1,c2,c0) end --- Returns the position of the given point in world coordinates system, on the game screen From 56598de7ee3d0ded98123ece85c638d094590958 Mon Sep 17 00:00:00 2001 From: leniver Date: Thu, 8 Sep 2022 20:33:14 +0200 Subject: [PATCH 12/14] Adding RadarConstructInfo structure --- api-mockup/radar.lua | 2 +- api-mockup/structures/radarconstructinfo.lua | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 api-mockup/structures/radarconstructinfo.lua diff --git a/api-mockup/radar.lua b/api-mockup/radar.lua index c4d5397..6e71456 100644 --- a/api-mockup/radar.lua +++ b/api-mockup/radar.lua @@ -127,7 +127,7 @@ function Radar() --- Returns a table of working elements on the given construction, if identified for owned dynamic constructs ---@param id integer The ID of the construct - ---@return table info A table with fields : {[float] weapons, [float] radars, [float] antiGravity, [float] atmoEngines, [float] spaceEngines, [float] rocketEngines} with values between 0.0 and 1.0. Exceptionally antiGravity and rocketEngines are always 1.0 if present, even if broken + ---@return RadarConstructInfo info A table with fields : {[float] weapons, [float] radars, [float] antiGravity, [float] atmoEngines, [float] spaceEngines, [float] rocketEngines} with values between 0.0 and 1.0. Exceptionally antiGravity and rocketEngines are always 1.0 if present, even if broken function self.getConstructInfos(id) end --- Returns the speed of the given construct, if identified for owned dynamic constructs diff --git a/api-mockup/structures/radarconstructinfo.lua b/api-mockup/structures/radarconstructinfo.lua new file mode 100644 index 0000000..e97a59c --- /dev/null +++ b/api-mockup/structures/radarconstructinfo.lua @@ -0,0 +1,16 @@ +-- ################################################################################ +-- # Copyright 2014-2022 Novaquark SAS # +-- ################################################################################ + +----------------------------------------------------------------------------------- +-- RadarConstructInfo +-- +-- RadarConstructInfo represents information about a construct from a radar +----------------------------------------------------------------------------------- +---@class RadarConstructInfo +---@field weapons number Weapons working elements of the construct, values between 0.0 and 1.0 +---@field radars number Radars working elements of the construct, values between 0.0 and 1.0 +---@field antiGravity number Anti-gravity working element of the construct, always return 1.0 if present even if broken +---@field atmoEngines number Atmopheric engines working elements of the construct, values between 0.0 and 1.0 +---@field spaceEngines number Space engines working elements of the construct, values between 0.0 and 1.0 +---@field rocketEngines number Rocket engines working elements of the construct, always return 1.0 if present even if broken From 7128384e1848e66cefa7b3335f1d9d12f1fc3f6b Mon Sep 17 00:00:00 2001 From: leniver Date: Thu, 8 Sep 2022 22:08:28 +0200 Subject: [PATCH 13/14] Add 'id' field to organization structure --- api-mockup/structures/organization.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/api-mockup/structures/organization.lua b/api-mockup/structures/organization.lua index ac88373..fe09984 100644 --- a/api-mockup/structures/organization.lua +++ b/api-mockup/structures/organization.lua @@ -8,5 +8,6 @@ -- Organization represents an organization in game ----------------------------------------------------------------------------------- ---@class Organization +---@field id number ID of the organization ---@field name string Full name of the organization ---@field tag string Short tag of the organization \ No newline at end of file From 59368c81e92e094c4f7d70601f137889123a57b1 Mon Sep 17 00:00:00 2001 From: leniver Date: Thu, 8 Sep 2022 22:10:58 +0200 Subject: [PATCH 14/14] Replace vec3 and vec2 by Vector3 and Vector2 Returning vec3 was wrong because it's more than a simple array. Vector3 is defined as an array of numbers --- api-mockup/adjustor.lua | 8 +-- api-mockup/airfoil.lua | 8 +-- api-mockup/brakeengine.lua | 4 +- api-mockup/construct.lua | 78 ++++++++++----------- api-mockup/controlunit.lua | 6 +- api-mockup/coreunit.lua | 12 ++-- api-mockup/cpml/vec2.lua | 89 ------------------------ api-mockup/cpml/vec3.lua | 110 ------------------------------ api-mockup/element.lua | 18 ++--- api-mockup/fueledengine.lua | 8 +-- api-mockup/library.lua | 22 +++--- api-mockup/light.lua | 2 +- api-mockup/miningunit.lua | 2 +- api-mockup/player.lua | 26 +++---- api-mockup/radar.lua | 10 +-- api-mockup/structures/raycast.lua | 2 +- api-mockup/structures/vector2.lua | 16 +++++ api-mockup/structures/vector3.lua | 16 +++++ api-mockup/system.lua | 18 ++--- api-mockup/telemeter.lua | 10 +-- 20 files changed, 149 insertions(+), 316 deletions(-) delete mode 100644 api-mockup/cpml/vec2.lua delete mode 100644 api-mockup/cpml/vec3.lua create mode 100644 api-mockup/structures/vector2.lua create mode 100644 api-mockup/structures/vector3.lua diff --git a/api-mockup/adjustor.lua b/api-mockup/adjustor.lua index 43dd9e0..2e59c6d 100644 --- a/api-mockup/adjustor.lua +++ b/api-mockup/adjustor.lua @@ -48,21 +48,21 @@ function Adjustor() function self.getMaxThrustBase() error("Adjustor.getMaxThrustBase() is deprecated, use Adjustor.getMaxThrust().") end --- Returns the adjustor exhaust thrust direction in construct local coordinates - ---@return vec3 + ---@return Vector3 function self.getThrustAxis() end --- Returns the adjustor torque axis in construct local coordinates - ---@return vec3 + ---@return Vector3 function self.getTorqueAxis() end --- Returns the adjustor exhaust thrust direction in world coordinates - ---@return vec3 + ---@return Vector3 function self.getWorldThrustAxis() end ---@deprecated Adjustor.thrustAxis() is deprecated, use Adjustor.getWorldThrustAxis(). function self.thrustAxis() error("Adjustor.thrustAxis() is deprecated, use Adjustor.getWorldThrustAxis().") end --- Returns the adjustor torque axis in world coordinates - ---@return vec3 + ---@return Vector3 function self.getWorldTorqueAxis() end ---@deprecated Adjustor.torqueAxis() is deprecated, use Adjustor.getWorldTorqueAxis(). function self.torqueAxis() error("Adjustor.torqueAxis() is deprecated, use Adjustor.getWorldTorqueAxis().") end diff --git a/api-mockup/airfoil.lua b/api-mockup/airfoil.lua index 7e8af24..ca7f825 100644 --- a/api-mockup/airfoil.lua +++ b/api-mockup/airfoil.lua @@ -62,21 +62,21 @@ function Airfoil() function self.getMaxThrustEfficiency() error("Airfoil.getMaxThrustEfficiency() is deprecated, use Airfoil.getMaxLiftEfficiency().") end --- Returns the airfoil lift direction in construct local coordinates - ---@return vec3 + ---@return Vector3 function self.getLiftAxis() end --- Returns the airfoil torque axis in construct local coordinates - ---@return vec3 + ---@return Vector3 function self.getTorqueAxis() end --- Returns the airfoil lift direction in world coordinates - ---@return vec3 + ---@return Vector3 function self.getWorldLiftAxis() end ---@deprecated Airfoil.thrustAxis() is deprecated, use Airfoil.getWorldLiftAxis(). function self.thrustAxis() error("Airfoil.thrustAxis() is deprecated, use Airfoil.getWorldLiftAxis().") end --- Returns the adjustor torque axis in world coordinates - ---@return vec3 + ---@return Vector3 function self.getWorldTorqueAxis() end ---@deprecated Airfoil.torqueAxis() is deprecated, use Airfoil.getWorldTorqueAxis(). function self.torqueAxis() error("Airfoil.torqueAxis() is deprecated, use Airfoil.getWorldTorqueAxis().") end diff --git a/api-mockup/brakeengine.lua b/api-mockup/brakeengine.lua index 90b0cde..6ce40b6 100644 --- a/api-mockup/brakeengine.lua +++ b/api-mockup/brakeengine.lua @@ -68,11 +68,11 @@ function BrakeEngine() function self.getMaxThrustEfficiency() end --- Returns the brake thrust direction in construct local coordinates - ---@return vec3 + ---@return Vector3 function self.getThrustAxis() end --- Returns the brake thrust direction in world coordinates - ---@return vec3 + ---@return Vector3 function self.getWorldThrustAxis() end ---@deprecated BrakeEngine.thrustAxis() is deprecated, use BrakeEngine.getWorldThrustAxis(). function self.thrustAxis() error("BrakeEngine.thrustAxis() is deprecated, use BrakeEngine.getWorldThrustAxis().") end diff --git a/api-mockup/construct.lua b/api-mockup/construct.lua index 25c14e1..6067adc 100644 --- a/api-mockup/construct.lua +++ b/api-mockup/construct.lua @@ -60,22 +60,22 @@ function Construct() ---@return number[] function self.getInertialTensor() end --- Returns the position of the center of mass of the construct, in local construct coordinates - ---@return vec3 + ---@return Vector3 function self.getCenterOfMass() end --- Returns the position of the center of mass of the construct, in world coordinates - ---@return vec3 + ---@return Vector3 function self.getWorldCenterOfMass() end --- Returns the construct's cross sectional surface in the current direction of movement ---@return number value The construct's surface exposed in the current direction of movement in meters square function self.getCrossSection() end --- Returns the size of the building zone of the construct - ---@return vec3 + ---@return Vector3 function self.getSize() end --- Returns the size of the bounding box of the construct - ---@return vec3 + ---@return Vector3 function self.getBoundingBoxSize() end --- Returns the position of the center of bounding box of the construct in local construct coordinates - ---@return vec3 + ---@return Vector3 function self.getBoundingBoxCenter() end @@ -97,7 +97,7 @@ function Construct() --- orientation, obstruction, engine damage, etc) --- This is typically used in conjunction with the Control Unit throttle to setup the desired forward acceleration ---@param taglist string Comma (for union) or space (for intersection) separated list of tags. You can set tags directly on the engines in the right-click menu - ---@param CRefAxis vec3 Axis along which to compute the max force (in construct reference) + ---@param CRefAxis Vector3 Axis along which to compute the max force (in construct reference) ---@return number[] value The kinematics parameters in Newtons in the order: atmoRange.FMaxPlus, atmoRange.FMaxMinus, spaceRange.FMaxPlus, spaceRange.FMaxMinus function self.getMaxThrustAlongAxis(taglist, CRefAxis) end --- Returns the current braking force generated by construct brakes @@ -108,87 +108,87 @@ function Construct() function self.getMaxBrake() end --- Returns the world position of the construct - ---@return vec3 value The xyz world coordinates of the construct center position in meters + ---@return Vector3 value The xyz world coordinates of the construct center position in meters function self.getWorldPosition() end --- The construct's linear velocity, relative to its parent, in construct local coordinates - ---@return vec3 value Relative linear velocity vector, in construct local coordinates in m/s + ---@return Vector3 value Relative linear velocity vector, in construct local coordinates in m/s function self.getVelocity() end --- The construct's linear velocity, relative to its parent, in world coordinates - ---@return vec3 value Relative linear velocity vector, in world coordinates in m/s + ---@return Vector3 value Relative linear velocity vector, in world coordinates in m/s function self.getWorldVelocity() end --- The construct's absolute linear velocity, in construct local coordinates - ---@return vec3 value Absolute linear velocity vector, in construct local coordinates in m/s + ---@return Vector3 value Absolute linear velocity vector, in construct local coordinates in m/s function self.getAbsoluteVelocity() end --- The construct's absolute linear velocity, in world coordinates - ---@return vec3 value Absolute linear velocity vector, in world coordinates in m/s + ---@return Vector3 value Absolute linear velocity vector, in world coordinates in m/s function self.getWorldAbsoluteVelocity() end --- The construct's linear acceleration, in construct local coordinates - ---@return vec3 value Linear acceleration vector, in construct local coordinates in m/s2 + ---@return Vector3 value Linear acceleration vector, in construct local coordinates in m/s2 function self.getAcceleration() end --- The construct's linear acceleration, in world coordinates - ---@return vec3 value Linear acceleration vector, in world coordinates in m/s2 + ---@return Vector3 value Linear acceleration vector, in world coordinates in m/s2 function self.getWorldAcceleration() end --- The construct's angular velocity, in construct local coordinates - ---@return vec3 value Angular velocity vector, in construct local coordinates in rad/s + ---@return Vector3 value Angular velocity vector, in construct local coordinates in rad/s function self.getAngularVelocity() end --- The construct's angular velocity, in world coordinates - ---@return vec3 value Angular velocity vector, in world coordinates in rad/s + ---@return Vector3 value Angular velocity vector, in world coordinates in rad/s function self.getWorldAngularVelocity() end --- The construct's angular acceleration, in construct local coordinates - ---@return vec3 value Angular acceleration vector, in construct local coordinates in rad/s2 + ---@return Vector3 value Angular acceleration vector, in construct local coordinates in rad/s2 function self.getAngularAcceleration() end --- The construct's angular acceleration, in world coordinates - ---@return vec3 value Angular acceleration vector, in world coordinates in rad/s2 + ---@return Vector3 value Angular acceleration vector, in world coordinates in rad/s2 function self.getWorldAngularAcceleration() end --- Returns the acceleration generated by air resistance - ---@return vec3 value The xyz world acceleration generated by air resistance + ---@return Vector3 value The xyz world acceleration generated by air resistance function self.getWorldAirFrictionAcceleration() end --- Returns the acceleration torque generated by air resistance - ---@return vec3 value The xyz world acceleration torque generated by air resistance + ---@return Vector3 value The xyz world acceleration torque generated by air resistance function self.getWorldAirFrictionAngularAcceleration() end --- Returns the speed at which your construct will suffer damage due to friction with the air ---@return number value The construct speed to get damages due to friction in m/s function self.getFrictionBurnSpeed() end --- Returns the forward vector of the construct coordinates system - ---@return vec3 value The forward vector of the construct coordinates system. It's a static value equal to (0,1,0) + ---@return Vector3 value The forward vector of the construct coordinates system. It's a static value equal to (0,1,0) function self.getForward() end --- Returns the right vector of the construct coordinates system - ---@return vec3 value The right vector of the construct coordinates system. It's a static value equal to (1,0,0) + ---@return Vector3 value The right vector of the construct coordinates system. It's a static value equal to (1,0,0) function self.getRight() end --- Returns the up direction vector of the construct coordinates system - ---@return vec3 value The up vector of the construct coordinates system.. It's a static value equal to (0,0,1) + ---@return Vector3 value The up vector of the construct coordinates system.. It's a static value equal to (0,0,1) function self.getUp() end --- Returns the forward direction vector of the construct, in world coordinates - ---@return vec3 value The forward direction vector of the construct, in world coordinates + ---@return Vector3 value The forward direction vector of the construct, in world coordinates function self.getWorldForward() end --- Returns the right direction vector of the construct, in world coordinates - ---@return vec3 value The right direction vector of the construct, in world coordinates + ---@return Vector3 value The right direction vector of the construct, in world coordinates function self.getWorldRight() end --- Returns the up direction vector of the construct, in world coordinates - ---@return vec3 value The up direction vector of the construct, in world coordinates + ---@return Vector3 value The up direction vector of the construct, in world coordinates function self.getWorldUp() end --- Returns the local id of the current active orientation unit (core unit or gyro unit) ---@return integer value local id of the current active orientation unit (core unit or gyro unit) function self.getOrientationUnitId() end --- Returns the forward direction vector of the active orientation unit, in construct local coordinates - ---@return vec3 value Forward direction vector of the active orientation unit, in construct local coordinates + ---@return Vector3 value Forward direction vector of the active orientation unit, in construct local coordinates function self.getOrientationForward() end --- Returns the right direction vector of the active orientation unit, in construct local coordinates - ---@return vec3 value Right direction vector of the active orientation unit, in construct local coordinates + ---@return Vector3 value Right direction vector of the active orientation unit, in construct local coordinates function self.getOrientationRight() end --- Returns the up direction vector of the active orientation unit, in construct local coordinates - ---@return vec3 value Up direction vector of the active orientation unit, in construct local coordinates + ---@return Vector3 value Up direction vector of the active orientation unit, in construct local coordinates function self.getOrientationUp() end --- Returns the forward direction vector of the active orientation unit, in world coordinates - ---@return vec3 value Forward direction vector of the active orientation unit, in world coordinates + ---@return Vector3 value Forward direction vector of the active orientation unit, in world coordinates function self.getWorldOrientationForward() end --- Returns the right direction vector of the active orientation unit, in world coordinates - ---@return vec3 value Right direction vector of the active orientation unit, in world coordinates + ---@return Vector3 value Right direction vector of the active orientation unit, in world coordinates function self.getWorldOrientationRight() end --- Returns the up direction vector of the active orientation unit, in world coordinates - ---@return vec3 value Up direction vector of the active orientation unit, in world coordinates + ---@return Vector3 value Up direction vector of the active orientation unit, in world coordinates function self.getWorldOrientationUp() end --- Returns the id of the parent construct of our active construct @@ -202,28 +202,28 @@ function Construct() function self.getCloseParents() end --- Returns the position of the construct's parent when docked in local coordinates - ---@return vec3 value The position of the construct's parent in local coordinates + ---@return Vector3 value The position of the construct's parent in local coordinates function self.getParentPosition() end --- Returns the position of the construct's parent when docked in world coordinates - ---@return vec3 value The position of the construct's parent in world coordinates + ---@return Vector3 value The position of the construct's parent in world coordinates function self.getParentWorldPosition() end --- Returns the construct's parent forward direction vector, in local coordinates - ---@return vec3 value The construct's parent forward direction vector, in local coordinates + ---@return Vector3 value The construct's parent forward direction vector, in local coordinates function self.getParentForward() end --- Returns the construct's parent right direction vector, in construct local coordinates - ---@return vec3 value The construct's parent right direction vector, in construct local coordinates + ---@return Vector3 value The construct's parent right direction vector, in construct local coordinates function self.getParentRight() end --- Returns the construct's parent up direction vector, in construct local coordinates - ---@return vec3 value The construct's parent up direction vector, in construct local coordinates + ---@return Vector3 value The construct's parent up direction vector, in construct local coordinates function self.getParentUp() end --- Returns the construct's parent forward direction vector, in world coordinates - ---@return vec3 value The construct's parent forward direction vector, in world coordinates + ---@return Vector3 value The construct's parent forward direction vector, in world coordinates function self.getParentWorldForward() end --- Returns the construct's parent right direction vector, in world coordinates - ---@return vec3 value The construct's parent right direction vector, in world coordinates + ---@return Vector3 value The construct's parent right direction vector, in world coordinates function self.getParentWorldRight() end --- Returns the construct's parent up direction vector, in world coordinates - ---@return vec3 value The construct's parent up direction vector, in world coordinates + ---@return Vector3 value The construct's parent up direction vector, in world coordinates function self.getParentWorldUp() end diff --git a/api-mockup/controlunit.lua b/api-mockup/controlunit.lua index e9eaddf..7e1ee83 100644 --- a/api-mockup/controlunit.lua +++ b/api-mockup/controlunit.lua @@ -92,8 +92,8 @@ function ControlUnit() --- to approximate it --- This function must be used on a piloting controller in onFlush event ---@param taglist string Comma (for union) or space (for intersection) separated list of tags. You can set tags directly on the engines in the right-click menu - ---@param acceleration vec3 The desired acceleration expressed in world coordinates in m/s2 - ---@param angularAcceleration vec3 The desired angular acceleration expressed in world coordinates in rad/s2 + ---@param acceleration Vector3 The desired acceleration expressed in world coordinates in m/s2 + ---@param angularAcceleration Vector3 The desired angular acceleration expressed in world coordinates in rad/s2 ---@param keepForceCollinearity boolean Forces the resulting acceleration vector to be collinear to the acceleration parameter ---@param keepTorqueCollinearity boolean Forces the resulting angular acceleration vector to be collinear to the angular acceleration parameter ---@param priority1SubTags string Comma (for union) or space (for intersection) separated list of tags of included engines to use as priority 1 @@ -112,7 +112,7 @@ function ControlUnit() --- Returns the total thrust values of all engines in the tag list --- This function must be used on a piloting controller ---@param taglist string Comma separated list of tags. You can set tags directly on the engines in the right-click menu - ---@return vec3 The total thrust in newtons + ---@return Vector3 The total thrust in newtons function self.getEngineThrust(taglist) end --- Set the value of throttle in the cockpit, which will be displayed in the cockpit widget when flying diff --git a/api-mockup/coreunit.lua b/api-mockup/coreunit.lua index 8404614..afe57cb 100644 --- a/api-mockup/coreunit.lua +++ b/api-mockup/coreunit.lua @@ -204,22 +204,22 @@ function CoreUnit() --- Returns the position of the Element, identified by its local ID, in construct local coordinates. ---@param localId integer The local ID of the Element - ---@return vec3 + ---@return Vector3 function self.getElementPositionById(localId) end --- Returns the up direction vector of the Element, identified by its local ID, in construct local coordinates ---@param localId integer The local ID of the Element - ---@return vec3 + ---@return Vector3 function self.getElementUpById(localId) end --- Returns the right direction vector of the Element, identified by its local ID, in construct local coordinates ---@param localId integer The local ID of the Element - ---@return vec3 + ---@return Vector3 function self.getElementRightById(localId) end --- Returns the forward direction vector of the Element, identified by its local ID, in construct local coordinates ---@param localId integer The local ID of the Element - ---@return vec3 + ---@return Vector3 function self.getElementForwardById(localId) end --- Returns the status of the Industry Unit Element, identified by its local ID @@ -246,11 +246,11 @@ function CoreUnit() function self.g() error("CoreUnit.g() is deprecated, use CoreUnit.getGravityIntensity() instead.") end --- Returns the local gravity vector in world coordinates - ---@return vec3 + ---@return Vector3 function self.getWorldGravity() end --- Returns the vertical unit vector along gravity, in world coordinates (0 in space) - ---@return vec3 + ---@return Vector3 function self.getWorldVertical() end --- Returns the id of the current close stellar body diff --git a/api-mockup/cpml/vec2.lua b/api-mockup/cpml/vec2.lua deleted file mode 100644 index 2ad17f8..0000000 --- a/api-mockup/cpml/vec2.lua +++ /dev/null @@ -1,89 +0,0 @@ ----@class vec2 -vec2 = vec2() -vec2.__index = vec2 - - ----Create a new vector containing the same data. ----@return vec2 -function vec2:clone() end - ----Unpack the vector into its components. ----@return number ----@return number -function vec2:unpack() end - ----Dot product. ----@param a vec2 first vec2 to dot with ----@param b vec2 second vec2 to dot with ----@return number -function vec2.dot(a, b) end - ---- @return number -function vec2:len2() end - ----Vector length/magnitude. ----@return number -function vec2:len() end - ----Distance between two points. ----@param a vec2 first point ----@param b vec2 second point ----@return number -function vec2.dist(a, b) end - ----Squared distance between two points. ----@param a vec2 first point ----@param b vec2 second point ----@return number -function vec2.dist2(a, b) end - ----Normalize vector. Scales the vector in place such that its length is 1. ----@return vec2 -function vec2:normalize_inplace() end - ----Normalize vector. Returns a copy of the vector scaled such that its length is 1. ----@return vec2 -function vec2:normalize() end - ----Rotate vector about an axis. ----@param phi number Amount to rotate, in radians ----@return vec2 Return rotated vector -function vec2:rotate_inplace(phi) end - ----Rotate vector about an axis. ----@param phi number Amount to rotate, in radians ----@return vec2 Return rotated vector -function vec2:rotate(phi) end - ----@return vec2 Return perpendicular vector -function vec2:perpendicular() end - ----Mirror the vector. ----@param v vec2 ----@return vec2 -function vec2:mirror_on(v) end - ----Cross product. ----@param v vec2 Vector to cross with ----@return vec2 -function vec2:cross(v) end - ----@param maxLen number ----@return vec2 -function vec2:trim_inplace(maxLen) end - ----@param maxLen number ----@return vec2 -function vec2:trim(maxLen) end - ----Angle to other vector. Only makes sense in 2D. ----@param other vec2 ----@return number -function vec2:angle_to(other) end - ----@param a vec2 ----@param b vec2 ----@param s number ----@return vec2 -function vec2.lerp(a, b, s) end - diff --git a/api-mockup/cpml/vec3.lua b/api-mockup/cpml/vec3.lua deleted file mode 100644 index 788e253..0000000 --- a/api-mockup/cpml/vec3.lua +++ /dev/null @@ -1,110 +0,0 @@ ----@class vec3 ----@field x number X Value ----@field y number Y Value ----@field z number Z Value -vec3 = {} -vec3.__index = vec3 - - ----Create a new vector containing the same data. ----@return vec3 -function vec3:clone() end - ----Unpack the vector into its components. ----@return number ----@return number ----@return number -function vec3:unpack() end - ----Dot product. ----@param a vec3 first vec3 to dot with ----@param b vec3 second vec3 to dot with ----@return number -function vec3.dot(a, b) end - ---- @return number -function vec3:len2() end - ----Vector length/magnitude. ----@return number -function vec3:len() end - ----Distance between two points. ----@param a vec3 first point ----@param b vec3 second point ----@return number -function vec3.dist(a, b) end - ----Squared distance between two points. ----@param a vec3 first point ----@param b vec3 second point ----@return number -function vec3.dist2(a, b) end - ----Normalize vector. Scales the vector in place such that its length is 1. ----@return vec3 -function vec3:normalize_inplace() end - ----Normalize vector. Returns a copy of the vector scaled such that its length is 1. ----@return vec3 -function vec3:normalize() end - ----Rotate vector about an axis. ----@param phi number Amount to rotate, in radians ----@param axis number Axis to rotate by ----@return vec3 Return rotated vector -function vec3:rotate(phi, axis) end - ----@return vec3 Return perpendicular vector -function vec3:perpendicular() end - ----@param v vec3 ----@return vec3 Projection of the vector on target -function vec3:project_on(v) end - ----Project on plane containing origin ----@param plane_normal vec3 ----@return vec3 Projection of the vector on target -function vec3:project_on_plane(plane_normal) end - ----Does the reverse of projectOn. ----@param v vec3 ----@return vec3 -function vec3:project_from(v) end - ----Mirror the vector. ----@param v vec3 ----@return vec3 -function vec3:mirror_on(v) end - ----Cross product. ----@param v vec3 Vector to cross with ----@return vec3 -function vec3:cross(v) end - ----@param maxLen number ----@return vec3 -function vec3:trim_inplace(maxLen) end - ----@param maxLen number ----@return vec3 -function vec3:trim(maxLen) end - ----Angle to other vector. Only makes sense in 2D. ----@param other vec3 ----@return number -function vec3:angle_to(other) end - ----Angle between both vector. ----@param other vec3 ----@return number -function vec3:angle_between(other) end - ----@return vec3 -function vec3:orientation_to_direction(orientation) end - ----@param a vec3 ----@param b vec3 ----@param s number ----@return vec3 -function vec3.lerp(a, b, s) end diff --git a/api-mockup/element.lua b/api-mockup/element.lua index bca6c4d..002cb05 100644 --- a/api-mockup/element.lua +++ b/api-mockup/element.lua @@ -87,39 +87,39 @@ function Element() function self.getMaxRestorations() end --- Returns the position of the Element in construct local coordinates. - ---@return vec3 + ---@return Vector3 function self.getPosition() end --- Returns the bounding box dimensions of the element. - ---@return vec3 + ---@return Vector3 function self.getBoundingBoxSize() end --- Returns the position of the center of bounding box of the element in local construct coordinates. - ---@return vec3 + ---@return Vector3 function self.getBoundingBoxCenter() end --- Returns the up direction vector of the Element in construct local coordinates - ---@return vec3 + ---@return Vector3 function self.getUp() end --- Returns the right direction vector of the Element in construct local coordinates - ---@return vec3 + ---@return Vector3 function self.getRight() end --- Returns the forward direction vector of the Element in construct local coordinates - ---@return vec3 + ---@return Vector3 function self.getForward() end --- Returns the up direction vector of the Element in world coordinates - ---@return vec3 + ---@return Vector3 function self.getWorldUp() end --- Returns the right direction vector of the Element in world coordinates - ---@return vec3 + ---@return Vector3 function self.getWorldRight() end --- Returns the forward direction vector of the Element in world coordinates - ---@return vec3 + ---@return Vector3 function self.getWorldForward() end --- Set the value of a signal in the specified IN plug of the Element. diff --git a/api-mockup/fueledengine.lua b/api-mockup/fueledengine.lua index 931043a..c1854fb 100644 --- a/api-mockup/fueledengine.lua +++ b/api-mockup/fueledengine.lua @@ -77,21 +77,21 @@ function FueledEngine() --- Returns the engine thrust direction in construct local coordinates - ---@return vec3 + ---@return Vector3 function self.getThrustAxis() end --- Returns the engine torque axis in construct local coordinates - ---@return vec3 + ---@return Vector3 function self.getTorqueAxis() end --- Returns the engine exhaust thrust direction in world coordinates - ---@return vec3 + ---@return Vector3 function self.getWorldThrustAxis() end ---@deprecated FueledEngine.thrustAxis() is deprecated, use FueledEngine.getWorldThrustAxis(). function self.thrustAxis() error("FueledEngine.thrustAxis() is deprecated, use FueledEngine.getWorldThrustAxis().") end --- Returns the engine torque axis in world coordinates - ---@return vec3 + ---@return Vector3 function self.getWorldTorqueAxis() end ---@deprecated FueledEngine.torqueAxis() is deprecated, use FueledEngine.getWorldTorqueAxis(). function self.torqueAxis() error("FueledEngine.torqueAxis() is deprecated, use FueledEngine.getWorldTorqueAxis().") end diff --git a/api-mockup/library.lua b/api-mockup/library.lua index cf956a3..e8f5d5c 100644 --- a/api-mockup/library.lua +++ b/api-mockup/library.lua @@ -20,23 +20,23 @@ function Library() --- Solve the 3D linear system M*x=c0 where M is defined by its column vectors c1,c2,c3 - ---@param c1 vec3 The first column of the matrix M - ---@param c2 vec3 The second column of the matrix M - ---@param c3 vec3 The third column of the matrix M - ---@param c0 vec3 The target column vector of the system - ---@return vec3 value The vec3 solution of the above system + ---@param c1 Vector3 The first column of the matrix M + ---@param c2 Vector3 The second column of the matrix M + ---@param c3 Vector3 The third column of the matrix M + ---@param c0 Vector3 The target column vector of the system + ---@return Vector3 value The vec3 solution of the above system function self.systemResolution3(c1,c2,c3,c0) end --- Solve the 2D linear system M*x=c0 where M is defined by its column vectors c1,c2 - ---@param c1 vec3 The first column of the matrix M - ---@param c2 vec3 The second column of the matrix M - ---@param c0 vec3 The target column vector of the system - ---@return vec2 value The vec2 solution of the above system + ---@param c1 Vector3 The first column of the matrix M + ---@param c2 Vector3 The second column of the matrix M + ---@param c0 Vector3 The target column vector of the system + ---@return vector2 value The vec2 solution of the above system function self.systemResolution2(c1,c2,c0) end --- Returns the position of the given point in world coordinates system, on the game screen - ---@param worldPos vec3: The world position of the point - ---@return vec3 value The position in percentage (between 0 and 1) of the screen resolution as vec3 with {x, y, depth} + ---@param worldPos Vector3: The world position of the point + ---@return Vector3 value The position in percentage (between 0 and 1) of the screen resolution as vec3 with {x, y, depth} function self.getPointOnScreen(worldPos) end diff --git a/api-mockup/light.lua b/api-mockup/light.lua index 763b94a..ff84745 100644 --- a/api-mockup/light.lua +++ b/api-mockup/light.lua @@ -42,7 +42,7 @@ function Light() function self.setRGBColor(r,g,b) error("Light.setRGBColor(r,g,b) is deprecated, use Light.setColor(r,g,b) instead.") end --- Returns the light color in RGB - ---@return vec3 color A vec3 for the red, blue and green components of the light, with values between 0.0 and 1.0, up to 5.0. + ---@return number[] color A vec3 for the red, blue and green components of the light, with values between 0.0 and 1.0, up to 5.0. function self.getColor() end ---@deprecated Light.getRGBColor() is deprecated, use Light.getColor() instead. function self.getRGBColor() error("Light.getRGBColor() is deprecated, use Light.getColor() instead.") end diff --git a/api-mockup/miningunit.lua b/api-mockup/miningunit.lua index f7676f9..b38eb2b 100644 --- a/api-mockup/miningunit.lua +++ b/api-mockup/miningunit.lua @@ -60,7 +60,7 @@ function MiningUnit() function self.getAdjacencyBonus() end --- Returns the position of the last calibration excavation, in world coordinates. - ---@return vec3 + ---@return Vector3 function self.getLastExtractionPosition() end --- Returns the ID of the last player who calibrated the mining unit. diff --git a/api-mockup/player.lua b/api-mockup/player.lua index 99e4565..7d6d603 100644 --- a/api-mockup/player.lua +++ b/api-mockup/player.lua @@ -41,45 +41,45 @@ function Player() ---@return integer[] value The list of organization IDs function self.getOrgIds() end --- Returns the position of the player, in construct local coordinates - ---@return vec3 value The position in construct local coordinates + ---@return Vector3 value The position in construct local coordinates function self.getPosition() end --- Returns the position of the player, in world coordinates - ---@return vec3 value The position in world coordinates + ---@return Vector3 value The position in world coordinates function self.getWorldPosition() end --- Returns the position of the head of the player's character, in construct local coordinates - ---@return vec3 value The position of the head in construct local coordinates + ---@return Vector3 value The position of the head in construct local coordinates function self.getHeadPosition() end --- Returns the position of the head of the player's character, in world coordinates - ---@return vec3 value The position of the head in world coordinates + ---@return Vector3 value The position of the head in world coordinates function self.getWorldHeadPosition() end --- Returns the velocity vector of the player, in construct local coordinates - ---@return vec3 value The velocity vector in construct local coordinates + ---@return Vector3 value The velocity vector in construct local coordinates function self.getVelocity() end --- Returns the velocity vector of the player, in world coordinates - ---@return vec3 value The velocity vector in world coordinates + ---@return Vector3 value The velocity vector in world coordinates function self.getWorldVelocity() end --- Returns the absolute velocity vector of the player, in world coordinates - ---@return vec3 value The velocity absolute vector in world coordinates + ---@return Vector3 value The velocity absolute vector in world coordinates function self.getAbsoluteVelocity() end --- Returns the forward direction vector of the player, in construct local coordinates - ---@return vec3 value The forward direction vector in construct local coordinates + ---@return Vector3 value The forward direction vector in construct local coordinates function self.getForward() end --- Returns the right direction vector of the player, in construct local coordinates - ---@return vec3 value The right direction vector in construct local coordinates + ---@return Vector3 value The right direction vector in construct local coordinates function self.getRight() end --- Returns the up direction vector of the player, in construct local coordinates - ---@return vec3 value The up direction vector in construct local coordinates + ---@return Vector3 value The up direction vector in construct local coordinates function self.getUp() end --- Returns the forward direction vector of the player, in world coordinates - ---@return vec3 value The forward direction vector in world coordinates + ---@return Vector3 value The forward direction vector in world coordinates function self.getWorldForward() end --- Returns the right direction vector of the player, in world coordinates - ---@return vec3 value The right direction vector in world coordinates + ---@return Vector3 value The right direction vector in world coordinates function self.getWorldRight() end --- Returns the up direction vector of the player, in world coordinates - ---@return vec3 value The up direction vector in world coordinates + ---@return Vector3 value The up direction vector in world coordinates function self.getWorldUp() end --- Returns the id of the planet the player is located on diff --git a/api-mockup/radar.lua b/api-mockup/radar.lua index 6e71456..90c28f7 100644 --- a/api-mockup/radar.lua +++ b/api-mockup/radar.lua @@ -85,7 +85,7 @@ function Radar() --- Return the size of the bounding box of the given construct, if in range ---@param id integer The ID of the construct - ---@return vec3 + ---@return Vector3 function self.getConstructSize(id) end --- Return the kind of the given construct @@ -97,22 +97,22 @@ function Radar() --- Returns the position of the given construct in construct local coordinates, if active transponder tags match for owned dynamic constructs ---@param id integer The ID of the construct - ---@return vec3 + ---@return Vector3 function self.getConstructPos(id) end --- Returns the position of the given construct in world coordinates, if in range and if active transponder tags match for owned dynamic constructs ---@param id integer The ID of the construct - ---@return vec3 + ---@return Vector3 function self.getConstructWorldPos(id) end --- Returns the velocity vector of the given construct in construct local coordinates, if identified and if active transponder tags match for owned dynamic constructs ---@param id integer The ID of the construct - ---@return vec3 + ---@return Vector3 function self.getConstructVelocity(id) end --- Returns the velocity vector of the given construct in world coordinates, if identified and if active transponder tags match for owned dynamic constructs ---@param id integer The ID of the construct - ---@return vec3 + ---@return Vector3 function self.getConstructWorldVelocity(id) end --- Returns the mass of the given construct, if identified for owned dynamic constructs diff --git a/api-mockup/structures/raycast.lua b/api-mockup/structures/raycast.lua index da1d2bb..e3da05a 100644 --- a/api-mockup/structures/raycast.lua +++ b/api-mockup/structures/raycast.lua @@ -10,4 +10,4 @@ ---@class Raycast ---@field hit boolean True if the ray has hit something ---@field distance number Distance to closest object in front ----@field point vec3 Position of the hit in world coordinates \ No newline at end of file +---@field point Vector3 Position of the hit in world coordinates \ No newline at end of file diff --git a/api-mockup/structures/vector2.lua b/api-mockup/structures/vector2.lua new file mode 100644 index 0000000..5ff82cf --- /dev/null +++ b/api-mockup/structures/vector2.lua @@ -0,0 +1,16 @@ +-- ################################################################################ +-- # Copyright 2014-2022 Novaquark SAS # +-- ################################################################################ + +----------------------------------------------------------------------------------- +-- Vector2 +-- +-- Vector2 represents a table with 2 numbers +-- Function return a table that should be converted into vec2 +-- +-- local vec2 = require("cpml/vec2") +-- local myVector = vec2(library.systemResolution2(c0,c1,c2)) +-- +----------------------------------------------------------------------------------- +---@class Vector2 : number[] + diff --git a/api-mockup/structures/vector3.lua b/api-mockup/structures/vector3.lua new file mode 100644 index 0000000..19ffed2 --- /dev/null +++ b/api-mockup/structures/vector3.lua @@ -0,0 +1,16 @@ +-- ################################################################################ +-- # Copyright 2014-2022 Novaquark SAS # +-- ################################################################################ + +----------------------------------------------------------------------------------- +-- Vector3 +-- +-- Vector3 represents a table with 3 numbers +-- Function return a table that should be converted into vec3 +-- +-- local vec3 = require("cpml/vec3") +-- local myVector = vec3(construct.getForward()) +-- +----------------------------------------------------------------------------------- +---@class Vector3 : number[] + diff --git a/api-mockup/system.lua b/api-mockup/system.lua index 621749c..9943041 100644 --- a/api-mockup/system.lua +++ b/api-mockup/system.lua @@ -220,35 +220,35 @@ function System() function self.isFirstPerson() end --- Returns the position of the camera, in construct local coordinates. - ---@return vec3 value Camera position in construct local coordinates. + ---@return Vector3 value Camera position in construct local coordinates. function self.getCameraPos() end --- Returns the position of the camera, in world coordinates. - ---@return vec3 value Camera position in world coordinates. + ---@return Vector3 value Camera position in world coordinates. function self.getCameraWorldPos() end --- Returns the forward direction vector of the active camera, in world coordinates. - ---@return vec3 value Camera forward direction vector in world coordinates. + ---@return Vector3 value Camera forward direction vector in world coordinates. function self.getCameraWorldForward() end --- Returns the right direction vector of the active camera, in world coordinates. - ---@return vec3 value Camera right direction vector in world coordinates. + ---@return Vector3 value Camera right direction vector in world coordinates. function self.getCameraWorldRight() end --- Returns the up direction vector of the active camera, in world coordinates. - ---@return vec3 value Camera up direction vector in world coordinates. + ---@return Vector3 value Camera up direction vector in world coordinates. function self.getCameraWorldUp() end --- Returns the forward direction vector of the active camera, in construct local coordinates. - ---@return vec3 value Camera forward direction vector in construct local coordinates. + ---@return Vector3 value Camera forward direction vector in construct local coordinates. function self.getCameraForward() end --- Returns the right direction vector of the active camera, in construct local coordinates. - ---@return vec3 value Camera right direction vector in construct local coordinates. + ---@return Vector3 value Camera right direction vector in construct local coordinates. function self.getCameraRight() end --- Returns the up direction vector of the active camera, in construct local coordinates. - ---@return vec3 value Camera up direction vector in construct local coordinates. + ---@return Vector3 value Camera up direction vector in construct local coordinates. function self.getCameraUp() end --- Return the current value of the mouse wheel (for the throttle speedUp/speedDown action) @@ -314,7 +314,7 @@ function System() --- Return the world position of the given player, if in range of visibility ---@param id integer The ID of the player - ---@return vec3 value The coordinates of the player in world coordinates + ---@return Vector3 value The coordinates of the player in world coordinates function self.getPlayerWorldPos(id) end --- Return the item table corresponding to the given item ID. diff --git a/api-mockup/telemeter.lua b/api-mockup/telemeter.lua index cbfd101..2b552df 100644 --- a/api-mockup/telemeter.lua +++ b/api-mockup/telemeter.lua @@ -21,23 +21,23 @@ function Telemeter() function self.getDistance() error("Telemeter.getDistance() is deprecated, use Telemeter.raycast().distance instead.") end --- Emits a raycast from the telemeter, returns a raycastHit object - ---@return Raycast hit A table with fields : {[bool] hit, [float] distance, [vec3] point} + ---@return Raycast hit A table with fields : {[bool] hit, [float] distance, [Vector3] point} function self.raycast() end --- Returns telemeter raycast origin in local construct coordinates - ---@return vec3 + ---@return Vector3 function self.getRayOrigin() end --- Returns telemeter raycast origin in world coordinates - ---@return vec3 + ---@return Vector3 function self.getRayWorldOrigin() end --- Returns telemeter raycast axis in local construct coordinates - ---@return vec3 + ---@return Vector3 function self.getRayAxis() end --- Returns telemeter raycast axis in world coordinates - ---@return vec3 + ---@return Vector3 function self.getRayWorldAxis() end --- Returns the max distance from which an obstacle can be detected (default is 100m)