Player Script API: Difference between revisions

From DF21 Wiki
(enums)
No edit summary
Line 56: Line 56:


== Properties ==
== Properties ==
=== position ===
* Get or set
* Gets or sets the player's current position (float3)
* You will not be allowed to move the player outside of a sector
* Usage example: get the current player position and change it to 10 units higher altitude
<pre>
float3 currentPos = player.position;
player.position = {currentPos.x, currentPos.y + 10, currentPos.z};
</pre>
=== yaw ===
* Get or set
* Gets or sets the player's yaw (float in degrees)
* Usage example: make the player face south
* <code>player.yaw = 180;</code>
=== velocity ===
* Get or set
* Gets or sets the player's velocity (float3)
* Usage example: set the player's velocity to 100 north + 100 west
<pre>player.velocity = {-100.0, 0, 100.0};</pre>
* Usage example: set the player's velocity to 50 upwards and 30 south
<pre>player.velocity = {0, 50.0, -30.0};</pre>
== Methods ==
=== kill ===
* Instantly kill the player
* Usage example: <code>player.kill();</code>

Revision as of 09:18, 28 March 2025

Documentation for TFE Player Script API.

Enums

ITEM enum

PLANS
PHRIK
NAVA
DT_WEAPON
DATATAPE
ITEM10

WEAPON enum

PISTOL
RIFLE
REPEATER
FUSION
MORTAR
CONCUSSION
CANNON

AMMO enum

AMMO_ENERGY
AMMO_POWER
AMMO_DETONATOR
AMMO_SHELL
AMMO_PLASMA
AMMO_MINE
AMMO_MISSILE

Properties

position

  • Get or set
  • Gets or sets the player's current position (float3)
  • You will not be allowed to move the player outside of a sector
  • Usage example: get the current player position and change it to 10 units higher altitude
float3 currentPos = player.position;
player.position = {currentPos.x, currentPos.y + 10, currentPos.z};

yaw

  • Get or set
  • Gets or sets the player's yaw (float in degrees)
  • Usage example: make the player face south
  • player.yaw = 180;

velocity

  • Get or set
  • Gets or sets the player's velocity (float3)
  • Usage example: set the player's velocity to 100 north + 100 west
player.velocity = {-100.0, 0, 100.0};
  • Usage example: set the player's velocity to 50 upwards and 30 south
player.velocity = {0, 50.0, -30.0};

Methods

kill

  • Instantly kill the player
  • Usage example: player.kill();