Module player

Player related variables and functions

Functions

hurt (damage, vel, recovery) Hurts the player by a specific amount and with a specified velocity.
setmetadata (key, value) Sets a metadata with a specified key-value pair to the player.
getmetadata (key, defaultValue) Gets a player metadata value with the specified key.
alert (message) Sends an alert popup to the player.
chat (message, color) Sends a chat message to the player.
safety () Teleports the player to the latest 'safe' block.
giveitem (item) Gives the player a specified default item.
givelaser (settings) Gives the player a laser gun item with specified settings.
givesword (settings) Gives the player a sword item with specified settings.
giverocket (settings) Gives the player a rocket launcher item with specified settings.
givebow (settings) Gives the player a bow item with specified settings.
givegrenade (settings) Gives the player a grenade item with specified settings.
givelightningcloud (settings) Gives the player a lightning cloud item with specified settings.
giveblackhole (settings) Gives the player a black hole item with specified settings.
teleportto (xpos, ypos, keepvelocity) Teleports the player to the given direction.
rotate (value, amplifier) Rotates a player to a given rotation at a given speed.
removeitem () Removes the item that the player is currently holding.
chill (amount) Chills the player, causing massive reduction in stats until the effect wears off.
dye (color) Dyes the player's body parts for the rest of the match.
playsound (id, volume) Plays a sound effect to the player.
disableup (times) Disables the player's up input for a duration.
disabledown (times) Disables the player's down input for a duration.
disableleft (times) Disables the player's left input for a duration.
disableright (times) Disables the player's right input for a duration.
autoup (times) Forces the player's up input to be pressed for a duration.
autodown (times) Forces the player's down input to be pressed for a duration.
autoleft (times) Forces the player's left input to be pressed for a duration.
autoright (times) Forces the player's right input to be pressed for a duration.
disablesuperjump () Disables the player's superjump until re-enabled.
enablesuperjump () Enables the player's superjump.
keypressed (keycode) Is the specified key currently pressed?
postGameEvent (data, sendToSelf) Sends a gameEvent to every player in the match.

Fields

team The current team the player is in.
tick The event handler for player tick.
health Player's current health.
maxhealth Player's max health.
rotation Player's current rotation in degrees.
speed Player's current speed stat.
jump Player's current jump stat.
accel Player's current acceleration stat.
gravity Strength of the gravity affecting the player.
fov Affects how far can you see (zoom).
xvelocity Player's current horizontal velocity.
yvelocity Player's current vertical velocity.
xmove The current horizontal momentum of the player.
ymove The current vertical momentum of the player.
x The absolute x-position of the player.
y The absolute y-position of the player.
xpos The next absolute x-position of the player.
ypos The next absolute y-position of the player.
safex The absolute x-position of the player's respawn location.
safey The absolute y-position of the player's respawn location.
camerax The absolute x-position of the camera (top left corner; not affected by player.fov).
cameray The absolute y-position of the camera (top left corner; not affected by player.fov).
stiffness Defines how fast the camera does follow the player.
hat Player's array of hats.
minimap Is the minimap currently visible?
teleStealth Does the teleport effect appear when the player teleports?
recoverytimer The remaining duration, in milliseconds, of the player's invulnerability received by recovering from damage.
hurttimer The remaining duration, in milliseconds, of the player's stun received by damage.
frost The remaining duration, in milliseconds, of the player's chill.
uppressed Is the up arrow key or w currently pressed?
downpressed Is the down arrow key or s currently pressed?
leftpressed Is the left arrow key or a currently pressed?
rightpressed Is the right arrow key or d currently pressed?
spacepressed Is the spacebar currently pressed?


Functions

hurt (damage, vel, recovery)
Hurts the player by a specific amount and with a specified velocity.

Parameters:

  • damage int The amount of damage done to the player. By default 1.
  • vel number The strength of the impact that pushes the player. By default 0.3.
  • recovery number The number of seconds the player takes to recover. By default 2.5.

Usage:

    player.hurt(2, 0.15)
setmetadata (key, value)
Sets a metadata with a specified key-value pair to the player.

Parameters:

  • key string Name of the metadata variable (the key)
  • value Value of the metadata variable

Usage:

    player.setmetadata("coins", 10)
getmetadata (key, defaultValue)
Gets a player metadata value with the specified key.

Parameters:

  • key string The key (metadata variable name) that's used to find its value.
  • defaultValue The value to return if the searched key does not exists. By default no specific value is returned.

Returns:

    Returns the key's value. Returns defaultValue instead if the key isn't found.

Usage:

    player.getmetadata("coins", 0)
alert (message)
Sends an alert popup to the player.

Parameters:

  • message string The message to show the player.

Usage:

    player.alert("Hello world!")
chat (message, color)
Sends a chat message to the player.

Parameters:

  • message string The message to show to the player.
  • color int The decimal (or hex) value of the RGB color to use. By default #1D5497.

Usage:

  • player.chat('hello', 0x1D5497)
  • player.chat('hello', 1922199)
safety ()
Teleports the player to the latest 'safe' block.
giveitem (item)
Gives the player a specified default item.

Parameters:

  • item string The given item. Options are: "sword", "lasergun", "angelwings", "blackhole", "bow", "freezeray", "heart", "grenade", "jetpack", "lightning", "lightningcloud", "napalm", "portableblock", "portablemine", "rocketlauncher", "shield", "snowball", "speedburst", "superjump", "teleport", "superteleport"

Usage:

    player.giveitem("lasergun")
givelaser (settings)
Gives the player a laser gun item with specified settings. Fields: ammo(int), reload(float), damage(int), recoil(float), knockback(float), sap(int), recovery(float), speed(float), range(float), rotation(String), repeats(float), phasing(float), transferhit(int), transferfade(int) rotation takes the format "float1,float2", where float1 is the first bullet's rotation in degrees and float2 is the number of degrees incremented to each subsequent bullet's rotation (for multi-shots created with the repeats field) rotation also accepts a single float or a string of a single float, in which case float2 defaults to 0 transferhit and transferfade are active when set to 1

Parameters:

  • settings The given laser gun item as an AS3 Object.

Usage:

    player.givelaser(toobject{ammo=100,reload=1,speed=50,range=0.5,phasing=10,recoil=0})
givesword (settings)
Gives the player a sword item with specified settings. Fields: ammo(int), reload(float), damage(int), recoil(float), knockback(float), sap(int), recovery(float)

Parameters:

  • settings The given sword item as an AS3 Object.

Usage:

    player.givesword(toobject{ammo=20,reload=2,recoil=50})
giverocket (settings)
Gives the player a rocket launcher item with specified settings. Fields: ammo(int), reload(float), damage(int), recoil(float), knockback(float), sap(int), recovery(float), speed(float), accel(float), maxVel(float), range(float), rotation(String), repeats(float), phasing(float) rotation takes the format "float1,float2", where float1 is the first bullet's rotation in degrees and float2 is the number of degrees incremented to each subsequent bullet's rotation (for multi-shots created with the repeats field) rotation also accepts a single float or a string of a single float, in which case float2 defaults to 0

Parameters:

  • settings The given rocket launcher item as an AS3 Object.

Usage:

    player.giverocket(toobject{ammo=5,reload=4,speed=-20,range=50,recoil=0})
givebow (settings)
Gives the player a bow item with specified settings. Fields: ammo(int), reload(float), damage(int), knockback(float), sap(int), recovery(float), range(float), phasing(int), rotation(String), repeats(int), pullspeed(int), maxforce(int), autofire(int, 0 or 1) rotation takes the format "float1,float2", where float1 is the first bullet's rotation in degrees and float2 is the number of degrees incremented to each subsequent bullet's rotation (for multi-shots created with the repeats field) rotation also accepts a single float or a string of a single float, in which case float2 defaults to 0

Parameters:

  • settings The given bow item as an AS3 Object.

Usage:

    player.givebow(toobject{ammo=5,pullspeed=2,autofire=1,reload=0,rotation="-6,2",repeats=7})
givegrenade (settings)
Gives the player a grenade item with specified settings. Fields: ammo(int), reload(float), damage(int), knockback(float), recovery(float), blastdelay(int), throwforcex(float), throwforcey(float), hurtarea(int), blastdamage(int), blastrecovery(float), blastradius(int)

Parameters:

  • settings The given grenade item as an AS3 Object.

Usage:

    player.givegrenade(toobject{ammo=1,reload=8,damage=1,knockback=10,recovery=25,blastdelay=95,throwforcex=1,throwforcey=1,hurtarea=120,blastdamage=1,blastrecovery=25,blastradius=1})
givelightningcloud (settings)
Gives the player a lightning cloud item with specified settings. Fields: damage(int), zaptime(int), extrazaptime(int), zaps(int), recovery(float), passcooldown(int)

Parameters:

  • settings The given lightning cloud item as an AS3 Object.

Usage:

    player.givelightningcloud(toobject{damage=1,zaptime=270,extrazaptime=270,zaps=1,recovery=25,passcooldown=27})
giveblackhole (settings)
Gives the player a black hole item with specified settings. Fields: ammo(int), reload(float), duration(int), strength(float), speedx(int), speedy(int).

Parameters:

  • settings The given black hole item as an AS3 Object.

Usage:

    player.giveblackhole(toobject{ammo=1,reload=8,duration=9900,strength=1,speedx=0,speedy=0})
teleportto (xpos, ypos, keepvelocity)
Teleports the player to the given direction.

Parameters:

  • xpos number Teleport the player (xpos) blocks among the x-axis.
  • ypos number Teleport the player (ypos) blocks among the y-axis. A positive y teleports the player down.
  • keepvelocity boolean Determines if the player keeps their velocity after teleportation. False by default.

Usage:

    player.teleportto(3, -1, true)
rotate (value, amplifier)
Rotates a player to a given rotation at a given speed.

Parameters:

  • value (float) Sets the angle that the player will be rotated to in the nearest increment of 90.
  • amplifier (Number) Sets the speed amplifier of the rotation speed. For reference, Fez rotates at 10 amplifier.

Usage:

    player.rotate(90, 1.6)
removeitem ()
Removes the item that the player is currently holding.
chill (amount)
Chills the player, causing massive reduction in stats until the effect wears off.

Parameters:

  • amount number The amount of chill applied in seconds. By default 6.

Usage:

    player.chill(6)
dye (color)
Dyes the player's body parts for the rest of the match.

Parameters:

  • color int The decimal color applied to the player's parts. By default 16777215.

Usage:

    player.dye(255)
playsound (id, volume)
Plays a sound effect to the player.

Parameters:

  • id int Id of the played sound effect. (0: jetpack, 1: level start, 2: sword, 3: lightning, 4: coin, 5: jump, 6: item block, 7: black hole, 8: rocket launcher, 9: shatter, 10: sad block, 11: laser gun hit, 12: ready, 13: explosion, 14: teleport, 15: match end, 16: shield, 17: shield extra, 18: bow draw, 19: water enter, 20: happy block, 21: speed burst end, 22: speed burst, 23: bump, 24: cheer, 25: laser gun shot, 26: ouch, 27: bouncy block, 28: bow fire, 29: water exit, 30: portable block, 31: superjump, 32: angel wings, 33: water effect, 34: water effect, 35: water effect, 36: water effect, 37: freeze ray, 38: snowball hit, 39: napalm)
  • volume number Volume of the played sound effect.

Usage:

    player.playsound(6, 2)
disableup (times)
Disables the player's up input for a duration.

Parameters:

  • times int The amount of ticks for the input to be disabled. By default 999999.

Usage:

    local durationInSeconds = 5 player.autoup(durationInSeconds * 27)
disabledown (times)
Disables the player's down input for a duration.

Parameters:

  • times int The amount of ticks for the input to be disabled. By default 999999.

Usage:

    local durationInSeconds = 5 player.autodown(durationInSeconds * 27)
disableleft (times)
Disables the player's left input for a duration.

Parameters:

  • times int The amount of ticks for the input to be disabled. By default 999999.

Usage:

    local durationInSeconds = 5 player.autoleft(durationInSeconds * 27)
disableright (times)
Disables the player's right input for a duration.

Parameters:

  • times int The amount of ticks for the input to be disabled. By default 999999.

Usage:

    local durationInSeconds = 5 player.autoright(durationInSeconds * 27)
autoup (times)
Forces the player's up input to be pressed for a duration.

Parameters:

  • times int The amount of ticks for the input to be pressed. By default 999999.

Usage:

    local durationInSeconds = 5 player.autoup(durationInSeconds * 27)
autodown (times)
Forces the player's down input to be pressed for a duration.

Parameters:

  • times int The amount of ticks for the input to be pressed. By default 999999.

Usage:

    local durationInSeconds = 5 player.autodown(durationInSeconds * 27)
autoleft (times)
Forces the player's left input to be pressed for a duration.

Parameters:

  • times int The amount of ticks for the input to be pressed. By default 999999.

Usage:

    local durationInSeconds = 5 player.autoleft(durationInSeconds * 27)
autoright (times)
Forces the player's right input to be pressed for a duration.

Parameters:

  • times int The amount of ticks for the input to be pressed. By default 999999.

Usage:

    local durationInSeconds = 5 player.autoright(durationInSeconds * 27)
disablesuperjump ()
Disables the player's superjump until re-enabled.

Usage:

    player.disablesuperjump()
enablesuperjump ()
Enables the player's superjump.

Usage:

    player.enablesuperjump()
keypressed (keycode)
Is the specified key currently pressed?

Parameters:

  • keycode int The specified key that is being checked.

Returns:

    Returns true if pressed, otherwise false.

Usage:

    local Zpressed = tolua(player.keypressed(keys.Z))
postGameEvent (data, sendToSelf)
Sends a gameEvent to every player in the match. Used with game.gameEvent.

Parameters:

  • data The event data to send.
  • sendToSelf boolean If true, the gameEvent will also be sent to the sender. By default false.

Usage:

    player.postGameEvent(toobject{type="damageall", message="Everyone took 1 damage!", damage=1}, true)

Fields

team
The current team the player is in. By default 'none'. Teammates can't directly hurt each other unless there are players left only in that team.
tick
The event handler for player tick.

See also:

health
Player's current health. The player is killed if it goes to zero or below.
maxhealth
Player's max health.
rotation
Player's current rotation in degrees. Rotation can only be set to values dividable by 90 degrees.
speed
Player's current speed stat.
jump
Player's current jump stat.
accel
Player's current acceleration stat.
gravity
Strength of the gravity affecting the player.
fov
Affects how far can you see (zoom). Greater values decrease your view size.
xvelocity
Player's current horizontal velocity. Ranges from -1 to 1.
yvelocity
Player's current vertical velocity. Ranges from -1 to 1.
xmove
The current horizontal momentum of the player.
ymove
The current vertical momentum of the player.
x
The absolute x-position of the player.
y
The absolute y-position of the player.
xpos
The next absolute x-position of the player.
ypos
The next absolute y-position of the player.
safex
The absolute x-position of the player's respawn location.
safey
The absolute y-position of the player's respawn location.
camerax
The absolute x-position of the camera (top left corner; not affected by player.fov).
cameray
The absolute y-position of the camera (top left corner; not affected by player.fov).
stiffness
Defines how fast the camera does follow the player. Ranges from 0 to 1. 0 means the camera will not move at all. By default 0.25.
hat
Player's array of hats. Read-only.
minimap
Is the minimap currently visible?
teleStealth
Does the teleport effect appear when the player teleports?
recoverytimer
The remaining duration, in milliseconds, of the player's invulnerability received by recovering from damage.
hurttimer
The remaining duration, in milliseconds, of the player's stun received by damage.
frost
The remaining duration, in milliseconds, of the player's chill.
uppressed
Is the up arrow key or w currently pressed? Read-only.
downpressed
Is the down arrow key or s currently pressed? Read-only.
leftpressed
Is the left arrow key or a currently pressed? Read-only.
rightpressed
Is the right arrow key or d currently pressed? Read-only.
spacepressed
Is the spacebar currently pressed? Read-only.
generated by LDoc 1.4.6 Last updated 2022-07-11 01:44:20