Jump to content

INFO: DETAILED LUA API REVAMP


NQ-Ligo

Recommended Posts

Library

Contains a list of useful math and helper methods that would be slow to implement in Lua, and which are given here as fast C++ implementation.

 

Quote

A new function getPointOnScreen() has been added to this API to help projecting 3D points on your screen for simple uses.

 

Functions

  • systemResolution3([table] c1,[table] c2,[table] c3,[table] c0): Solve the 3D linear system M*x=c0 where M is defined by its column vectors c1,c2,c3
    • [table] c1: The first column of the matrix M
    • [table] c2: The second column of the matrix M
    • [table] c3: The third column of the matrix M
    • [table] c0: The target column vector of the system
    • return [table]: The vec3 solution of the above system
  • systemResolution2([table] c1,[table] c2,[table] c0): Solve the 2D linear system M*x=c0 where M is defined by its column vectors c1,c2
    • [table] c1: The first column of the matrix M
    • [table] c2: The second column of the matrix M
    • [table] c0: The target column vector of the system
    • return [table]: The vec2 solution of the above system
       
  • NEW [vec3] getPointOnScreen([table] worldPos): Returns the position of the given point in world coordinates system, on the game screen
    • [table] worldPos: The world position of the point
    • return [table]: The position in percentage (between 0 and 1) of the screen resolution as vec3 with {x, y, depth}
Link to comment
Share on other sites

Light

Emits a source of light.

 

Quote

This API has received new features to allow better use of the element.
To be consistent with Lua rendering, the values of the color components are now on the range 0-1 instead of 0-255.

Also, the range is extended to 0-5 for HDR (High Dynamic Range) colors that can make your lights shine.

 

Functions

  • activate(): Switches the light on
  • deactivate(): Switches the light off
  • NEW [int] isActive(): Checks if the light is on
    • DEPRECATED [int] getState() → [int] isActive()
  • toggle(): Toggle the state of the light
     
  • NEW setColor([float] r, [float] g, [float] b): Set the light color in RGB
    • [float] r: The red component, between 0.0 and 1.0
    • [float] g: The green component, between 0.0 and 1.0
    • [float] b: The blue component, between 0.0 and 1.0
    • DEPRECATED setRGBColor() → setColor()
  • NEW [table] getColor(): Returns the light color in RGB
    • return [table]: A vec3 for the red, blue and green components of the light, with values between 0.0 and 1.0
    • DEPRECATED getRGBColor() → getColor()
       
  • NEW setBlinkingState([bool] state): Returns the blinking state of the light
    • [bool] state: True to enable light blinking
  • NEW [int] isBlinking(): Checks if the light blinking is enabled
     
  • NEW [float] getOnBlinkingDuration(): Returns the light 'on' blinking duration
  • NEW setOnBlinkingDuration([float] time): Set the light 'on' blinking duration
    • [float] time: The duration of the 'on' blinking in seconds
  • NEW [float] getOffBlinkingDuration(): Returns the light 'off' blinking duration
  • NEW setOffBlinkingDuration([float] time): Set the light 'off' blinking duration
    • [float] time: The duration of the 'off' blinking in seconds
  • NEW [float] getBlinkingTimeShift(): Returns the light blinking time shift
  • NEW setBlinkingTimeShift([float] shift): Set the light blinking time shift
    • [float] shift: The time shift of the blinking
Link to comment
Share on other sites

Manual Button

Emits a signal for the duration it is pressed.

 

Quote

This API has been modified to improve the user experience and to enforce the event naming convention.

 

Functions

  • NEW [int] isDown(): Checks if the manual button is down
    • DEPRECATED [int] getState() → [int] isDown()

Events

  • NEW onPressed(): Emitted when the button is pressed
    • DEPRECATED pressed() → onPressed()
  • NEW onReleased(): Emitted when the button is released
    • DEPRECATED released() → onReleased()
Link to comment
Share on other sites

Manual Switch

A Manual Switch that can be in an on/off state.

 

Quote

This API has been modified to improve the user experience and to enforce the event naming convention.

 

Functions

  • activate(): Switches the switch on
  • deactivate(): Switches the switch off
  • toggle(): Toggle the switch
  • NEW [int] isActive(): Checks if the switch is active
    • DEPRECATED [int] getState() → [int] isActive()

Events

  • NEW onPressed(): Emitted when the button is pressed
    • DEPRECATED pressed() → onPressed()
  • NEW onReleased(): Emitted when the button is released
    • DEPRECATED released() → onReleased()
Link to comment
Share on other sites

Mining Unit

Extracts a regular amount of resources from the ground.

 

Quote

This API has been modified to improve the user experience and to enforce the event naming convention.

 

Functions

  • NEW [int] getState(): Returns the current state of the mining unit
    • return [int]: The status of the mining unit can be (Stopped = 1, Running = 2, Jammed output full = 3, Jammed no output container = 4)
    • DEPRECATED [int] getStatus() → [int] getState()
  • [float] getRemainingTime(): Returns the remaining time of the current batch extraction process.
     
  • [int] getActiveOre(): Returns the item ID of the currently selected ore.
  • [table] getOrePools(): Returns the list of available ore pools
    • return [table]: A list of tables composed with {[int] oreId, [float] available, [float] maximum).
       
  • [float] getBaseRate(): Returns the base production rate of the mining unit.
  • [float] getEfficiency(): Returns the efficiency rate of the mining unit.
  • [float] getCalibrationRate(): Returns the calibration rate of the mining unit.
  • [float] getOptimalRate(): Returns the optimal calibration rate of the mining unit.
  • [float] getProductionRate(): Returns the current production rate of the mining unit.
  • [float] getAdjacencyBonus(): Returns the territory's adjacency bonus to the territory of the mining unit. Note: This value is updated only when a new batch is started.
     
  • [table] getLastExtractionPosition(): Returns the position of the last calibration excavation, in world coordinates.
  • [int] getLastExtractingPlayerId(): Returns the ID of the last player who calibrated the mining unit.
  • [float] getLastExtractionTime(): Returns the time in seconds since the last calibration of the mining unit.
  • [float] getLastExtractedVolume(): Returns the volume of ore extracted during the last calibration excavation.

Events

  • NEW onStarted([int] oreId): Emitted when the mining unit started a new extraction process.
    • [int] oreId: The item ID of the ore mined during the extraction process
       
  • NEW onCalibrated([int] oreId, [float] amount, [float] rate): Emitted when the mining unit is calibrated.
    • [int] oreId: The item ID of the ore extracted during the calibration process
    • [float] amount: Amount of ore extracted during the calibration process
    • [float] rate: The new calibration rate after calibration process
    • DEPRECATED calibrated([int] oreId, [float] amount, [float] rate) → onCalibrated([int] oreId, [float] amount, [float] rate)
       
  • NEW onCompleted([int] oreId, [float] amount): Emitted when the mining unit complete a batch.
    • [int] oreId: The item ID of the ore mined during the extraction process
    • [float] amount: Amount of ore mined
    • DEPRECATED completed([int] oreId, [float] amount) → onCompleted([int] oreId, [float] amount)
       
  • NEW onStatusChanged([int] status): Emitted when the mining unit status is changed.
    • [int] status: The status of the mining unit can be (Stopped = 1, Running = 2, Jammed output full = 3, Jammed no output container = 4)
    • DEPRECATED statusChanged([int] status) → onStatusChanged([int] status)
       
  • NEW onStopped(): Emitted when the mining unit stopped the extraction process.
Link to comment
Share on other sites

NEW Plasma Extractor

Extracts a regular amount of plasma from the space surrouding an alien core

 

Quote

This API is new to Mercury

 

Functions

  • NEW [int] getStatus(): Returns the current status of the plasma extractor
    • return [int]: The status of the plasma extractor can be (Stopped = 1, Running = 2, Jammed output full = 3, Jammed no output container = 4)
    •  
  • NEW [float] getRemainingTime(): Returns the remaining time of the current batch extraction process.
  • NEW [table] getPlasmaPools(): Returns the list of available plasma pools
    • return [table]: A list of tables composed with {[int] oreId, [float] available, [float] maximum)

Events

  • NEW onStarted(): Emitted when the plasma extractor started a new extraction process
  • NEW onCompleted(): Emitted when the plasma extractor complete a batch
  • NEW onStatusChanged([int] status): Emitted when the plasma extractor status is changed
    • [int] status: The status of the mining unit can be (Stopped = 1, Running = 2, Jammed output full = 3, Jammed no output container = 4)
  • NEW onStopped(): Emitted when the plasma extractor stopped the extraction process
Link to comment
Share on other sites

NEW Player

Player represents the player who is using the control unit

 

Quote

This API has been added to improve the user experience, a simple and more logical access to information related to the local player.
It also receives multiple additions in order to give more control, more creation tools ... etc


 

Functions

  • NEW [string] getName()Returns the player name
  • NEW [int] getId(): Return the ID of the player
     
  • NEW [float] getMass(): Returns the player mass
    • return [float]: The mass of the player in kilograms
  • NEW [float] getNanopackMass(): Returns the player's nanopack content mass
    • return [float]: The player's nanopack content mass in kilograms
  • NEW [float] getNanopackVolume(): Returns the player's nanopack content volume
    • return [float]: The player's nanopack content volume in liters
  • NEW [float] getNanopackMaxVolume(): Returns the player's nanopack maximum volume
    • return [float]: The player's nanopack maximum volume in liters
       
  • NEW [table] getOrgIds(): Returns the list of organization IDs of the player
    • return [table]: The list of organization IDs
  • NEW [table] getPosition(): Returns the position of the player, in construct local coordinates
    • return [table]: The position in construct local coordinates
  • NEW [table] getWorldPosition(): Returns the position of the player, in world coordinates
    • return [table]: The position in world coordinates
  • NEW [table] getHeadPosition(): Returns the position of the head of the player's character, in construct local coordinates
    • return [table]: The position of the head in construct local coordinates
  • NEW [table] getWorldHeadPosition(): Returns the position of the head of the player's character, in world coordinates
    • return [table]: The position of the head in world coordinates
       
  • NEW [table] getVelocity(): Returns the velocity vector of the player, in construct local coordinates
    • return [table]: The velocity vector in construct local coordinates
  • NEW [table] getWorldVelocity(): Returns the velocity vector of the player, in world coordinates
    • return [table]: The velocity vector in world coordinates
  • NEW [table] getAbsoluteVelocity(): Returns the absolute velocity vector of the player, in world coordinates
    • return [table]: The velocity absolute vector in world coordinates

       
  • NEW [table] getForward()Returns the forward direction vector of the player, in construct local coordinates
  • NEW [table] getRight()Returns the right vector of the construct coordinates system
  • NEW [table] getUp()Returns the up direction vector of the player, in construct local coordinates
  • NEW [table] getWorldForward()Returns the forward direction vector of the player, in world coordinates
  • NEW [table] getWorldRight()Returns the right direction vector of the player, in world coordinates
  • NEW [table] getWorldUp()Returns the up direction vector of the player, in world coordinates
     
  • NEW [int] getPlanet()Returns the id of the planet the player is located on
    • return [int]: The id of the planet, 0 if none
  • NEW [int] getParent()Returns the identifier of the construct to which the player is parented
    • return [int]: The id of the construct, 0 if none
       
  • NEW [int] isSeated()Checks if the player is seated
    • return [int]: 1 if the player is seated
  • NEW [int] getSeatId()Returns the local id of the seat on which the player is sitting
    • return [int]: The local id of the seat, or 0 is not seated
  • NEW [int] isParentedTo([int] id)Checks if the player is parented to the given construct
    • [int] id: The construct id
    • return [int]: 1 if the player is parented to the given construct
       
  • NEW [int] isSprinting()Checks if the player is currently sprinting
    • return [int]: 1 if the player is sprinting
  • NEW [int] isJetpackOn()Checks if the player's jetpack is on
    • return [int]: 1 if the player's jetpack is on
  • NEW [int] isHeadlightOn()Returns the state of the headlight of the player
    • return [int]: 1 if the player has his headlight on
  • NEW setHeadlightOn([bool] state)Set the state of the headlight of the player
    • [bool] state: True to turn on headlight
  • NEW freeze([bool] state)Freezes the player movements, liberating the associated movement keys to be used by the script. Note that this function is disabled if the player is not running the script explicitly (pressing F on the Control Unit, vs. via a plug signal)
    • [bool] state: 1 freeze the character, 0 unfreeze the character
  • NEW [int] isFrozen()Checks if the player movements are frozen
    • return [int]: 1 if the player is frozen, 0 otherwise
  • NEW [int] hasDRMAutorization()Checks if the player has DRM autorization to the control unit
    • return [int]: 1 if the player has DRM autorization on the control unit

 

Events

  • NEW onParentChanged([int] oldId, [int] newId)Emitted when the player parent change
    • [int] oldId: The previous parent construct ID
    • [int] newId: The new parent construct ID
Link to comment
Share on other sites

Pressure Tile

Emits a signal when a player walks on the tile.

 

Quote

This API has been modified to improve the user experience and to enforce the event naming convention.

 

Functions

  • NEW [int] isDown(): Checks if the pressure tile is down
    • DEPRECATED [int] getState() → [int] isDown()

Events

  • NEW onPressed(): Emitted when the pressure tile is pressed
    • DEPRECATED pressed() → onPressed()
  • NEW onReleased(): Emitted when the pressure tile is released
    • DEPRECATED released() → onReleased()
Link to comment
Share on other sites

Radar

Get information about the Radar and its current targets

 

Quote

This API has been modified to improve the user experience and to enforce the event naming convention.

Also, since Mercury, you will only need the transponder for dynamic player-owned builds. This means that you will be able to get any information about space/static or abandoned builds.

 

Functions

  • [int] isOperational():  Returns 1 if the radar is not broken, works in the current environment and is not used by another control unit
  • [float] getRange():  Returns the scan range of the radar
  • [table] getIdentifyRanges():  Returns ranges to identify a target based on its core size
    • return [table]: The list of float values for ranges in meters as { xsRange, sRange, mRange, lRange }
       
  • [table] getConstructIds():  Returns the list of construct IDs in the scan range
  • [table] getIdentifiedConstructIds():  Returns the list of identified construct IDs
  • [int] getTargetId():  Returns the ID of the target construct
     
  • [float] getConstructDistance([int] id): Returns the distance to the given construct
    • [int] id: The ID of the construct
  • [int] isConstructIdentified([int] id): Returns 1 if the given construct is identified
    • [int] id: The ID of the construct
  • [int] isConstructAbandoned([int] id): Returns 1 if the given construct was abandoned
    • [int] id: The ID of the construct
  • [string] getConstructCoreSize([int] id): Returns the core size of the given construct
    • [int] id: The ID of the construct
    • return [string]: The core size name; can be 'XS', 'S', 'M', 'L', 'XL'
  • NEW [int] getThreatRateTo([int] id): Returns the threat rate your construct is for the given construct
    • [int] id: The ID of the construct
    • return [int]: The threat rate index (None = 1, Identified = 2, Threatened and identified = 3, Threatened = 4, Attacked = 5), can be -1 if the radar is not operational
    • DEPRECATED [int] getThreatTo([int] id) → [int] getThreatRateTo([int] id)
  • NEW [int] getThreatRateFrom([int] id): Returns the threat rate the given construct is for your construct
    • [int] id: The ID of the construct
    • return [int]: The threat rate index (None = 1, Identified = 2, Threatened and identified = 3, Threatened = 4, Attacked = 5), can be -1 if the radar is not operational
    • DEPRECATED [string] getThreatFrom([int] id) → [int] getThreatRateFrom([int] id)
       
  • [int] hasMatchingTransponder([int] id): Returns whether the target has an active Transponder with matching tags
    • [int] id: The ID of the construct
  • NEW [table] getConstructOwnerEntity([int] id): 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.
    • [int] id: The ID of the construct
    • return [table]: A table with fields {[int] id, [bool] isOrganization} describing the owner. Use system.getPlayerName(id) and system.getOrganization(id) to retrieve info about it
    • DEPRECATED [int] getConstructOwner([int] id) → [int] getConstructOwnerEntity([int] id)
       
  • [table] getConstructSize([int] id): Return the size of the bounding box of the given construct, if in range
    • [int] id: The ID of the construct
  • NEW [int] getConstructKind([int] id): Return the kind of the given construct
    • [int] id: The ID of the construct
    • return [int]: The kind index of the construct (Universe = 1, Planet = 2,Asteroid = 3,Static = 4,Dynamic = 5,Space = 6,Alien = 7)
    • DEPRECATED [string] getConstructType([int] id) → [int] getConstructKind([int] id)
       
  • [table] getConstructPos([int] id): Returns the position of the given construct in construct local coordinates, if active transponder tags match for owned dynamic constructs
    • [int] id: The ID of the construct
  • [table] getConstructWorldPos([int] id): Returns the position of the given construct in world coordinates, if in range and if active transponder tags match for owned dynamic constructs
    • [int] id: The ID of the construct
  • [table] getConstructVelocity([int] id): Returns the velocity vector of the given construct in construct local coordinates, if identified and if active transponder tags match for owned dynamic constructs
    • [int] id: The ID of the construct
  • [table] getConstructWorldVelocity([int] id): Returns the velocity vector of the given construct in world coordinates, if identified and if active transponder tags match for owned dynamic constructs
    • [int] id: The ID of the construct

 

  • [float] getConstructMass([int] id): Returns the mass of the given construct, if identified for owned dynamic constructs
    • [int] id: The ID of the construct
    • return [float]: The mass of the construct in kilograms
  • [string] getConstructName([int] id): Return the name of the given construct, if defined
    • [int] id: The ID of the construct
  • [table] getConstructInfos([int] id): Returns a table of working elements on the given construction, if identified for owned dynamic constructs
    • [int] id: The ID of the construct
    • return [table]: 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
       
  • [float] getConstructSpeed([int] id): Returns the speed of the given construct, if identified for owned dynamic constructs
    • [int] id: The ID of the construct
    • return [float]: The speed of the construct relative to the universe in meters per second
  • [float] getConstructAngularSpeed([int] id): Returns the angular speed of the given construct to your construct, if identified for owned dynamic constructs
    • [int] id: The ID of the construct
    • return [float]: The angular speed of the construct relative to our construct in radians per second
  • [float] getConstructRadialSpeed([int] id): Returns the radial speed of the given construct to your construct, if identified for owned dynamic constructs
    • [int] id: The ID of the construct
    • return [float]: The radial speed of the construct relative to our construct in meters per secon

 

Events

  • NEW onEnter([int] id): Emitted when a Construct enters the scan range of the radar
    • DEPRECATED enter() → onEnter([int] id)
  • NEW onLeave([int] id): Emitted when a construct leaves the range of the radar
    • DEPRECATED leave() → onLeave([int] id)
  • NEW onIdentified([int] id): Emitted when a construct is identified
Link to comment
Share on other sites

Receiver

Receives messages on the element's channels

 

Quote

This API has been modified to improve the user experience and to enforce the event naming convention.

 

Functions

  • [float] getRange(): Returns the receiver range
     
  • [int] hasChannel([string] channel): Checks if the given channel exists in the receiver channels list
    • [string] channel: The channels list as Lua table
  • NEW [int] setChannelList([table] channels): Set the channels list
    • [table] channels: The channels list as Lua table
    • return [int]: 1 if the channels list has been successfully set
    • DEPRECATED setChannels([string] channels) → [int] setChannelList([table] channels)
  • NEW [table] getChannelList(): Returns the channels list
    • [table] channels: The channels list as Lua table
    • DEPRECATED [string] getChannels() → [table] getChannelList()

Events

  • NEW onReceived([string] channel, [string] message): Emitted when a message is received on any channel defined on the element
    • [string] channel: The channel; can be used as a filter
    • [string] message: The message received
    • DEPRECATED receive([string] channel, [string] message) → onReceived([string] channel, [string] message)
Link to comment
Share on other sites

NEW Rocket Engines

Rocket engines are engines capable of producing enormous thrust in a short period of time. They consume fuel but do not need time to warm up.
 

Quote

This API was added as part of an effort to improve the user experience on Lua, especially for new players. In this context, we added multiple specialized APIs for engine type elements to make it more user-friendly than a global engine API.
We took this opportunity to add additional specialized features.

 

Functions

  • activate(): Start the engine at full power (works only when run inside a cockpit or under remote control)
  • deactivate(): Stops the engine (works only when run inside a cockpit or under remote control)
  • NEW [int] isActive(): Checks if the engine is active
    • DEPRECATED [int] getState() → isActive()
  • toggle(): Toggle the state of the engine
     
  • setThrust([float] thrust): Set the thrust of the engine
    • [float] thrust: The engine thrust in newtons (limited by the maximum thrust)
  • [float] getThrust(): Returns the current thrust of the engine
  • NEW [float] getMaxThrust(): Returns the maximal thrust the engine can deliver in principle, under optimal conditions.
    • DEPRECATED [float] getMaxThrustBase() → getMaxLift()
  • NEW [float] getCurrentMinThrust(): Returns the minimal thrust the engine can deliver at the moment (can be more than zero), which will depend on various conditions like atmospheric density, obstruction, orientation, etc
    • DEPRECATED [float] getMinThrust() → getCurrentMinThrust()
  • NEW [float] getCurrentMaxThrust(): Returns the maximal thrust the engine can deliver at the moment, which might depend on various conditions like atmospheric density, obstruction, orientation, etc. The actual thrust will be anything below this maxThrust, which defines the current max capability of the engine
    • DEPRECATED [float] getMaxThrust() → getCurrentMaxThrust()
  • NEW [float] getMaxThrustEfficiency(): Returns the ratio between the current maximum thrust and the optimal maximum thrust
     
  • NEW [int] isTorqueEnabled(): Checks if the torque generation is enabled on the engine
  • NEW enableTorque([bool] state): Sets the torque generation state on the engine
     
  • NEW [vec3] getThrustAxis(): Returns the engine thrust direction in construct local coordinates
  • NEW [vec3] getTorqueAxis(): Returns the engine torque axis in construct local coordinates
  • NEW [vec3] getWorldThrustAxis(): Returns the engine exhaust thrust direction in world coordinates
    • DEPRECATED [vec3] thrustAxis() → getWorldThrustAxis()
  • NEW [vec3] getWorldTorqueAxis(): Returns the engine torque axis in world coordinates
    • DEPRECATED [vec3] torqueAxis() → getWorldTorqueAxis()
       
  • [int] isOutOfFuel(): Checks if the engine out of fuel
  • NEW [int] getFuelId(): Returns the item ID of the fuel currently used by the engine
  • NEW [int] getFuelTankId(): Returns the local ID of the fueltank linked to the engine
  • [int] hasFunctionalFuelTank(): Checks if the engine linked to a functional Fuel Tank (not broken or colliding)
  • [float] getCurrentFuelRate(): Returns the engine fuel consumption rate per newton of thrust delivered per second
  • [float] getFuelRateEfficiency(): Returns the ratio between the current fuel rate and the theoretical nominal fuel rate
  • [float] getFuelConsumption(): Returns the current fuel consumption rate
     
  • NEW [float] getWarmupTime(): Returns the T50; the time needed for the engine to reach 50% of its maximal thrust (all engines do not instantly reach the thrust that is set for them, but they can take time to "warm up" to the final value)
    • DEPRECATED [float] getT50() → getWarmupTime()
       
  • [float] getObstructionFactor(): Returns the obstruction ratio of the engine exhaust by Elements and Voxels. The more obstructed the engine is, the less properly it will work. Try to fix your design if this is the case.
  • [string] getTags(): Returns the tags of the engine
  • [string] setTags([string] tags,[boolean] ignore): Set the tags of the engine
    • [string] tags: The CSV string of the tags
    • [bool] ignore: True to ignore the default engine tags
  • [int] isIgnoringTags(): Checks if the engine is ignoring default tags
     
  • DEPRECATED getDistance() → No reason to keep it from Engine API, only works for hover engines and vertical boosters
Link to comment
Share on other sites

NEW Screen Unit

Screens can display any HTML code or text message, and you can use them to create visually interactive feedback for your running Lua script by connecting one or more of them to your Control Unit.
 

Quote

This API has been modified to apply the event naming convention and add the onOutputChanged event added to improve the user experience with Lua screens.

 

Functions

  • activate(): Switch on the screen
  • deactivate(): Switch off the screen
  • NEW [int] isActive(): Checks if the screen is on
    • DEPRECATED [int] getState() → [int] isActive()
  • toggle(): Toggle the state of the screen
     
  • [int] addText([float] x,[float] y,[float] fontSize,[string] text): Displays the given text at the given coordinates in the screen, and returns an ID to move it later
    • [float] x: Horizontal position, as a percentage (between 0 and 100) of the screen width
    • [float] y: Vertical position, as a percentage (between 0 and 100) of the screen height
    • [float] fontSize: Text font size, as a percentage of the screen width
    • [string] text: The text to display
    • return [int]: An integer ID that is used to identify the Element in the screen. Methods such as setContent return the id that you can store to use later here
  • setCenteredText([string] text): Displays the given text centered in the screen with a font to maximize its visibility
    • [string] text: The text to display
       
  • setHTML([string] html): Set the whole screen HTML content (overrides anything already set)
    • [string] html: The HTML content to display
  • setRenderScript([string] script): Set the screen render script, switching the screen to native rendering mode
    • [string] script: The Lua render script
  • setScriptInput([string] input): Defines the input of the screen rendering script, which will be automatically defined during the execution of Lua
    • [string] input: A string that can be retrieved by calling getInput in a render script
  • clearScriptOutput(): Set the screen render script output to the empty string
  • [string] getScriptOutput(): Get the screen render script output
    • return [string]: The contents of the last render script setOutput call, or an empty string

 

  • [int] addContent([float] x, [float] y, [string] html): Displays the given HTML content at the given coordinates in the screen, and returns an ID to move it later
    • [float] x: Horizontal position, as a percentage (between 0 and 100) of the screen width
    • [float] y: Vertical position, as a percentage (between 0 and 100) of the screen height
    • [string] html: The HTML content to display, which can contain SVG elements to make drawings
    • return [int]: An integer ID that is used to identify the html element in the screen.
  • setSVG([string] svg): Displays SVG code (anything that fits within a <svg> section), which overrides any preexisting content
    • [string] svg: The SVG content to display, which fits inside a 1920x1080 canvas
  • resetContent([int] id, [string] html):  Update the html element with the given ID (returned by addContent) with a new HTML content
    • [int] id: An integer ID that is used to identify the html element in the screen. Methods such as addContent return the ID that you can store to use later here
    • [string] html: The HTML content to display, which can contain SVG elements to make drawings
  • deleteContent([int] id): Delete the html element with the given ID (returned by addContent)
    • [int] id: An integer ID that is used to identify the html element in the screen. Methods such as addContent return the id that you can store to use later here
  • showContent([int] id, [bool] state): Update the visibility of the html element with the given ID (returned by addContent)
    • [int] id: An integer ID that is used to identify the html element in the screen. Methods such as addContent return the ID that you can store to use later here
    • [bool] state: true to show the content, false to hide
  • moveContent([int] id, [float] x, [float] y): Move the html element with the given id (returned by addContent) to a new position in the screen
    • [int] id: An integer id that is used to identify the html element in the screen. Methods such as addContent return the ID that you can store to use later here
    • [float] x: Horizontal position, as a percentage (between 0 and 100) of the screen width
    • [float] y: Vertical position, as a percentage (between 0 and 100) of the screen height

 

  • [float] getMouseX(): Returns the x-coordinate of the position point at in the screen
    • return [float]: The x-position as a percentage (between 0 and 1) of screen width; -1 if nothing is point at
  • [float] getMouseY(): Returns the y-coordinate of the position point at in the screen
    • return [float]: The y-position as a percentage (between 0 and 1) of screen height; -1 if nothing is point at
  • [int] getMouseState(): Returns the state of the mouse click
    • return [int]:  1 if the mouse is pressed, otherwise 0

 

  • clear(): Clear the screen

 

Events

  • NEW onMouseDown([float] x, [float] y): Emitted when the player starts a click on the screen
    • [float] x: X-coordinate of the click in percentage (between 0 and 1) of the screen width
    • [float] y: Y-coordinate of the click in percentage (between 0 and 1) the screen height
    • DEPRECATED mouseDown([float] x, [float] y) → onMouseDown([float] x, [float] y)
  • NEW onMouseUp([float] x, [float] y): Emitted when the player releases a click on the screen
    • [float] x: X-coordinate of the click in percentage (between 0 and 1) of the screen width
    • [float] y: Y-coordinate of the click in percentage (between 0 and 1) the screen height
    • DEPRECATED mouseUp([float] x, [float] y) → onMouseUp([float] x, [float] y)
       
  • NEW onOutputChanged([string] output): Emitted when the output of the screen is changed
    • [string] output: The output string of the screen
Link to comment
Share on other sites

NEW Space Brake

Space brakes are retro-rocket elements designed to produce thrust opposite to the movement of a construct in space, acting as a space brake. It that can be used to slow down your construct.

 

Quote

This API was added as part of an effort to improve the user experience on Lua, especially for new players. In this context, we added multiple specialized APIs for engine type elements to make it more user-friendly than a global engine API.
We took this opportunity to add additional specialized functions.

 

Functions

  • activate()Start the brake at full power (works only when run inside a cockpit or under remote control)
  • deactivate(): Stops the brake (works only when run inside a cockpit or under remote control)
  • NEW [int] isActive(): Checks if the brake is active
    • DEPRECATED [int] getState() → isActive()
  • toggle(): Toggle the state of the brake
     
  • setThrust([float] thrust): Set the thrust of the brake. Note that brakes can generate a force only in the movement opposite direction
    • [float] thrust: The brake thrust in newtons (limited by the maximum thrust)
  • [float] getThrust(): Returns the current thrust of the brake
  • NEW [float] getMaxThrust(): Returns the maximal thrust the brake can deliver in principle, under optimal conditions.
    • DEPRECATED [float] getMaxThrustBase() → getMaxThrust()
  • NEW [float] getCurrentMinThrust(): Returns the minimal thrust the brake can deliver at the moment (can be more than zero), which will depend on various conditions like atmospheric density, obstruction, orientation, etc.
    • DEPRECATED [float] getMinThrust() → getCurrentMinThrust()
  • NEW [float] getCurrentMaxThrust(): Returns the maximal thrust the brake can deliver at the moment, which might depend on various conditions like atmospheric density, obstruction, orientation, etc.
    • DEPRECATED [float] getMaxThrust() → getCurrentMaxThrust()
       
  • [float] getMaxThrustEfficiency(): Returns the ratio between the current maximum thrust and the optimal maximum thrust
  • NEW [vec3] getThrustAxis(): Returns the brake thrust direction in construct local coordinates
  • NEW [vec3] getWorldThrustAxis(): Returns the brake thrust direction in world coordinates
    • DEPRECATED [vec3] thrustAxis() → getWorldThrustAxis()
       
  • [float] getObstructionFactor(): Returns the obstruction ratio of the engine exhaust by Elements and Voxels. The more obstructed the engine is, the less properly it will work. Try to fix your design if this is the case.
  • [string] getTags(): Returns the tags of the engine
  • [string] setTags([string] tags,[boolean] ignore): Set the tags of the engine
    • [string] tags: The CSV string of the tags
    • [bool] ignore: True to ignore the default engine tags
  • [int] isIgnoringTags(): Checks if the engine is ignoring default tags

 

  • DEPRECATED [int] isOutOfFuel() → No reason to keep it from Engine API
  • DEPRECATED [int] hasFunctionalFuelTank() → No reason to keep it from Engine API
  • DEPRECATED [float] getCurrentFuelRate() → No reason to keep it from Engine API
  • DEPRECATED [float] getFuelRateEfficiency() → No reason to keep it from Engine API
  • DEPRECATED [float] getFuelConsumption() → No reason to keep it from Engine API
  • DEPRECATED [float] getDistance() → No reason to keep it from Engine AP
  • DEPRECATED [float] getT50() → No reason to keep it from Engine API
  • DEPRECATED [float] torqueAxis() → No reason to keep it from Engine API
Link to comment
Share on other sites

NEW Space Engines

Space engines are engines designed to operate optimally in the space void.

 

Quote

This API was added as part of an effort to improve the user experience on Lua, especially for new players. In this context, we added multiple specialized APIs for engine type elements to make it more user-friendly than a global engine API.
We took this opportunity to add additional specialized functions.

 

Functions

  • activate(): Start the engine at full power (works only when run inside a cockpit or under remote control)
  • deactivate(): Stops the engine (works only when run inside a cockpit or under remote control)
  • NEW [int] isActive(): Checks if the engine is active
    • DEPRECATED [int] getState() → isActive()
  • toggle(): Toggle the state of the engine
     
  • setThrust([float] thrust): Set the thrust of the engine
    • [float] thrust: The engine thrust in newtons (limited by the maximum thrust)
  • [float] getThrust(): Returns the current thrust of the engine
  • NEW [float] getMaxThrust(): Returns the maximal thrust the engine can deliver in principle, under optimal conditions.
    • DEPRECATED [float] getMaxThrustBase() → getMaxLift()
  • NEW [float] getCurrentMinThrust(): Returns the minimal thrust the engine can deliver at the moment (can be more than zero), which will depend on various conditions like atmospheric density, obstruction, orientation, etc
    • DEPRECATED [float] getMinThrust() → getCurrentMinThrust()
  • NEW [float] getCurrentMaxThrust(): Returns the maximal thrust the engine can deliver at the moment, which might depend on various conditions like atmospheric density, obstruction, orientation, etc. The actual thrust will be anything below this maxThrust, which defines the current max capability of the engine
    • DEPRECATED [float] getMaxThrust() → getCurrentMaxThrust()
  • NEW [float] getMaxThrustEfficiency(): Returns the ratio between the current maximum thrust and the optimal maximum thrust
     
  • NEW [int] isTorqueEnabled(): Checks if the torque generation is enabled on the engine
  • NEW enableTorque([bool] state): Sets the torque generation state on the engine
     
  • NEW [vec3] getThrustAxis(): Returns the engine thrust direction in construct local coordinates
  • NEW [vec3] getTorqueAxis(): Returns the engine torque axis in construct local coordinates
  • NEW [vec3] getWorldThrustAxis(): Returns the engine exhaust thrust direction in world coordinates
    • DEPRECATED [vec3] thrustAxis() → getWorldThrustAxis()
  • NEW [vec3] getWorldTorqueAxis(): Returns the engine torque axis in world coordinates
    • DEPRECATED [vec3] torqueAxis() → getWorldTorqueAxis()
       
  • [int] isOutOfFuel(): Checks if the engine out of fuel
  • NEW [int] getFuelId(): Returns the item ID of the fuel currently used by the engine
  • NEW [int] getFuelTankId(): Returns the local ID of the fueltank linked to the engine
  • [int] hasFunctionalFuelTank(): Checks if the engine linked to a functional Fuel Tank (not broken or colliding)
  • [float] getCurrentFuelRate(): Returns the engine fuel consumption rate per newton of thrust delivered per second
  • [float] getFuelRateEfficiency(): Returns the ratio between the current fuel rate and the theoretical nominal fuel rate
  • [float] getFuelConsumption(): Returns the current fuel consumption rate
     
  • NEW [float] getWarmupTime(): Returns the T50; the time needed for the engine to reach 50% of its maximal thrust (all engines do not instantly reach the thrust that is set for them, but they can take time to "warm up" to the final value)
    • DEPRECATED [float] getT50() → getWarmupTime()
       
  • [float] getObstructionFactor(): Returns the obstruction ratio of the engine exhaust by Elements and Voxels. The more obstructed the engine is, the less properly it will work. Try to fix your design if this is the case.
  • [string] getTags(): Returns the tags of the engine
  • [string] setTags([string] tags,[boolean] ignore): Set the tags of the engine
    • [string] tags: The CSV string of the tags
    • [bool] ignore: True to ignore the default engine tags
  • [int] isIgnoringTags(): Checks if the engine is ignoring default tags
     
  • DEPRECATED getDistance() → No reason to keep it from Engine API, only works for hover engines and vertical boosters
Link to comment
Share on other sites

System

System is a virtual Element that represents your computer. It gives access to events like key strokes or mouse movements that can be used inside your scripts. It also gives you access to regular updates that can be used to pace the execution of your script

 

Quote

This API receives some minor changes and additions in order to standardize and enforce the new event naming convention.
In addition, a new action has been added for the onActionStart, onActionStop and onActionLoop events, `leftmouse` which is emitted when the player use the left mouse click. This click is only detected when it is not already captured by the game interface.


Additional note:
A part of the Control Unit API may potentially change again with the next flight configuration.

 

Functions

  • [string] getActionKeyName([string] actionName): Return the currently key bound to the given action. Useful to display tips.

    • [string] actionName: The action name, represented as a string taken among the set of predefined Lua-available actions (you can check the drop down list to see what is available)

    • return [string]: The key associated to the given action name
       

  • showScreen([bool] bool)Control the display of the Control Unit custom screen, where you can define customized display information in HTML. Note that this function is disabled if the player is not running the script explicitly (pressing F on the Control Unit, vs. via a plug signal).

    • [bool] bool: True to show the screen, false to hide the screen

  • setScreen([string] content): Set the content of the Control Unit custom screen with some HTML code. Note that this function is disabled if the player is not running the script explicitly (pressing F on the Control Unit, vs. via a plug signal).

    • [string] content: The HTML content you want to display on the screen widget. You can also use SVG here to make drawings.
       

  • [string] createWidgetPanel([string] label): Create an empty panel. Note that this function is disabled if the player is not running the script explicitly (pressing F on the Control Unit, vs. via a plug signal).

    • [string] label: The title of the panel

    • return [string]: The panel ID, or "" on failure

  • [int] destroyWidgetPanel([string] panelId): Destroy the panel. Note that this function is disabled if the player is not running the script explicitly (pressing F on the Control Unit, vs. via a plug signal).

    • [string] panelId: The panel ID

    • return [int]: 1 on success, 0 on failure.

  • [string] createWidget([string] panelId, [string] type): Create an empty widget and add it to a panel. Note that this function is disabled if the player is not running the script explicitly (pressing F on the Control Unit, vs. via a plug signal).

    • [string] panelId: The panel ID

    • [string] type: Widget type, determining how it will display data attached to ID

    • return [string]: The widget ID, or "" on failure.

  • [int] destroyWidget([string] widgetId): Destroy the widget. Note that this function is disabled if the player is not running the script explicitly (pressing F on the Control Unit, vs. via a plug signal).

    • [string] widgetId: The widget ID

    • return [int]: 1 on success, 0 on failure.
       

  • [string] createData([string] dataJson): Create data. Note that this function is disabled if the player is not running the script explicitly (pressing F on the Control Unit, vs. via a plug signal).

    • [string] dataJson: The data fields as JSON

    • return [string]: The data ID, or "" on failure.

  • [intdestroyData([string] dataId): Destroy the data. Note that this function is disabled if the player is not running the script explicitly (pressing F on the Control Unit, vs. via a plug signal).

    • [string] dataId: The data ID

    • return [int]: value 1 on success, 0 on failure.

  • [intupdateData([string] dataId, [string] dataJson): Update JSON associated to data. Note that this function is disabled if the player is not running the script explicitly (pressing F on the Control Unit, vs. via a plug signal).

    • [string] dataId: The data ID

    • [string]dataJson: The data fields as JSON

    • return [int]: value 1 on success, 0 on failure.

 

  • [intaddDataToWidget([string] dataId, [string] widgetId): Add data to widget.Note that this function is disabled if the player is not running the script explicitly (pressing F on the Control Unit, vs. via a plug signal).

    • [string] dataId: The data ID

    • [string] widgetId : The widget ID

    • return [int]: value 1 on success, 0 on failure.

  • [intremoveDataFromWidget([string] dataId, [string] widgetId ): Remove data from widget. Note that this function is disabled if the player is not running the script explicitly (pressing F on the Control Unit, vs. via a plug signal).

    • [string] dataId: The data ID

    • [string] widgetId : The widget ID

    • return [int]: value 1 on success, 0 on failure.
       

  • [float] getMouseWheel(): Return the current value of the mouse wheel
  • [float] getMouseDeltaX(): Return the current value of the mouse delta X
  • [float] getMouseDeltaY(): Return the current value of the mouse delta Y
  • [float] getMousePosX(): Return the current value of the mouse pos X
  • [float] getMousePosY(): Return the current value of the mouse pos Y
  • [float] getMouseSensitivity(): Return the value of mouse sensitivity game setting
  •  
  • [float] getScreenHeight(): Return the current value of the screen height
  • [float] getScreenWidth(): Return the current value of the screen width
  • [float] getCameraHorizontalFov(): Return the current value of the player's horizontal field of view
  • [float] getCameraVerticalFov(): Return the current value of the player's vertical field of view
  • [int] getCameraMode(): Returns the active camera mode.
    • return [int]: 1: First Person View, 2: Look Around Construct View, 3: Follow Construct View
  • [int] isFirstPerson(): Checks if the active camera is in first person view.
     
  • [int] getCameraPos(): Returns the position of the camera, in construct local coordinates.
  • [int] getCameraWorldPos(): Returns the position of the camera, in world coordinates.
  • [int] getCameraForward(): Returns the forward direction vector of the active camera, in construct local coordinates.
  • [int] getCameraRight(): Returns the right direction vector of the active camera, in construct local coordinates.
  • [int] getCameraUp(): Returns the up direction vector of the active camera, in construct local coordinates.
  • [int] getCameraWorldForward(): Returns the forward direction vector of the active camera, in world coordinates.
  • [int] getCameraWorldRight(): Returns the right direction vector of the active camera, in world coordinates.
  • [int] getCameraWorldUp(): Returns the up direction vector of the active camera, in world coordinates.

 

  • [float] getThrottleInputFromMouseWheel(): Return the current value of the mouse wheel (for the throttle speedUp/speedDown action). This value will go through the control scheme, devices and sensitivity
  • [float] getControlDeviceForwardInput(): Return the mouse input for the ship control action (forward/backward). This value will go through the control scheme, devices and sensitivity
  • [float] getControlDeviceYawInput(): Return the mouse input for the ship control action  (yaw right/left). This value will go through the control scheme, devices and sensitivity
  • [float] getControlDeviceLeftRightInput(): Return the mouse input for the ship control action  (right/left). This value will go through the control scheme, devices and sensitivity

 

  • lockView([bool] state): Lock or unlock the mouse free look.
  • [int] isViewLocked(): Return the lock state of the mouse free look

 

  • DEPRECATED freeze([int] state) → player.freeze([bool] state)
  • DEPRECATED [int] isFrozen() → [int] player.isFrozen()

 

  • [float] getArkTime(): Return the current time since the arrival of the Arkship on September 30th, 2017
  • [float] getUtcTime(): Return the current time since January 1st, 1970.
  • [float] getUtcOffset(): Return the time offset between local timezone and UTC

 

  • NEW [string] getLocale(): Return the locale in which the game is currently running
    • return [string]: The locale, currently one of "en-US", "fr-FR", or "de-DE"
       
  • [float] getActionUpdateDeltaTime(): Return delta time of action updates (to use in ActionLoop)
    • return [float]: The delta time in second
       
  • [string] getPlayerName([int] id): Return the name of the given player, if in range of visibility or broadcasted by a transponder
    • [int] id: The ID of the player
    • return [string]: The name of the player
  • [table] getPlayerWorldPos([int] id): Return the world position of the given player, if in range of visibility
    • [int] id: The ID of the player
    • return [table]: The coordinates of the player in world coordinates
       
  • [table] getItem([int] id): Return the item table corresponding to the given item ID.
    • [int] id: The ID of the item
    • return [table]: An item table with fields: {[integer] 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}
  • NEW [table] getSchematic([int] id): Returns the schematic table corresponding to the given schematic ID
    • [int] id: The Schematic Id, as returned for example by the getCurrentSchematic industry Lua API
    • return [table]: A schematic table with field: {[integer] id, [integer] tier,[integer] time, products:{{[integer] id, [double] quantity},...}, components:{{[integer] id, [double] quantity},...}}
  • NEW [table] getOrganization([int] id): Returns the corresping organization to the given organization id, if known, e.g. broadcasted by a transponder
    • [int] id: The ID of the organization
    • return [table]: A table containing information about the given organization {[string] name, [string] tag}
    • DEPRECATED [string] getOrganizationName([int] id) → [string] getOrganization([int] id).name
    • DEPRECATED [string] getOrganizationTag([int] id) → [string] getOrganization([int] id).tag
       
  • [string] getWaypointFromPlayerPos(): Return the player's world position as a waypoint string, starting with '::pos' (only in explicit runs)
     
  • NEW setWaypoint([string] waypointStr, [bool] notify): Set a waypoint at the destination described by the waypoint string, of the form '::pos{...}' (only in explicit runs)
    • [string] waypointStr: The waypoint as a string
    • NEW [bool] notify: (Optional) True to display a notification on waypoint change
  • NEW clearWaypoint([bool] notify): Clear the active destination waypoint. (only in explicit runs)'
    • NEW [bool] notify: (Optional) True to display a notification about the waypoint's clearing
       
  • showHelper([bool] show): Set the visibility of the helper top menu.
     
  • playSound([string] filePath): Play a sound file from your audio folder (located in "My documents/NQ/DualUniverse/audio"). Only one sound can be played at a time.
    • filePath: Relative path to audio folder (.mp3, .wav)
  • NEW [int] isPlayingSound(): Checks if a sound is playing
  • stopSound(): Stop the current playing sound

 

 

Events

  • NEW onActionStart([string] action): Emitted when an action starts
    • [string] action: The action name, represented as a string taken among the set of predefined Lua-available actions (you can check the drop down list to see what is available)
    • DEPRECATED actionStart([string] action) → onActionStart([string] action)
  • NEW onActionStop([string] action): Emitted when an action stops
    • [string] action: The action name, represented as a string taken among the set of predefined Lua-available actions (you can check the drop down list to see what is available)
    • DEPRECATED actionStop([string] action) → onActionStop([string] action)
  • NEW onActionLoop([string] action): Emitted at each update as long as the action is maintained
    • [string] action: The action name, represented as a string taken among the set of predefined Lua-available actions (you can check the drop down list to see what is available)
    • DEPRECATED actionLoop([string] action) → onActionLoop([string] action)
       
  • NEW onUpdate(): Game update event. This is equivalent to a timer set at 0 seconds, as updates will go as fast as the FPS can go
    • DEPRECATED update() → onUpdate()
  • NEW onFlush(): Game update event. This is equivalent to a timer set at 0 seconds, as updates will go as fast as the FPS can go
    • DEPRECATED flush() → onFlush()
  • NEW onInputText([string] text): A new message has been entered in the Lua tab of the chat, acting like a command line interface
    • DEPRECATED inputText([string] text) → onInputText([string] text)
  • NEW onCameraChanged([int] mode): Emitted when the player changes the camera mode.
    • DEPRECATED cameraChanged([int] mode) → onCameraChanged([int] mode)

       

Link to comment
Share on other sites

Telemeter

Measures the distance to an obstacle in front of it.

 

Quote

This API has been modified to improve the user experience and to enforce the event naming convention.
In addition, we wanted to make this element more interesting by changing the way it works to something more detailed.

 

Functions

  • DEPRECATED [float] getDistance() → [float] raycast().Distance
     
  • NEW [table] raycast(): Emits a raycast from the telemeter, returns a raycastHit object
    • return [table]: A table with fields : {[bool] hit, [float] distance, [vec3] point}
       
  • NEW [table] getRayOrigin(): Returns telemeter raycast origin in local construct coordinates
  • NEW [table] getRayWorldOrigin(): Returns telemeter raycast origin in world coordinates
  • NEW [table] getRayAxis(): Returns telemeter raycast axis in local construct coordinates
  • NEW [table] getRayWorldAxis(): Returns telemeter raycast axis in world coordinates
     
  • NEW [table] getMaxDistance(): Returns the max distance from which an obstacle can be detected (default is 100m)
Link to comment
Share on other sites

  

Transponder

Broadcasts data to radars, that can access more information if their transponder tags are matching

 

Quote

This API has been modified to enforce the event naming convention.

 

Functions

  • activate(): Activate the transponder
  • deactivate(): Deactivate the transponder
  • toggle(): Toggle the state of the transponder
  • [int] isActive(): Checks if the transponder is active
    • DEPRECATED [int] getState() → [int] isActive()
       
  • [int] setTags(): Set the tags list with up to 8 entries. Returns 1 if the application was successful, 0 if the tag format is invalid.
    • [table] tags: List of up to 8 transponder tag strings
  • [table] getTags(): Returns the tag list
    • return [table]: List of up to 8 transponder tag strings

 

Events

  • NEW onToggled([int] active): Emitted when the transponder is started or stopped
    • [int] active: 1 if the element was activated, 0 otherwise
    • DEPRECATED toggled([int] active) → onToggled([int] active)
       
Link to comment
Share on other sites

NEW Vertical Boosters

Vertical boosters are engines designed to produce powerful vertical thrust over a limited distance. They consume space fuel but operate in the atmosphere and in the space void.

 

Quote

This API was added as part of an effort to improve the user experience on Lua, especially for new players. In this context, we added multiple specialized APIs for engine type elements to make it more user-friendly than a global engine API.
We took this opportunity to add additional specialized functions.

 

Functions

  • activate(): Start the engine at full power (works only when run inside a cockpit or under remote control)
  • deactivate(): Stops the engine (works only when run inside a cockpit or under remote control)
  • NEW [int] isActive(): Checks if the engine is active
    • DEPRECATED [int] getState() → isActive()
  • toggle(): Toggle the state of the engine
     
  • setThrust([float] thrust): Set the thrust of the engine
    • [float] thrust: The engine thrust in newtons (limited by the maximum thrust)
  • [float] getThrust(): Returns the current thrust of the engine
  • NEW [float] getMaxThrust(): Returns the maximal thrust the engine can deliver in principle, under optimal conditions.
    • DEPRECATED [float] getMaxThrustBase() → getMaxLift()
  • NEW [float] getCurrentMinThrust(): Returns the minimal thrust the engine can deliver at the moment (can be more than zero), which will depend on various conditions like atmospheric density, obstruction, orientation, etc
    • DEPRECATED [float] getMinThrust() → getCurrentMinThrust()
  • NEW [float] getCurrentMaxThrust(): Returns the maximal thrust the engine can deliver at the moment, which might depend on various conditions like atmospheric density, obstruction, orientation, etc. The actual thrust will be anything below this maxThrust, which defines the current max capability of the engine
    • DEPRECATED [float] getMaxThrust() → getCurrentMaxThrust()
  • NEW [float] getMaxThrustEfficiency(): Returns the ratio between the current maximum thrust and the optimal maximum thrust
     
  • NEW [int] isTorqueEnabled(): Checks if the torque generation is enabled on the engine
  • NEW enableTorque([bool] state): Sets the torque generation state on the engine
     
  • NEW [vec3] getThrustAxis(): Returns the engine thrust direction in construct local coordinates
  • NEW [vec3] getTorqueAxis(): Returns the engine torque axis in construct local coordinates
  • NEW [vec3] getWorldThrustAxis(): Returns the engine exhaust thrust direction in world coordinates
    • DEPRECATED [vec3] thrustAxis() → getWorldThrustAxis()
  • NEW [vec3] getWorldTorqueAxis(): Returns the engine torque axis in world coordinates
    • DEPRECATED [vec3] torqueAxis() → getWorldTorqueAxis()
       
  • [int] isOutOfFuel(): Checks if the engine out of fuel
  • NEW [int] getFuelId(): Returns the item ID of the fuel currently used by the engine
  • NEW [int] getFuelTankId(): Returns the local ID of the fueltank linked to the engine
  • [int] hasFunctionalFuelTank(): Checks if the engine linked to a functional Fuel Tank (not broken or colliding)
  • [float] getCurrentFuelRate(): Returns the engine fuel consumption rate per newton of thrust delivered per second
  • [float] getFuelRateEfficiency(): Returns the ratio between the current fuel rate and the theoretical nominal fuel rate
  • [float] getFuelConsumption(): Returns the current fuel consumption rate
     
  • NEW [float] getWarmupTime(): Returns the T50; the time needed for the engine to reach 50% of its maximal thrust (all engines do not instantly reach the thrust that is set for them, but they can take time to "warm up" to the final value)
    • DEPRECATED [float] getT50() → getWarmupTime()
  • [float] getDistance(): Returns the distance to the first object detected in the direction of the thrust
  • NEW [float] getMaxDistance(): Returns the maximum functional distance from the ground
     
  • [float] getObstructionFactor(): Returns the obstruction ratio of the engine exhaust by Elements and Voxels. The more obstructed the engine is, the less properly it will work. Try to fix your design if this is the case.
  • [string] getTags(): Returns the tags of the engine
  • [string] setTags([string] tags,[boolean] ignore): Set the tags of the engine
    • [string] tags: The CSV string of the tags
    • [bool] ignore: True to ignore the default engine tags
  • [int] isIgnoringTags(): Checks if the engine is ignoring default tags
Link to comment
Share on other sites

 Warp Drive

Based on the principle of the Alcubierre drive, this unit creates a powerful negative energy-density field capable of distorting space-time and transport your ship at hyper speeds through space.

 

Quote

The API has received multiple additions to make it easier to control and monitor.
 

The initiate function has also been reinstated following changes in warp behavior, adding a delay between the initialization of the jump and the actual jump.

However, note that there is no question today of adding a stop function in order to avoid automating the stop of the warp for malicious use.

 

Functions

  • NEW initiate(): Initiate the warp jump process
     
  • NEW [int] getStatus(): Returns the current status of the warp drive
    • return [int]: The current status of the warp drive (NoWarpDrive = 1, Broken = 2, Warping = 3, ParentWarping = 4, NotAnchored = 5, WarpCooldown = 6, PvPCooldown = 7, MovingChild = 8, NoContainer = 9, PlanetTooClose = 10, DestinationNotSet = 11, DestinationTooClose = 12, DestinationTooFar = 13, NotEnoughWarpCells = 14, Ready = 15)
       
  • NEW [float] getDistance(): Returns the distance to the current warp destination
  • NEW [int] getDestination(): Returns the construct ID of the current warp destination
  • NEW [string] getDestinationName(): Returns the name of the current warp destination construct
     
  • NEW [int] getContainerId(): Returns the local id of the container linked to the warp drive
  • NEW [int] getAvailableWarpCells(): Returns the quantity of warp cells available in the linked container
  • NEW [int] getRequiredWarpCells(): Returns the quantity of warp cells required to warp to the warp destination set
Link to comment
Share on other sites

 NEW Weapon

Displays information about the weapon's state

 

Quote

This API has been added to allow easier monitoring of weapons in combat. It also adds some events to better follow the progress of a fight.

 

Functions

  • NEW [int] getAmmo(): Returns the item id of the currently equipped ammo
  • NEW [int] getAmmoCount(): Returns the current amount of remaining ammunition
  • NEW [int] getMaxAmmo(): Returns the maximum amount of ammunition the weapon can carry
  • NEW [int] isOutOfAmmo(): Checks if the weapon is out of ammo
     
  • NEW [int] isOperational(): Checks if the weapon is operational
  • NEW [int] getStatus(): Returns the current weapon status
    • return [int]: The current status of the weapon (Idle = 1, Firing = 2, Reloading = 3, Unloading = 4)
       
  • NEW [int] getContainerId(): Returns the local id of the container linked to the weapon
     
  • NEW [float] getHitProbability(): Returns the current hit probability of the weapon for the current target
  • NEW [float] getBaseDamage(): Returns the base weapon damage
  • NEW [float] getOptimalAimingCone(): Returns the optimal aim cone
  • NEW [float] getOptimalDistance(): Returns the optimal distance to target
  • NEW [float] getMaxDistance(): Returns the maximum distance to target
  • NEW [float] getOptimalTracking(): Returns the optimal tracking rate
  • NEW [float] getMagazineVolume(): Returns the magazine volume
  • NEW [float] getCycleTime(): Returns the weapon cycle time
  • NEW [float] getReloadTime(): Returns the weapon reload time
  • NEW [float] getUnloadTime(): Returns the weapon unload time
     
  • NEW [float] getTargetId(): Returns the id of the current target construct of the weapon

 

Events

  • NEW onReload([int] ammoId): Emitted when the weapon start reloading
    • [int] ammoId: The item id of the ammo
  • NEW onReloaded([int] ammoId): Emitted when the weapon has reloaded
    • [int] ammoId: The item id of the ammo
       
  • NEW onMissed([int] targetId): Emitted when the weapon has missed its target
    • [int] targetId: The construct id of the target
  • NEW onDestroyed([int] targetId): Emitted when the weapon target has been destroyed
    • [int] targetId: The construct id of the target
  • NEW onElementDestroyed([int] targetId, [int] itemId): Emitted when an element on the weapon target has been destroyed
    • [int] targetId: The construct id of the target
    • [int] itemId:The item id of the destroyed element
  • NEW onHit([int] targetId, [float] damage): Emitted when the weapon has hit
    • [int] targetId: The construct id of the target
    • [int] damage: The damage amount dealt by the hit
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...