Skip to content

LUA methods for Movement

Peter-Crawley edited this page Oct 18, 2021 · 9 revisions

Ship controller specific methods

getLocalPosition

Returns the location of the ship controller.

x, y, z = shipController.getLocalPosition()

getAttachedPlayers

Returns the list of attached players.

stringPlayers, arrayPlayers = shipController.getAttachedPlayers()
  • stringPlayers is a comma separated list
  • arrayPlayers is only available on OpenComputers
  • only attached players can be summoned

getShipSize

Returns the ship mass measured in blocks.

shipMass, shipVolume = shipController.getShipSize()
  • this is fairly slow call, make sure you only call it when strictly necessary (i.e. not at every screen refresh)
  • shipMass is the count of non-air blocks
  • shipVolume is the count of all blocks. It was added in 1.3.31

getOrientation

Returns the x,y,z vector for the ship front.

dx, dy, dz = shipController.getOrientation()
  • dx and dz are -1, 0 or +1 depending on ship controller position relative to ship core. They're nil is ship core wasn't detected
  • dy is always 0, obviously :)

getEnergyRequired

Returns energy required for jumping with current parameters

shipController.command(...)
shipController.movement(...)
success, energyRequired = shipController.getEnergyRequired()
  • success is true if the arguments are correct. In the opposite, second return value is the error message
  • energyRequired is the estimated energy required for a single jump with current parameters. By default, it depends on the current position and mass of the ship.

Previously to 1.3.31, the syntax was:

energyRequired = shipController.getEnergyRequired(distance)

isInSpace, isInHyperspace

Type: Boolean

Returns the status for the current ship position.

getMaxJumpDistance

Reports the maximum jump distance for current dimension and command.

shipController.command(...)
shipController.movement(...)
success, distance = shipController.getMaxJumpDistance()
  • success is true if the arguments are correct. In the opposite, second return value is the error message
  • distance is the maximum movement of the ship in a single jump. It depends on the current position and mass of the ship.

Previously to 1.3.31, the syntax was:

distance = shipController.getMaxJumpDistance()

isAttached (deprecated)

This was used to report if a ship core was found. Use it to confirm the ship is ready during boot time/chunk loading. isAttached() was replaced to isAssemblyValid() as of 1.3.31, allowing to get a status message.

jump (deprecated)

This was used to trigger the jump sequence based on previously set properties. jump() was replaced by enable(true) as of 1.3.31, allowing to disable an ongoing command.

summon (deprecated)

Summon a specific player Returns true if the arguments are correct.

success, namePlayer = shipController.summon(indexPlayer)
  • indexPlayer is a 0 based index in the array returned by getAttachedPlayers()
  • success is true if the arguments are correct. In the opposite, second return value is the error message
  • namePlayer is the name of the player that will be considered for summoning
  • player summoning will happen after the return from this call
  • player will be teleported in front or around of the ship core since 1.3.20

summon_all (deprecated)

Summon all attached players back to the ship.

shipController.summon_all()
  • player summoning will happen after the return from this call
  • player will be teleported in front of the ship core as of 1.3.20
  • this method has been removed as of 1.3.31. You can loop through attached players to get a similar behavior.

Transporter core specific properties

getLockStrength

Returns the current lock strength.

lockStrength = transporterCore.getLockStrength()
  • lockStrength is a number from 0.0 (no lock) to 1.0 (perfect lock) or higher

getEnergyRequired

Returns the acquisition and energizing energy required per tick.

acquisitionEnergy, energizeEnergy = transporterCore.getEnergyRequired()
  • acquisitionEnergy is the energy required per tick for locking on a remote location
  • energizeEnergy is the energy required per tick for energizing
Clone this wiki locally