Jump to content

INFO: DETAILED LUA API REVAMP


NQ-Ligo

Recommended Posts

Hello noveans! As explained in the Mercury Lua devblog, the update is bringing too many changes to list them in such an article. We therefore decided to detail them on a separate thread for players interested in the details!


LUA API CHANGES

In this post, we will then go through each API, one by one, identifying the new additions and changes in the alphabetic order.

To list the general changes:

  • Added new `player` permanent slot. Represents the local player, usually called MasterPlayer in the API. Give access to name, id, nanopack mass/volume, headlight control, parenting, etc.
  • Added new `construct` permanent slot. Represents the control unit construct, usually accessed through the Core Unit API. Give access to name, warp status, pvp status, more physics data, etc.
  • Implemented new naming convention for events.
  • Changed container content acquisition behavior to a fixed minimum inter-request delay of 30 sec.
  • Added more item API support in containers and industry API.
  • Added specialized API for all engine type elements, such as wings, adjusters, atmospheric engines, space engines, airbrakes, space brakes, vertical boosters, hover engines, rocket engines.
  • Added Lua API for weapons
  • Added Lua API for plasma extractor
  • Re-enabled HDR color support for lights
  • Added Lua left mouse click action for onActionStart, onActionStop and onActionLoop events, as "leftmouse".
  • Replaced all string status values with integers for better comparisons and to be future-proof.
  • Redesigned the Counter element API to make it more interesting.
  • Redesigned the Telemeter element API to make it more interesting.
  • Added several useful functions on different elements

 

I invite you at the same time to study the details of the changes in the posts of this thread to see all the subtleties!


As stated in the previous devblog, our goal is to remove all depreciation at launch. However, this will remain dependent on our ability to release the new flight configuration before then and on the feedback we get from our community.
In any case, we will keep you informed if this is retained at release.



LUA API MOCKUP ON GITHUB!


In addition to that, we published a mockup of the API on our public GitHub.
We've made it as usable as possible, directly for use in Visual Studio Code, community tools, etc.
It's free to use, so please enjoy!

https://github.com/dual-universe/lua-examples

The goal will be to update it with every major update we make for the future.


CONCLUSION
 

I hope you will like these changes, from the more concrete to the more subtle ones. I can't wait to see what you'll create with all these additions! And I hope it will inspire you.

Thank you all for the support you have shown for this revamp, it encourages us to go further. Our goal is and will remain to offer you more and better Lua tools, so you can create your own content!

Link to comment
Share on other sites

NEW Adjustor

Adjustors are specific motors that expel gas to generate torque on 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 adjustor at full power (works only when run inside a cockpit or under remote control)
  • deactivate(): Stops the adjustor (works only when run inside a cockpit or under remote control)
  • NEW [int] isActive(): Checks if the adjustor is active
    • DEPRECATED [int] getState() → isActive()
  • toggle(): Toggle the state of the adjustor
     
  • setThrust([float] thrust): Set the exhaust thrust of the adjustor
    • [float] thrust: The adjustor thrust in newtons (limited by the maximum thrust)
  • [float] getThrust(): Returns the current exhaust thrust of the adjustor
  • NEW [float] getMaxThrust(): Returns the maximal exhaust thrust the adjustor can deliver
    • DEPRECATED [float] getMaxThrustBase() → getMaxThrust()
       
  • NEW [vec3] getThrustAxis(): Returns the adjustor exhaust thrust direction in construct local coordinates
  • NEW [vec3] getTorqueAxis(): Returns the adjustor torque axis in construct local coordinates
  • NEW [vec3] getWorldThrustAxis(): Returns the adjustor exhaust thrust direction in world coordinates
    • DEPRECATED [vec3] thrustAxis() → getWorldThrustAxis()
  • NEW [vec3] getWorldTorqueAxis(): Returns the adjustor torque axis in world coordinates
    • DEPRECATED [vec3] torqueAxis() → getWorldTorqueAxis()
       
  • 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 API
  • DEPRECATED [float] getT50() → No reason to keep it from Engine API
Link to comment
Share on other sites

NEW Airbrake

Atmospheric airbrakes are elements designed to produce thrust opposite to the movement of a construct in the atmosphere.
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 Airfoil

Airfoils are aerodynamic elements that produce a lift force according to their aerodynamic profile; as wings, stabilizers and ailerons

 

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

  • [float] getLift(): Returns the current lift of the airfoil
    • DEPRECATED [float] getThrust() → getLift()
  • [float] getMaxLift(): Gives the maximum lift that the airfoil can generate, under optimal conditions.
    • DEPRECATED [float] getMaxThrustBase() → getMaxLift()
       
  • NEW [float] getDrag(): Returns the current drag of the airfoil
  • NEW [float] getDragRatio(): The ratio between lift and drag, depending of the aerodynamic profile of the airfoil
     
  • NEW [float] getCurrentMinLift(): Returns the minimal lift the airfoil can deliver at the moment (can be higher than zero), which will depend on various conditions like atmospheric density, obstruction, orientation, etc
    • DEPRECATED [float] getMinThrust() → getCurrentMinLift()
  • NEW [float] getCurrentMaxLift(): Returns the maximal lift the aifoil can deliver at the moment, which might depend on various conditions like atmospheric density, obstruction, orientation, etc. The actual lift will be anything below this maximum lift, which defines the current max capability of the airfoil.
    • DEPRECATED [float] getMaxThrust() → getCurrentMaxLift()
  • NEW [float] getMaxLiftEfficiency(): Returns the ratio between the current maximum lift and the optimal maximum lift
    • DEPRECATED [float] getMaxThrustEfficiency() → getMaxLiftEfficiency()
       
  • NEW [vec3] getLiftAxis(): Returns the airfoil lift direction in construct local coordinates
  • NEW [vec3] getTorqueAxis(): Returns the airfoil torque axis in construct local coordinates
  • NEW [vec3] getWorldLiftAxis(): Returns the airfoil lift direction in world coordinates
    • DEPRECATED [vec3] thrustAxis() → getWorldLiftAxis()
  • NEW [vec3] getWorldTorqueAxis(): Returns the adjustor torque axis in world coordinates
    • DEPRECATED [vec3] torqueAxis() → getWorldTorqueAxis()
       
  • NEW [int] isStalled(): Checks if the airfoil is stalled
  • NEW [float] getStallAngle(): Returns the airfoil stall angle
  • NEW [float] getMinAngle(): Returns the minimum angle to produce the maximum lift of the airfoil. Note that the airfoil will produce lift at a lower angle but not optimally
  • NEW [float] getMaxAngle(): Returns the maximum angle to produce the maximum lift of the airfoil. Note that the airfoil will produce lift at a higher angle but not optimally
     
  • [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 activate() → No reason to keep it from Engine API
  • DEPRECATED deactivate() → No reason to keep it from Engine API
  • DEPRECATED [int] getState() → No reason to keep it from Engine API
  • DEPRECATED setThrust([float] thrust) → No reason to keep it from Engine API
  • 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
Link to comment
Share on other sites

Anti-gravity generator

Generates graviton condensates to power anti-gravity pulsors

 

Quote

This API has been modified to improve the accessibility of the element data and the control of the element.

 

Functions

  • activate()Activate the anti-gravity generator
  • deactivate(): Deactivate the anti-gravity generator
  • NEW [int] isActive(): Returns the state of activation of the anti-gravity generator
    • DEPRECATED [int] getState() → isActive()
  • toggle(): Toggle the anti-gravity generator
     
  • NEW [float] getFieldStrength(): Returns the strength of the anti-gravitational field
  • NEW [float] getCompensationRate(): Returns the current rate of compensation of the gravitational field
  • NEW [float] getFieldPower(): Returns the current power of the gravitational field
  • NEW [int] getPulsorCount(): Returns the number of pulsors linked to the anti-gravity generator
     
  • setTargetAltitude([float] altitude): Set the target altitude for the anti-gravity field. Cannot be called from onFlush
    • DEPRECATED [float] setBaseAltitude() → setTargetAltitude()
  • NEW [float] getTargetAltitude(): Returns the target altitude defined for the anti-gravitational field
  • NEW [float] getBaseAltitude(): Returns the current base altitude of the anti-gravitational field
Link to comment
Share on other sites

NEW Atmospheric Engines

Atmospheric engines are engines designed to operate optimally in the atmosphere

 

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

Base Shield Generator

Generates a protective shield around the space construct

 

Quote

This API has undergone minor changes as part of the implementation of a new naming convention for events and functions.

 

Functions

  • activate()Activate the shield
  • deactivate(): Deactivate the shield
  • NEW [int] isActive(): Returns the activation state of the shield
    • DEPRECATED [int] getState() → isActive()
  • toggle(): Toggle the state of the shield
     
  • [float] getShieldHitpoints(): Returns the current hit points of the shield
  • [float] getMaxShieldHitpoints(): Returns the maximal hit points of the shield
  • [table] getResistances(): Returns distribution of resistance pool over resistance types
  • setResistances([float] antimatter,[float] electromagnetic,[float] kinetic,[float] thermic): Distribute the resistance pool according to damage type
    • [float] antimatterAntimatter damage resistance
    • [float] electromagneticElectromagnetic damage resistance
    • [float] kineticKinetic damage resistance
    • [float] thermicThermic damage resistance
  • [float] getResistancesCooldown(): Returns time after which adjusting resistances is possible again
  • [float] getResistancesMaxCooldown(): Returns maximal cooldown between adjusting resistances
  • [float] getResistancesPool(): Returns total resistance pool that may be distributed
  • [float] getResistancesRemaining(): Returns the remaining amount of the resistance pool that can be distributed
     
  • [table] getStressRatio(): Returns ratio per damage type of recent weapon impacts after applying resistance
  • [table] getStressRatioRaw(): Returns ratio per damage type of recent weapon impacts without resistance
  • [float] getStressHitpoints(): Returns stress, that is the total hit points of recent weapon impacts after applying resistance
  • [float] getStressHitpointsRaw(): Returns stress, that is the total hit points of recent weapon impacts without resistance
     
  • [int] inLockdown(): Returns whether the base shield is currently in lockdown
  • [float] getLockdownRemaining(): Returns the remaining time of the base shield lockdown
  • [int] getLockdownExitTime(): Returns the hour since midnight of the preferred lockdown exit
  • setLockdownExitTime([int] hour): Set hour since midnight for the preferred lockdown exit
    • [int] hour: Preferred lockdown exit hour UTC

 

Events

  • NEW onToggled([int] active)Emitted when we started or stopped the shield generator
    • [int] active1 if the element was activated, 0 otherwise
    • DEPRECATED toggled([int] active) → onToggled([int] active)
  • NEW onAbsorbed([float] hitpoints,[float] rawHitpoints)Emitted when the shield absorbed incoming damage
    • [float] hitpointsDamage the shield absorbed
    • [float] rawHitpointsTotal damage without taking resistances into account
    • DEPRECATED absorbed([float] hitpoints,[float] rawHitpoints) → onAbsorbed([float] hitpoints,[float] rawHitpoints)
  • NEW onDown()Emitted when the shield hit points reached 0 due to damage
    • DEPRECATED down() → onDown()
  • NEW onRestored()Emitted when the shield hit points were fully restored
    • DEPRECATED restored() → onRestored()
  • NEW onEnterLockdown()Emitted when the shield enters lockdown
    • DEPRECATED enterLockdown() → onEnterLockdown()
  • NEW onLeaveLockdown()Emitted when the shield exits the lockdown
    • DEPRECATED leaveLockdown() → onLeaveLockdown()
Link to comment
Share on other sites

NEW Construct

Construct represents your construct. It gives access to the properties of your constructions and to the events linked to them, which can be used in your scripts.

 

Quote

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


 

Functions

  • NEW [string] getName()Returns the name of the construct
  • NEW [int] getId(): Returns the construct unique ID
  • NEW [table] getOwner(): Returns the owner entity
    • return [table]: 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
  • NEW [table] getCreator(): Returns the creator entity
    • return [table]: The creator entity table with fields {[int] id, [bool] isOrganization} describing the owner. Use system.getPlayerName(id) and system.getOrganization(id) to retrieve info about it
       
  • NEW [int] isWarping(): Checks if the construct is currently warping
  • NEW [int] getWarpState(): Returns the current warp state
    • return [int]: The current warp state index (Idle = 1, Engage = 2, Align = 3, Spool = 4, Accelerate = 5, Cruise = 6, Decelerate = 7, Stopping = 8, Disengage = 9)
       
  • NEW [int] isInPvPZone(): Checks if the construct is in PvP zone
  • NEW [float] getDistanceToSafeZone(): Returns the distance between the construct and the nearest safe zone
  • NEW [float] getPvPTimer(): Returns the current construct PvP timer state
     
  • NEW [float] getMass()Returns the mass of the construct
  • NEW [float] getInertialMass()Returns the inertial mass of the construct, calculated as 1/3 of the trace of the inertial tensor
  • NEW [table] getInertialTensor()Returns the inertial tensor of the construct
  • NEW [table] getCenterOfMass()Returns the position of the center of mass of the construct, in local construct coordinates
  • NEW [table] getWorldCenterOfMass()Returns the position of the center of mass of the construct, in world coordinates
  • NEW [float] getCrossSection()Returns the construct's cross sectional surface in the current direction of movement
  • NEW [table] getSize(): Returns the size of the building zone of the construct
  • NEW [table] getBoundingBoxSize()Returns the size of the bounding box of the construct
  • NEW [table] getBoundingBoxCenter()Returns the position of the center of bounding box of the construct in local construct coordinates
     
  • NEW [float] getMaxSpeed()Returns the max speed along current moving direction
  • NEW [float] getMaxAngularSpeed()Returns the max angular speed
  • NEW [table] getMaxSpeedPerAxis()Returns the max speed per axis
  • NEW [table] getMaxThrustAlongAxis([string] taglist, [table] CRefAxis)Returns the construct max kinematics parameters in both atmo and space range, in newtons.
    • [string] taglist: Comma (for union) or space (for intersection) separated list of tags. You can set tags directly on the engines in the right-click menu
    • [table] CRefAxis: Axis along which to compute the max force (in construct reference)
  • NEW [float] getCurrentBrake()Returns the current braking force generated by construct brakes
  • NEW [float] getMaxBrake()Returns the maximum braking force that can currently be generated by the construct brakes
     
  • NEW [table] getWorldPosition()Returns the world position of the construct
  • NEW [table] getVelocity()The construct's linear velocity, relative to its parent, in construct local coordinates
  • NEW [table] getWorldVelocity()The construct's linear velocity, relative to its parent, in world coordinates
  • NEW [table] getAbsoluteVelocity()The construct's absolute linear velocity, in construct local coordinates
  • NEW [table] getWorldAbsoluteVelocity()The construct's absolute linear velocity, in world coordinates
  • NEW [table] getAcceleration()The construct's linear acceleration, in construct local coordinates
  • NEW [table] getWorldAcceleration()The construct's linear acceleration, in world coordinates
  • NEW [table] getAngularVelocity()The construct's angular velocity, in construct local coordinates
  • NEW [table] getWorldAngularVelocity() The construct's angular velocity, in world coordinates
  • NEW [table] getAngularAcceleration()The construct's angular acceleration, in construct local coordinates
  • NEW [table] getWorldAngularAcceleration()The construct's angular acceleration, in world coordinates
  • NEW [table] getWorldAirFrictionAcceleration()Returns the acceleration generated by air resistance
  • NEW [table] getWorldAirFrictionAngularAcceleration()Returns the acceleration torque generated by air resistance
  • NEW [table] getFrictionBurnSpeed()Returns the speed at which your construct will suffer damage due to friction with the air
     
  • NEW [table] getForward()Returns the forward vector of the construct coordinates system
  • NEW [table] getRight()Returns the right vector of the construct coordinates system
  • NEW [table] getUp()Returns the up direction vector of the construct coordinates system
  • NEW [table] getWorldForward()Returns the forward direction vector of the construct, in world coordinates
  • NEW [table] getWorldRight()Returns the right direction vector of the construct, in world coordinates
  • NEW [table] getWorldUp()Returns the up direction vector of the construct, in world coordinates
     
  • NEW [int] getOrientationUnitId()Returns the local id of the current active orientation unit (core unit or gyro unit)
  • NEW [table] getOrientationForward()Returns the forward direction vector of the active orientation unit, in construct local coordinates
  • NEW [table] getOrientationRight()Returns the right direction vector of the active orientation unit, in construct local coordinates
  • NEW [table] getOrientationUp()Returns the up direction vector of the active orientation unit, in construct local coordinates
  • NEW [table] getWorldOrientationForward()Returns the forward direction vector of the active orientation unit, in world coordinates
  • NEW [table] getWorldOrientationRight()Returns the right direction vector of the active orientation unit, in world coordinates
  • NEW [table] getWorldOrientationUp()Returns the up direction vector of the active orientation unit, in world coordinates
     
  • NEW [int] getParent()Returns the id of the parent construct of our active construct
  • NEW [int] getClosestParent()Returns the id of the nearest constructs, on which the construct can dock
  • NEW [table] getCloseParents()Returns the list of ids of nearby constructs, on which the construct can dock
     
  • NEW [table] getParentPosition()Returns the position of the construct's parent when docked in local coordinates
  • NEW [table] getParentWorldPosition()Returns the position of the construct's parent when docked in world coordinates
  • NEW [table] getParentForward()Returns the construct's parent forward direction vector, in local coordinates
  • NEW [table] getParentRight()Returns the construct's parent right direction vector, in construct local coordinates
  • NEW [table] getParentUp()Returns the construct's parent up direction vector, in construct local coordinates
  • NEW [table] getParentWorldForward()Returns the construct's parent forward direction vector, in world coordinates
  • NEW [table] getParentWorldRight()Returns the construct's parent right direction vector, in world coordinates
  • NEW [table] getParentWorldUp()Returns the construct's parent up direction vector, in world coordinates
     
  • NEW [table] getPlayersOnBoard()Returns the list of player IDs on board the construct
  • NEW [table] getPlayersOnBoardInVRStation()Returns the list of player ids on board the construct inside a VR Station
  • NEW [int] isPlayerBoarded([int] id)Checks if the given player is on board in the construct
    • [int] id: The player id
  • NEW [int] isPlayerBoardedInVRStation([int] id)Returns 1 if the given player is boarded to the construct inside a VR Station
    • [int] id: The player id
  • NEW [float] getBoardedPlayerMass([int] id)Returns the mass of the given player or surrogate if it is on board the construct
    • [int] id: The player id
  • NEW [float] getBoardedInVRStationAvatarMass([int] id)Returns the mass of the given player if in VR station on board the construct
    • [int] id: The player id
       
  • NEW [table] getDockedConstructs([int] id)Returns the list of IDs of constructs docked to the construct
    • [int] id: The construct id
  • NEW [table] isConstructDocked([int] id)Checks if the given construct is docked to the construct
    • [int] id: The construct id
  • NEW [float] getDockedConstructMass([int] id)Returns the mass of the given construct if it is docked to the construct
    • [int] id: The construct id
       
  • NEW setDockingMode([int] mode)Sets the docking mode
    • [int] id: The docking mode (0: Manual, 1: Automatic, 2: Semi-automatic)
  • NEW [int] getDockingMode()Returns the current docking mode
    • return [int]: The docking mode (0: Manual, 1: Automatic, 2: Semi-automatic)
  • NEW [int] dock([int] id)Sends a request to dock to the given construct. Limited to piloting controllers
    • [int] id: The parent construct id
  • NEW [int] undock()Sends a request to undock the construct. Limited to piloting controllers
     
  • NEW forceDeboard([int] id)Sends a request to deboard a player or surrogate with the given id
    • [int] id: The player id
  • NEW forceUndock([int] id)Sends a request to undock a construct with the given id
    • [int] id: The construct id
  • NEW forceInterruptVRSession([int] id)Sends a request to interrupt the surrogate session of a player with the given id
    • [int] id: The player id

 

Events

  • NEW onDocked([int] id)Emitted when the construct becomes docked
    • [int] id: The parent id
  • NEW onUndocked([int] id)Emitted when the construct is undocked
    • [int] id: The previous parent id
  • NEW onPlayerBoarded([int] id)Emitted when a player or surrogate boards the construct
    • [int] id: The id of the boarding player
  • NEW onVRStationEntered([int] id)Emitted when a player enters a VR Station
    • [int] id: The id of the boarding player
  • NEW onConstructDocked([int] id)Emitted when another construct docks this construct
    • [int] id: The id of the docking construct
  • NEW onPvPTimer([int] active)Emitted when the PvP timer started or elapsed
    • [int] active: 1 if the timer started, false when the timer elapsed
Link to comment
Share on other sites

Container

Containers are elements designed to store items and resources

 

Quote

The container API has been modified to fix the behavior of container content acquisition. The goal is twofold: to reduce the number of erratic server-side requests and to allow you to access information more easily with a minimum delay of 30 seconds between fixed requests.
In addition, this API receives the item API implementation, allowing you to access more information while reducing data size.


 

Functions

  • [float] getSelfMass(): Returns the mass of the container element(as if it were empty).
  • [float] getItemsMass(): Returns the container content mass(the sum of the mass of all items it contains).
  • [float] getItemsVolume(): Returns the current hit points of the shield
  • [float] getMaxVolume(): Returns the maximum volume of the container.
  • NEW [table] getContent(): Returns a table describing the contents of the container, as a pair itemId and quantity per slot.
    • return [table]: The content of the container as a table with fields {[int] id, [float] quantity} per slot
    • DEPRECATED [table] getItemsList() → [table] getContent()
  • NEW [float] updateContent(): Send a request to get an update of the content of the container, limited to one call allowed per 30 seconds. The onContentUpdate event is emitted by the container when the content is updated.
    • NEW return [float]: If the request is not yet possible, returns the remaining time to wait for.
    • DEPRECATED acquireStorage() → [float] updateContent()

Events

  • NEW onContentUpdate()Emitted when the container content is updated(storage update or after a manual request made with updateContent())
    • DEPRECATED storageAcquired() → onContentUpdate()
Link to comment
Share on other sites

Control Unit

Control Units come in various forms: cockpits, programming boards, emergency Control Units, etc.
A Control Unit stores a set of Lua scripts that can be used to control the Elements that are plugged on its CONTROL plugs.
Kinematics Control Units like cockpit or command seats are also capable of controlling the ship's engines via the update ICC method.

 

Quote

This API has received some changes to apply the new naming convention for events, and some minor additions. In addition, some of the events and functions have been moved to Player to reduce the complexity of the API.
Additional note:
A part of the Control Unit API may potentially change again with the next flight configuration.

 

Functions

  • setTimer([string] tag, [float] period): Set up a timer with a given tag in a given period. This will start to trigger the 'onTimer' event with the corresponding tag as an argument, to help you identify what is ticking, and when.
    • [string] tag: The tag of the timer, as a string, which will be used in the 'onTimer' event to identify this particular timer
    • [float] period: The period of the timer, in seconds. The time resolution is limited by the framerate here, so you cannot set arbitrarily fast timers
  • stopTimer([string] tag): Stop the timer with the given tag
    • [string] tag: The tag of the timer to stop, as a string
  • [float] getAtmosphereDensity(): Returns the ambient atmospheric density
    • return [float]: The atmospheric density(between 0 and 1)
  • [float] getClosestPlanetInfluence(): Returns the influence rate of the nearest planet
    • return [float]: The planet influence rate(between 0 and 1)
       
  • NEW [int] hasDRM(): Checks if the control unit is protected by DRM
  • [int] isRemoteControlled(): Check if the construct is remote controlled
     
  • [float] setEngineCommand([string] taglist, [table] acceleration, [table] angularAcceleration, [bool] keepForceCollinearity, [bool] keepTorqueCollinearity, [string] priority1SubTags, [string] priority2SubTags, [string] priority3SubTags, [float] toleranceRatioToStopCommand): Automatically assign the engines within the taglist to result in the given acceleration and angular acceleration provided. Can only be called within the system.onFlush event. If engines designated by the tags are not capable of producing the desired command, setEngineCommand will try to do its best to approximate it
    • [string] taglist: Comma (for union) or space (for intersection) separated list of tags. You can set tags directly on the engines in the right-click menu
    • [table] acceleration: The desired acceleration expressed in world coordinates in m/s2
    • [table] angularAcceleration: The desired angular acceleration expressed in world coordinates in rad/s2
    • [bool] keepForceCollinearity: Forces the resulting acceleration vector to be collinear to the acceleration parameter
    • bool] keepTorqueCollinearity: Forces the resulting angular acceleration vector to be collinear to the angular acceleration parameter
    • [string] priority1SubTags: Comma (for union) or space (for intersection) separated list of tags of included engines to use as priority 1
    • [string] priority2SubTags: Comma (for union) or space (for intersection) separated list of tags of included engines to use as priority 2
    • [string] priority3SubTags: Comma (for union) or space (for intersection) separated list of tags of included engines to use as priority 3
       
  • setEngineThrust([string] taglist, [float] thrust): Sets the thrust values for all engines in the tag list. This function must be used on a piloting controller
    • [string] taglist: Comma separated list of tags. You can set tags directly on the engines in the right-click menu
    • [float] thrust: The desired thrust in newtons (note that for boosters, any non zero value here will set them to 100%)
  • NEW [table] getEngineThrust([string] taglist): Returns the total thrust values of all engines in the tag list. This function must be used on a piloting controller
    • [string] taglist: Comma separated list of tags. You can set tags directly on the engines in the right-click menu
    • return [float]: The total thrust in newtons
       
  • setAxisCommandValue([int] axis, [float] commandValue): Set the value of throttle in the cockpit, which will be displayed in the cockpit widget when flying. This function must be used on a piloting controller
    • [int] axis: Longitudinal = 0, lateral = 1, vertical = 2
    • [float] commandValue: In 'by throttle', the value of the throttle position: -1 = full reverse, 1 = full forward. Or In 'By Target Speed', the value of the target speed in km/h
  • [float] getAxisCommandValue([int] axis,): Get the value of throttle in the cockpit. This function must be used on a piloting controller
    • [int] axis: Longitudinal = 0, lateral = 1, vertical = 2
    • return [float]: In travel mode, return the value of the throttle position: -1 = full reverse, 1 = full forward or in cruise mode, return the value of the target speed
  • setupAxisCommandProperties(axis, commandType, targetSpeedRanges): Set the properties of an axis command. This function must be used on a piloting controller. These properties will be used to display the command in UI.
    • [int] axis: Longitudinal = 0, lateral = 1, vertical = 2
    • [int] commandType: By throttle = 0, by target speed = 1, hidden = 2
    • [table] targetSpeedRanges: This is to specify the cruise control target speed ranges (for now, only for the longitudinal axis) in m/s
  • NEW [int] getControlMode(): Returns the current control mode. The mode is set by clicking the UI button or using the associated keybinding. This function must be used on a piloting controller
    • return [int]: The current control mode (for now, only 2 are available, 0 and 1)
    • DEPRECATED [int] getControlMasterModeId() → [table] getControlMode()
  • cancelCurrentControlMasterMode(): Cancel the current master mode in use. This function must be used on a piloting controller
     
  • [int] isMouseControlActivated(): Check if a mouse control scheme is selected. This function must be used on a piloting controller
  • [int] isMouseDirectControlActivated(): Check if the mouse control direct scheme is selected. This function must be used on a piloting controller
  • [int] isMouseVirtualJoystickActivated(): Check if the mouse control virtual joystick scheme is selected. This function must be used on a piloting controller
     
  • activateGroundEngineAltitudeStabilization([float] targetAltitude): The ground engines will stabilize to this altitude within their limits. The stabilization will be done by adjusting thrust to never go over the target altitude. This includes VerticalBooster and HoverEngine. This function must be used on a piloting controller
    • [float] targetAltitude: The stabilization target altitude in m
  • [float] getSurfaceEngineAltitudeStabilization(): Return the ground engines' stabilization altitude. This function must be used on a piloting controller
    • return [float]: Stab altitude in m or 0 if none is set
  • deactivateGroundEngineAltitudeStabilization(): The ground engines will behave like regular engine. This includes VerticalBooster and HoverEngine. This function must be used on a piloting controller
  • [table] computeGroundEngineAltitudeStabilizationCapabilities(): Returns ground engine stabilization altitude capabilities (lower and upper ranges). This function must be used on a piloting controller.
    • return [table]: Stabilization altitude capabilities for the least powerful engine and the most powerful engine
  • [float] getThrottle(): Return the current throttle value. This function must be used on a piloting controller.
    • return [float]: Throttle value between -100 and 100
       
  • NEW [int] setWidgetControlModeLabel([int] modeId, [string] label): Set the label of a control mode buttons shown in the control unit widget. This function must be used on a piloting controller
    • [int] modeId: The control mode: 0=Travel Mode, 1=Cruise Control by default
    • [string] label: The display name of the control mode, displayed on the widget button
    • DEPRECATED setupControlMasterModeProperties([int] modeId, [string] label) → setWidgetControlModeLabel([int] modeId, [string] label)
       
  • NEW [int] isAnyLandingGearDeployed(): Checks if any landing gear is deployed
    • return [int]: 1 if any landing gear is deployed
    • DEPRECATED isAnyLandingGearExtended() → isAnyLandingGearDeployed()
  • NEW deployLandingGears(): Deploy all landing gears
    • DEPRECATED extendLandingGears() → deployLandingGears()
  • retractLandingGears(): Retract all landing gears
     
  • [int] isAnyHeadlightSwitchedOn(): Check construct lights status
  • switchOnHeadlights(): Turn on the construct headlights
  • switchOffHeadlights(): Turn off the construct headlights

 

 

  • DEPRECATED [int] getMasterPlayerId() → [int] player.getId()
  • DEPRECATED [table] getMasterPlayerOrgIds() → [table] player.getOrgIds()
  • DEPRECATED [table] getMasterPlayerPosition() → [table] player.getPosition()
  • DEPRECATED [table] getMasterPlayerWorldPosition() → [table] player.getWorldPosition()
  • DEPRECATED [table] getMasterPlayerForward() → [table] player.getForward()
  • DEPRECATED [table] getMasterPlayerUp() → [table] player.getUp()
  • DEPRECATED [table] getMasterPlayerRight() → [table] player.getRight()
  • DEPRECATED [table] getMasterPlayerWorldForward() → [table] player.getWorldForward()
  • DEPRECATED [table] getMasterPlayerWorldUp() → [table] player.getWorldUp()
  • DEPRECATED [table] getMasterPlayerWorldRight() → [table] player.getWorldRight()
  • DEPRECATED [int] isMasterPlayerSeated() → [int] player.isSeated()
  • DEPRECATED [int] getMasterPlayerSeatId() → [int] player.getSeatId()
  • DEPRECATED [int] getMasterPlayerParent() → [int] player.getParent()
  • DEPRECATED [float] getMasterPlayerMass() → [float] player.getMass()

Events

  • NEW onTimer([string] tag)Emitted when the timer with the tag 'tag' is ticking
    • [string] tag: The tag of the timer that just ticked (see setTimer to set a timer with a given tag)
    • DEPRECATED tick([string] timerId) → onTimer([string] tag)
Link to comment
Share on other sites

Core Unit

It is the heart of your construction. It represents the interaction of the environment of your construction with its surroundings.

 

Quote

This API receives some naming changes to improve the user experience and is deprecated from multiple functions that have been transferred to the construct API.

The getElementClassById function has been added to have a more proof data for element comparison than the display name. It is therefore recommended to use it instead of getElementDisplayName.

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

 

Functions

  • [table] getElementIdList(): Returns the list of all the local IDs of the Elements of this construct
  • [string] getElementNameById([int] localId): Returns the name of the Element, identified by its local ID
    • [int] localId: The local ID of the Element
  • NEW [string] getElementClassById([int] localId): Returns the class of the Element, identified by its local ID
    • [int] localId: The local ID of the Element
  • NEW [string] getElementDisplayNameById([int] localId): Returns the display name of the Element, identified by its local ID
    • [int] localId: The local ID of the Element
    • DEPRECATED [string] getElementTypeById([int] uid) → [string] getElementDisplayNameById([int] localId)
  • NEW [int] getElementItemIdById([int] localId): Returns the item ID of the Element, identified by its local ID
    • [int] localId: The local ID of the Element
  • [float] getElementHitPointsById([int] localId): Returns the current level of hit points of the Element, identified by its local ID
    • [int] localId: The local ID of the Element
  • [float] getElementMaxHitPointsById([int] localId): Returns the maximum level of hit points of the Element, identified by its local ID
    • [int] localId: The local ID of the Element
  • [float] getElementMassById([int] localId): Returns the mass of the Element, identified by its local ID
    • [int] localId: The local ID of the Element
  • [table] getElementPositionById([int] localId): Returns the position of the Element, identified by its local ID, in construct local coordinates.
    • [int] localId: The local ID of the Element
  • [table] getElementUpById([int] localId): Returns the up direction vector of the Element, identified by its local ID, in construct local coordinates
    • [int] localId: The local ID of the Element
  • [table] getElementRightById([int] localId): Returns the right direction vector of the Element, identified by its local ID, in construct local coordinates
    • [int] localId: The local ID of the Element
  • [table] getElementForwardById([int] localId): Returns the forward direction vector of the Element, identified by its local ID, in construct local coordinates
    • [int] localId: The local ID of the Element
  • NEW [table] getElementIndustryInfoById([int] localId): Returns the status of the Industry Unit Element, identified by its local ID
    • [int] localId: The local ID of the Element
    • return [table]: If the Element is an Industry Unit, a table with fields {[string] state, [bool] stopRequested, [int] schematicId, [int] unitsProduced, [int] remainingTime, [int] batchesRequested, [int] batchesRemaining, [number] maintainProductAmount, [int] currentProductAmount}
    • DEPRECATED [string] getElementIndustryStatusById([int] uid) → [table] getElementIndustryInfoById([int] localId)
  • [string] getElementTagsById([int] localId): Returns the list of tags associated to the Element, identified by its local ID
    • [int] localId: The local ID of the Element
  • [float] getAltitude(): Returns the altitude above sea level, with respect to the closest planet (0 in space)
  • [float] getGravityIntensity(): Returns the local gravity intensity
    • DEPRECATED [string] g() → [table] getGravityIntensity()
  • [table] getWorldGravity(): Returns the local gravity vector in world coordinates
  • [table] getWorldVertical(): Returns the vertical unit vector along gravity, in world coordinates (0 in space)
  • [int] getCurrentPlanetId(): Returns the id of the current close stellar body
     
  • [float] getCoreStress(): Returns the core's current stress, destroyed when reaching max stress
  • [float] getMaxCoreStress(): Returns the maximal stress the core can bear before it gets destroyed
  • [float] getCoreStressRatio(): Returns the core's current stress to max stress ratio
     
  • [int] spawnNumberSticker([int] nb,[float] x,[float] y,[float] z,[string] orientation): Spawns a number sticker in the 3D world, with coordinates relative to the construct
    • [int] nb: The number to display 0 to 9
    • [float] x: The x-coordinate in the construct in meters. 0 = center
    • [float] y: The y-coordinate in the construct in meters. 0 = center
    • [float] z: The z-coordinate in the construct in meters. 0 = center
    • [string] orientation: Orientation of the number. Possible values are "front", "side"
  • [int] spawnArrowSticker([float] x,[float] y,[float] z,[string] orientation): Spawns an arrow sticker in the 3D world, with coordinates relative to the construct
    • [float] x: The x-coordinate in the construct in meters. 0 = center
    • [float] y: The y-coordinate in the construct in meters. 0 = center
    • [float] z: The z-coordinate in the construct in meters. 0 = center
    • [string] orientation: Orientation of the arrow. Possible values are "up", "down", "north", "south", "east", "west"
  • [int] deleteSticker([int] index): Delete the referenced sticker
    • [int] index: Index of the sticker to delete
  • [int] moveSticker([int] index,[float] x,[float] y,[float] z): Move the referenced sticker
    • [int] index: Index of the sticker to delete
    • [float] x: The x-coordinate in the construct in meters. 0 = center
    • [float] y: The y-coordinate in the construct in meters. 0 = center
    • [float] z: The z-coordinate in the construct in meters. 0 = center
  • [int] rotateSticker([int] index,[float] angle_x,[float] angle_y,[float] angle_z): Rotate the referenced sticker.
    • [int] index: Index of the sticker to delete
    • [float] angle_x: Rotation along the x-axis in degrees
    • [float] angle_y: Rotation along the y-axis in degrees
    • [float] angle_z: Rotation along the z-axis in degrees

 

 

  • DEPRECATED [int] getConstructId() → [int] construct.getId()
  • DEPRECATED [string] getConstructName() → [string] construct.getName()
  • DEPRECATED [table] getConstructWorldPos() → [table] construct.getWorldPosition()
  • DEPRECATED [table] getWorldAirFrictionAcceleration() → [table] construct.getWorldAirFrictionAngularAcceleration()
  • DEPRECATED [table] getAngularVelocity() → [table] construct.getAngularVelocity()
  • DEPRECATED [table] getWorldAngularVelocity() → [table] construct.getWorldAngularVelocity()
  • DEPRECATED [table] getAngularAcceleration() → [table] construct.getAngularAcceleration()
  • DEPRECATED [table] getWorldAngularAcceleration() → [table] construct.getWorldAngularAcceleration()
  • DEPRECATED [table] getWorldAngularVelocity() → [table] construct.getWorldAngularVelocity()
  • DEPRECATED [table] getVelocity() → [table] construct.getVelocity()
  • DEPRECATED [table] getWorldVelocity() → [table] construct.getWorldVelocity()
  • DEPRECATED [table] getAbsoluteVelocity() → [table] construct.getAbsoluteVelocity()
  • DEPRECATED [table] getWorldAbsoluteVelocity() → [table] construct.getWorldAbsoluteVelocity()
  • DEPRECATED [table] getAcceleration() → [table] construct.getAcceleration()
  • DEPRECATED [table] getWorldAcceleration() → [table] construct.getWorldAcceleration()
     
  • DEPRECATED [int] getOrientationUnitId() → [int] construct.getOrientationUnitId()
  • DEPRECATED [table] getConstructOrientationUp() → [table] construct.getConstructOrientationUp()
  • DEPRECATED [table] getConstructOrientationRight() → [table] construct.getConstructOrientationRight()
  • DEPRECATED [table] getConstructOrientationForward() → [table] construct.getConstructOrientationForward()
  • DEPRECATED [table] getConstructWorldOrientationUp() → [table] construct.getConstructWorldOrientationUp()
  • DEPRECATED [table] getConstructWorldOrientationRight() → [table] construct.getConstructWorldOrientationRight()
  • DEPRECATED [table] getConstructWorldOrientationForward() → [table] construct.getConstructWorldOrientationForward()
  • DEPRECATED [table] getConstructWorldUp() → [table] construct.getConstructWorldUp()
  • DEPRECATED [table] getConstructWorldRight() → [table] construct.getConstructWorldRight()
  • DEPRECATED [table] getConstructWorldForward() → [table] construct.getConstructWorldForward()
     
  • DEPRECATED [float] getPvPTimer() → [float] construct.getPvPTimer()
     
  • DEPRECATED [table] getPlayersOnBoard() → [table] construct.getPlayersOnBoard()
  • DEPRECATED [table] getPlayersOnBoardInVRStation() → [table] construct.getPlayersOnBoardInVRStation()
  • DEPRECATED [table] getDockedConstructs() → [table] construct.getDockedConstructs()
  • DEPRECATED [int] isPlayerBoarded([int] pid) → [int] construct.isPlayerBoarded([int] id)
  • DEPRECATED [int] isPlayerBoardedInVRStation([int] pid) → [int] construct.isPlayerBoardedInVRStation([int] id)
  • DEPRECATED [int] isConstructDocked([int] cid) → [int] construct.isConstructDocked([int] id)
  • DEPRECATED forceDeboard([int] pid) → construct.forceDeboard([int] id)
  • DEPRECATED forceInterruptVRSession([int] pid) → construct.forceInterruptVRSession([int] id)
  • DEPRECATED forceUndock([int] cid) → construct.forceUndock([int] id)
  • DEPRECATED [float] getBoardedPlayerMass([int] id) → [float] construct.getBoardedPlayerMass([int] id)
  • DEPRECATED [float] getBoardedInVRStationAvatarMass([int] id) → [float] construct.getBoardedInVRStationAvatarMass([int] id)
  • DEPRECATED [float] getDockedConstructMass([int] id) → [float] construct.getDockedConstructMass([int] id)
     
  • DEPRECATED [int] getParent() → [int] construct.getParent()
  • DEPRECATED [table] getCloseParents() → [table] construct.getCloseParents()
  • DEPRECATED [int] getClosestParent() → [int] construct.getClosestParent()
  • DEPRECATED [int] dock([int] id) → [int] construct.dock([int] id)
  • DEPRECATED [int] undock() → [int] construct.undock()
  • DEPRECATED [int] setDockingMode([int] mode) → [int] construct.setDockingMode([int] mode)
  • DEPRECATED [int] getDockingMode() → [int] construct.getDockingMode()
     
  • DEPRECATED [table] getParentPosition() → [table] construct.getParentPosition()
  • DEPRECATED [table] getParentWorldPosition() → [table] construct.getParentWorldPosition()
  • DEPRECATED [table] getParentForward() → [table] construct.getParentForward()
  • DEPRECATED [table] getParentUp() → [table] construct.getParentUp()
  • DEPRECATED [table] getParentRight() → [table] construct.getParentRight()
  • DEPRECATED [table] getParentWorldForward() → [table] construct.getParentWorldForward()
  • DEPRECATED [table] getParentWorldUp() → [table] construct.getParentWorldUp()
  • DEPRECATED [table] getParentWorldRight() → [table] construct.getParentWorldRight()
  • DEPRECATED [float] getMaxSpeed() → [float] construct.getMaxSpeed()
  • DEPRECATED [float] getMaxAngularSpeed() → [float] construct.getMaxAngularSpeed()
  • DEPRECATED [table] getMaxSpeedPerAxis() → [table] construct.getMaxSpeedPerAxis()
     
  • DEPRECATED [float] getConstructMass() → [float] construct.getMass()
  • DEPRECATED [float] getConstructIMass() → [float] construct.getInertialMass()
  • DEPRECATED [float] getConstructCrossSection() → [float] construct.getCrossSection()
  • DEPRECATED [table] getMaxKinematicsParametersAlongAxis([string] taglist, [table] CRefAxis) → [table] construct.getMaxThrustAlongAxis([string] taglist, [table] CRefAxis)
     

Events

  • NEW onStressChanged([float] stress)Emitted when core unit stress changed
    • [float] stress: Difference to previous stress value
    • DEPRECATED stressChanged([float] stress) → onStressChanged([float] stress)
  • DEPRECATED pvpTimer([int] active) → construct.onPvPTimer([int] active)
  • DEPRECATED playerBoarded([int] id) → construct.onPlayerBoarded([int] id)
  • DEPRECATED VRStationEntered([int] id) → construct.onVRStationEntered([int] id)
  • DEPRECATED constructDocked([int] id) → construct.onConstructDocked([int] id)
  • DEPRECATED docked([int] id) → construct.onDocked([int] id)
  • DEPRECATED undocked([int] id) → construct.onUndocked([int] id)
Link to comment
Share on other sites

  • NQ-Ligo changed the title to INFO: DETAILED LUA API REVAMP

Counter

Cycle its output signal over a set of n-plugs, incrementing the activate plug by one step at each impulse received on its IN plug

 

Quote

This API has been modified in order to add new functions to make the interaction with the element more interesting and improve the user experience.


 

Functions

  • NEW [int] getIndex(): Returns the index of the current active output plug
    • DEPRECATED [int] getCounterState() → [int] getIndex()
  • NEW [float] getMaxIndex(): Returns the container content mass(the sum of the mass of all items it contains).
  • NEW [float] nextIndex(): Returns the current hit points of the shield
    • DEPRECATED next() → nextIndex()
  • NEW setIndex([int] index): Sets the counter index
    • [int] index: The index of the plug to activate

 

Link to comment
Share on other sites

 Databank

Stores key/value pairs in a persistent way.

 

Quote

This API has been modified in order to improve the user experience.

 

Functions

  • clear(): Clear the Databank
  • [int] getNbKeys(): Returns the number of keys that are stored inside the Databank
  • NEW [table] getKeyList(): Returns all the keys in the Databank
    • DEPRECATED getKeys() → getKeyList()
  • [int] hasKey([string] key): Returns 1 if the key is present in the Databank, 0 otherwise
    • [string] key: The key used to store a value
  • NEW [int] clearValue([string] key): Remove the given key if the key is present in the Databank
    • [string] key: The key used to store a value
  • setStringValue([string] key, [string] val): Stores a string value at the given key
    • [string] key: The key used to store the value
    • [string] val: The value, as a string
  • [string] getStringValue([string] key): Returns value stored in the given key as a string
    • [string] key: The key used to store the value
    • return [string]: The value, as a string
  • setIntValue([string] key, [int] val): Stores an integer value at the given key
    • [string] key: The key used to store the value
    • [int] val: The value, as an integer
  • [int] getIntValue([string] key): Returns value stored in the given key as an integer
    • [string] key: The key used to store the value
    • return [int]: The value, as an integer
  • setFloatValue([string] key, [float] val): Stores a floating number value at the given key
    • [string] key: The key used to store the value
    • [string] val: The value, as a floating number
  • [float] getFloatValue([string] key): Returns value stored in the given key as a floating number
    • [string] key: The key used to store the value
    • return [string]: The value as a floating number

 

Link to comment
Share on other sites

Detection Zone

Detect the intrusion of any player inside the effect zone.

 

Quote

This API has been modified to add new functions to make the interaction with the element more interesting and a new naming convention for events.

 

Functions

  • [float] getRadius(): Returns the detection zone radius
  • NEW [table] getPlayers(): Returns the list of ids of the players in the detection zone

Events

  • NEW onEnter([int] id): Emitted when a player enters in the detection zone
    • [int] id: The ID of the player. Use system.getPlayerName(id) to retrieve its name
    • DEPRECATED enter([int] id) → onEnter([int] id)
  • NEW onLeave([int] id): Emitted when a player leaves in the detection zone
    • [int] id: The ID of the player. Use system.getPlayerName(id) to retrieve its name
    • DEPRECATED leave([int] id) → onLeave([int] id)
Link to comment
Share on other sites

Door

A door that can be opened or closed.

 

Quote

This API has been modified to apply the new naming convention to improve the user experience.

 

Functions

  • NEW open(): Open the door
    • DEPRECATED activate() → open()
  • NEW close(): Close the door
    • DEPRECATED deactivate() → close()
  • NEW [int] isOpen(): Return the opening status of the door
    • DEPRECATED getState() → isOpen()
  • toggle(): Toggle the door
Link to comment
Share on other sites


Element

All Elements share the same generic methods described below

 

Quote

This API has been modified to apply the new naming convention to improve the user experience.

 

Functions

  • NEW showWidget(): Show the element widget in the in-game widget stack
    • DEPRECATED show() → showWidget()
  • NEW hideWidget(): Hide the element widget in the in-game widget stack
    • DEPRECATED hide() → hideWidget()
  • [string] getWidgetType(): Returns the widget type compatible with the element data
  • NEW [string] getWidgetData(): Returns the element data as JSON
    • DEPRECATED [string] getData() → [string] getWidgetData()
  • NEW [string] getWidgetDataId(): Returns the element data ID
    • DEPRECATED [string] getDataId() → [string] getWidgetDataId()
       
  • NEW [string] getName(): Returns the element name
  • NEW [string] getClass(): Returns the class of the Element
    • DEPRECATED [string] getElementClass() → [string] getClass()
  • [float] getMass(): Returns the mass of the element (includes the included items' mass when the Element is a Container)
  • NEW [int] getItemId(): Returns the element item ID (to be used with system.getItem() function to get information about the element).
  • NEW [int] getLocalId(): Returns the unique local ID of the element
    • DEPRECATED [int] getLocalId() → [int] getId()
       
  • [float] getIntegrity(): Returns the element integrity between 0 and 100
  • [float] getHitPoints(): Returns the element's current hit points (0 = destroyed)
  • [float] getMaxHitPoints(): Returns the element's maximal hit points
  • [int] getRemainingRestorations(): Returns the element's remaining number of restorations
  • [int] getMaxRestorations(): Returns the element's maximal number of restorations
     
  • NEW [table] getPosition(): Returns the position of the Element in construct local coordinates.
  • NEW [table] getBoundingBoxSize(): Returns the bounding box dimensions of the element.
  • NEW [table] getBoundingBoxCenter(): Returns the position of the center of bounding box of the element in local construct coordinates.
  • NEW [table] getUp(): Returns the up direction vector of the Element in construct local coordinates
  • NEW [table] getRight(): Returns the right direction vector of the Element in construct local coordinates
  • NEW [table] getForward(): Returns the forward direction vector of the Element in construct local coordinates
  • NEW [table] getWorldUp(): Returns the up direction vector of the Element in world coordinates
  • NEW [table] getWorldRight(): Returns the right direction vector of the Element in world coordinates
  • NEW [table] getWorldForward(): Returns the forward direction vector of the Element in world coordinates

 

  • setSignalIn(plug, state): Set the value of a signal in the specified IN plug of the Element.
    • [string] plug: The plug name, in the form of IN-SIGNAL-index
    • [int] state: The plug signal state
  • getSignalIn(plug, state): eturns the value of a signal in the specified IN plug of the Element.
    • [string] plug: The plug name, in the form of IN-SIGNAL-index
    • return [int]: The plug signal state
  • getSignalOut(plug): Returns the value of a signal in the specified OUT plug of the Element.
    • [string] plug: The plug name, in the form of IN-SIGNAL-index
    • return [int]: The plug signal state
Link to comment
Share on other sites

Emitter

This unit is capable of emitting messages on a channel

 

Quote

This API receives the addition of an onSent event to verify the message sent.

 

Functions

  • send(): Send a message on the given channel, limited to one transmission per frame and per channel
    • [string] channel: The channel name, limited to 64 characters. The message will not be sent if it exceeds this
    • [string] message: The message to be transmitted, truncated to 512 characters in case of overflow
  • [float] getRange(): Returns the emitter range

Events

  • NEW onSent([string] channe, [string] message): Emitted when a player enters in the detection zone
    • [string] channel: The channel name
    • [string] message: The transmitted message
Link to comment
Share on other sites

Firework

A firework launcher capable to launch Fireworks that are stored in the attached Container.

 

Quote

This API has received new functions to allow a better use of the element and the integration of index instead of string for the types and colors properties.

 

Functions

  • NEW fire(): Fire the firework
    • DEPRECATED activate() → fire()
  • setExplosionDelay([float] delay): Set the delay before the launched Fireworks explodes
    • [float] delay: The delay before explosion in seconds (maximum 5s)
  • NEW [float] getExplosionDelay(): Returns the delay before the launched Fireworks explodes
  • setLaunchSpeed([float] speed): Set the speed at which the firework will be launched (impacts its altitude, depending on the local gravity).
    • [float] speed: The launch speed in m/s (maximum 200m/s)
  • NEW [float] getLaunchSpeed(): Returns the speed at which the firework will be launched
  • setType([int] type): Set the type of launched firework (will affect which firework is picked in the attached Container)
    • [int] type: The type index of the firework (Ball = 1, Ring = 2, Palmtree = 3, Shower = 4)
  • NEW [float] getType(): Returns the type of launched firework
  • setColor([int] color): Set the color of the launched firework (will affect which firework is picked in the attached Container)
    • [int] color: The color index of the firework (Blue = 1, Gold = 2, Green = 3, Purple = 4, Red = 5, Silver = 6)
  • NEW [float] getColor(): Returns the color of the launched firework

Events

  • NEW onFire(): Emitted when a firework has just been fired
Link to comment
Share on other sites

Force Field

A Force Field to create an uncrossable energy barrier.

 

Quote

This API has been modified in order to improve the user experience.

 

Functions

  • NEW deploy(): Deploys the forcefield
    • DEPRECATED activate() → deploy()
  • NEW retract(): Retracts the forcefield
    • DEPRECATED deactivate() → retract()
  • NEW isDeployed(): Checks if the forcefield is deployed
    • DEPRECATED getState() → isDeployed()
  • [float] toggle(): Toggle the forcefield
Link to comment
Share on other sites

Gyro

A general kinematic unit to obtain information about the ship orientation, velocity, and acceleration.

 

Quote

This API has been modified in order to improve the user experience and the axis functions removed as now inherited from the generic element.

 

Functions

  • activate(): Selects this gyro as the main gyro used for ship orientation
  • deactivate(): Deselects this gyro as the main gyro used for ship orientation, using the Core Unit instead
  • toggle(): Toggle the activation state of the gyro
  • NEW isActive(): Returns the activation state of the gyro
    • DEPRECATED getState() → isActive()
  • [float] getPitch(): The pitch value relative to the gyro orientation and the local gravity
    • return [float]: The pitch angle in degrees, relative to the gyro orientation and the local gravity
  • [float] getRoll(): The roll value relative to the gyro orientation and the local gravity
    • return [float]: The roll angle in degrees, relative to the gyro orientation and the local gravity
       
  • DEPRECATED [table] localForward() → [table] getForward()
  • DEPRECATED [table] localRight() → [table] getRight()
  • DEPRECATED [table] localUp() → [table] getUp()
  • DEPRECATED [table] worldForward() → [table] getWorldForward()
  • DEPRECATED [table] worldRight() → [table] getWorldRight()
  • DEPRECATED [table] worldUp() → [table] getWorldUp()
Link to comment
Share on other sites

NEW Hover Engines

Hover engines are engines designed for ground vehicles in the atmosphere; they require a surface to produce thrust.

 

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

Industry

An industry is a machine designed to produce different types of elements

 

Quote

This API has been modified to add new functions to make the interaction with the element more interesting and a new naming convention for events.

 

Functions

  • NEW startRun(): Start the production, and it will run unless it is stopped or the input resources run out
    • DEPRECATED start() → startRun()
  • NEW startMaintain([float] quantity): Start maintaining the specified quantity. Resumes production when the quantity in the output Container is too low, and pauses production when it is equal or higher
    • [float] quantity: Quantity to maintain inside output containers
    • DEPRECATED startAndMaintain([float] quantity) → startMaintain([float] quantity)
  • NEW startFor([int] numBatches): Start the production of numBatches and then stop
    • [int] numBatches: Number of batches to run before unit stops
    • DEPRECATED batchStart([int] numBatches) → startFor([int] numBatches)
  • NEW stop([bool] force,[bool] allowLoss): Stop the production of the industry unit
    • [bool] force: (optional by default false) True if you want to force the production to stop immediately
    • [bool] allowLoss: (optional by default false) True if you want to allow the industry unit to lose components when recovering in use components
    • DEPRECATED hardStop([bool] allowLoss) → stop( true, [bool] allowLoss)
    • DEPRECATED softStop() → stop(false)
       
  • [int] getStatus(): Get the current running state of the industry
    • return [int]: (Stopped = 1, Running = 2, Jammed missing ingredient = 3, Jammed output full = 4, Jammed no output container = 5, Pending = 6)
  • NEW [table] getState(): Get the complete state of the industry
    • return [table]: The complete state of the industry, a table with fields {[int] state, [bool] stopRequested, [int] schematicId, [int] unitsProduced, [int] remainingTime, [int] batchesRequested, [int] batchesRemaining, [float] maintainProductAmount, [int] currentProductAmount}
  • [int] getCyclesCompleted(): Get the count of completed cycles since the player started the unit
    • DEPRECATED [int] getCycleCountSinceStartup() → [int] getCyclesCompleted()
  • [float] getEfficiency(): Returns the efficiency of the industry
  • [float] getUptime(): Returns the time elapsed in seconds since the player started the unit for the latest time
  • [int] getCurrentSchematic(): Get the id of the currently loaded Schematic
  • setCurrentSchematic([int] id): Set the loaded Schematic, based on its id. Use getCurrentSchematic to learn about your Schematic id

Events

  • NEW onStarted([int] id, [float] quantity): Emitted when the Industry Unit has started a new production process
    • [int] id: The product item id
    • [float] quantity: The product quantity
  • NEW onCompleted([int] id, [float] quantity): Emitted when a player enters in the detection zone
    • [int] id: The product item id
    • [float] quantity: The product quantity
    • DEPRECATED completed([int] id, [float] quantity) → onCompleted([int] id, [float] quantity)
  • NEW onStatusChanged([int] status): Emitted when the industry status has changed
    • [int] status: The status of the industry can be (Stopped = 1, Running = 2, Jammed missing ingredient = 3, Jammed output full = 4, Jammed no output container = 5, Pending = 6)
    • DEPRECATED statusChanged[int] status) → onStatusChanged([int] status)
Link to comment
Share on other sites

Landing Gear

A Landing Gear that can be opened or closed.

 

Quote

This API has been modified in order to improve the user experience.

 

Functions

  • NEW deploy(): Deploys the landing gear
    • DEPRECATED activate() → deploy()
  • NEW retract(): Retracts the landing gear
    • DEPRECATED deactivate() → retract()
  • NEW isDeployed(): Checks if the landing gear is deployed
    • DEPRECATED getState() → isDeployed()
  • [float] toggle(): Toggle the landing gear
Link to comment
Share on other sites

Laser Detector

Detect the hit of a Laser.

 

Quote

This API has been modified in order to improve the user experience.

 

Functions

  • NEW isHit(): Checks if any laser is hitting the detector
    • DEPRECATED getState() → isHit()

Events

  • NEW onHit(): Emitted when a laser hit the detector
    • DEPRECATED laserHit() → onHit()
  • NEW onLoss(): Emitted when all lasers stop hitting the detector
    • DEPRECATED laserRelease() → onLoss()
Link to comment
Share on other sites

Laser Emitter

Emits a Laser ray that can be use to detect the passage of a player or on a Laser Detector unit.

 

Quote

This API has been modified in order to improve the user experience.

 

Functions

  • activate(): Activates the laser emitter
  • deactivate(): Deactivates the laser emitter
  • toggle(): Toggle the laser emitter
  • NEW [int] isActive(): Checks if the laser emitter is active
    • DEPRECATED [int] getState() → [int] isActive()
Link to comment
Share on other sites

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