Player

These are players in the game. It inherits all the properties of ObjectRef.

Methods

 * — returns  if is not a player
 * — returns player speed with a table {x,y,z}, or nil if not a player
 * Adds to player velocity, this happens client-side and only once.
 * Does not apply during free_move.
 * Note that since the player speed is normalized at each move step, increasing e.g. Y velocity beyond what would usually be achieved (see: physics overrides) will cause existing X/Z velocity to be reduced.
 * Example: `add_player_velocity({x=0, y=6.5, z=0})` is equivalent to pressing the jump key (assuming default settings)
 * Example: `add_player_velocity({x=0, y=6.5, z=0})` is equivalent to pressing the jump key (assuming default settings)


 * — returns the camera direction as a unit vector
 * — returns pitch in radians
 * Angle ranges between -pi/2 and pi/2, which are straight up and down respectively.


 * — returns yaw in radians
 * Angle is counter-clockwise from the +z direction.


 * — set pitch in radians.
 * : Angle from looking forward, where positive is downwards.


 * — set yaw in radians.
 * Parameter has the same meaning as the return value of get_look_horizontal, but it has an offset against get_look_yaw of math.pi/2
 * Example values :


 * To convert a Δx,Δz to a yaw value use following formula :
 * if Δx < 0 then
 * yaw = atan2(-Δx, Δz) + 2π
 * else
 * yaw = atan2(-Δx, Δz)
 * [[File:player_object_look_horizontal_vertical_yaw.png]]


 * - DEPRECATED use get_look_vertical
 * - DEPRECATED use get_look_horizontal
 * Angle is counter-clockwise from the +x direction.


 * - DEPRECATED use set_look_vertical
 * - DEPRECATED use set_look_horizontal
 * returns players breath
 * example for max breath = 11:
 * 0 player is drowning
 * 1-10 number of bubbles remain
 * 11 bubbles bar is not shown
 * — DEPRECATED, use  instead
 * set an extra player attribute to value.
 * The value must be a string, or a number which will be converted to a string.
 * Pass nil as value to remove the attribute
 * — DEPRECATED, use  instead
 * returns the value for the extra player attribute or nil if this attribute had not been set.
 * The return value is always a string
 * — Returns a PlayerMetaRef.
 * redefine player's inventory form.
 * Should usually be called by using.
 * — returns formspec string
 * the formspec string will be added to every formspec shown to the user, except for those with a  tag.
 * This should be used to set style elements such as  and , any non-style elements (eg: label) may result in weird behaviour.
 * Only affects formspecs shown after this is called.
 * — returns a formspec string.
 * — Returns table with player's pressed keys.
 * Format: {jump=bool, right=bool, left=bool, LMB=bool, RMB=bool, sneak=bool, aux1=bool, down=bool, up=bool}
 * — Returns an integer bitfield with player's pressed keys.
 * Bits: 0/up, 1/down, 2/left, 3/right, 4/jump, 5/aux1, 6/sneak, 7/LMB, 8/RMB
 * Table must be like: {
 * speed = 1.0, -- multiplier to default value
 * jump = 1.0, -- multiplier to default value
 * gravity = 1.0, -- multiplier to default value
 * sneak = true, -- whether player can sneak
 * sneak_glitch = true, -- whether player can use the sneak glitch
 * new_move = false, -- use new move/sneak code
 * }
 * -- returns a table by set_physics_override
 * Shows a HUD element to the player, returns ID number on success
 * Removes a HUD element shown to the player
 * Changes a HUD element shown to the player
 * element  values: ,  ,  ,  ,  ,  ,
 * Gets a HUD element definition
 * Sets specified HUD flags to true/false
 * flags: (is visible) hotbar, healthbar, crosshair, wielditem, breathbar, minimap, minimap_radar
 * pass a table containing a true/false value of each flag to be set or unset
 * if a flag is nil, the flag is not modified
 * minimap: Modifies the client's permission to view the minimap. The client may locally elect to not view the minimap.
 * minimap_radar is only usable when minimap is true
 * Returns a table containing the status of HUD flags
 * Set number of items in builtin hotbar
 * count must be between 1 and 32
 * Returns the number of items in builtin hotbar
 * Sets background image for hotbar
 * Returns the background image name for hotbar
 * Sets image for hotbar selected item
 * Returns the image name for hotbar selected item
 * bgcolor: {r=0...255, g=0...255, b=0...255} or nil, defaults to white
 * Available types:
 * "regular": Uses 0 textures, bgcolor ignored
 * "skybox": Uses 6 textures, bgcolor used
 * "plain": Uses 0 textures, bgcolor used
 * clouds: Boolean for whether clouds appear in front of "skybox" or "plain" custom skyboxes (default: true)
 * Available types:
 * "regular": Uses 0 textures, bgcolor ignored
 * "skybox": Uses 6 textures, bgcolor used
 * "plain": Uses 0 textures, bgcolor used
 * clouds: Boolean for whether clouds appear in front of "skybox" or "plain" custom skyboxes (default: true)


 * — returns bgcolor, type, table of textures, clouds
 * — set cloud parameters
 * parameters is a table with the following optional fields:
 * density: from 0 (no clouds) to 1 (full clouds) (default 0.4)
 * color: basic cloud color with alpha channel, ColorSpec (default "#fff0f0e5").
 * ambient: cloud color lower bound, use for a "glow at night" effect. ColorSpec (alpha ignored, default "#000000")
 * height: cloud height, i.e. y of cloud base (default per conf, usually 120)
 * thickness: cloud thickness in nodes (default 16)
 * speed: 2D cloud speed + direction in nodes per second (default ).
 * — returns a table with the current cloud parameters as in set_clouds.
 * — Overrides day/night ratio, controlling sunlight to a specific amount.
 * — Ratio from 0 to 1, or nil to reset to default behavior.
 * — returns the ratio or nil if it isn't overridden
 * — Sets animation for player model in third person view.
 * every parameter beside frame_speed is a table of the form
 * — Returns 4 frames and frame speed. See set_local_animation
 * — Defines camera offset value for player. Offsets are relative to the default camera position for the given view, not relative to the player's position as returned by getpos and not relative to previous calls (so using   resets to the default position for the view).  Offset vectors are in a left-handed coordinate system where x is toward the player's right, y is up, and z is toward the player's front.
 * — Offset vector in first person view.
 * — Offset vector in third person view. Ranges:
 * — Returns eye offset. See set_eye_offset
 * Sends a server-side loaded mapblock to the player.
 * Returns false if failed.
 * Resource intensive - use sparsely
 * To get blockpos, integer divide pos by 16
 * To get blockpos, integer divide pos by 16