Player

From Minetest Developer Wiki
(Redirected from Player:get look yaw)
Jump to: navigation, search

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

Methods

  • is_player()true for players, false for others
  • is_player_connected("name") — returns true if name is connected
  • get_player_name() — returns "" if is not a player
  • get_attribute(attribute) — returns the value for the extra player attribute or nil if this attribute had not been set. The return value is always a string
  • set_attribute(attribute, value) — 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
  • get_look_dir() — returns the camera direction as a unit vector
  • get_look_pitch() - DEPRECATED use get_look_vertical
  • set_look_pitch(pitch) - DEPRECATED use set_look_vertical
  • get_look_yaw() - DEPRECATED use get_look_horizontal
  • set_look_yaw(yaw) - DEPRECATED use set_look_horizontal
  • get_look_horizontal() — returns yaw in radians
  • set_look_horizontal(yaw) — 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 :
dir Δx dir Δz Value
0 1 π/2
0 -1 3π/2
1 0 π
-1 0 0
To convert a Δx,Δz to a yaw value use following formula :
if Δz<0 then
yaw = -atan(Δx/Δz)
else if Δz>0
yaw = π-atan(Δx/Δz)
else if Δx<0
yaw = 0
else
yaw = π
  • get_look_vertical() — returns pitch in radians
  • set_look_vertical(pitch) — set pitch in radians.
  • get_player_control() — 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}
  • get_player_control_bits() — 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
  • get_breath() returns players breath
  • set_breath(value)
    • 0 player is drowning
    • 1-10 number of bubbles remain
    • 11 bubbles bar is not shown
  • set_physics_override(table)
    • 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
    • }
  • get_physics_override() -- returns a table by set_physics_override
  • get_player_velocity() — returns player speed with a table {x,y,z}, or nil if not a player
  • get_inventory_formspec() — returns formspec string

as of now)

  • set_inventory_formspec("string") — redefine player's inventory form. Should usually be called by using minetest.register_on_joinplayer().
  • hud_add(hud definition) Shows a HUD element to the player
  • hud_change(id, stat, value) Changes a HUD element shown to the player
  • hud_remove(id) Removes a HUD element shown to the player
  • hud_get(id) Gets a HUD element definition
  • hud_set_flags(flags) Sets specified HUD flags to true/false
    • flags: (is visible) hotbar, healthbar, crosshair, wielditem
    • pass a table containing a true/false value of each flag to be set or unset
note.png
Note: if a flag is nil, the flag is not modified


  • hud_get_flags() Returns a table containing the status of HUD flags
  • hud_get_hotbar_itemcount() Returns the number of items in builtin hotbar
  • hud_set_hotbar_itemcount(count) Set number of items in builtin hotbar
note.png
Note: Count must be between 1 and 23


  • hud_get_hotbar_image() Returns the background image name for hotbar
  • hud_set_hotbar_image(texturename) Sets background image for hotbar
  • hud_get_hotbar_selected_image() Returns the image name for hotbar selected item
  • hud_set_hotbar_selected_image(texturename) Sets image for hotbar selected item
  • hud_replace_builtin(name, hud definition) Replace the definition of a builtin HUD element
  • set_sky(bgcolor, type, {texture names})
    • 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
note.png
Note: currently does not work directly in on_joinplayer; use minetest.after(0) in there.


  • override_day_night_ratio(ratio) — Overrides day/night ratio, controlling sunlight to a specific amount.
    • ratio — Ratio from 0 to 1, or nil to reset to default behavior.
  • get_eye_offset() — Returns eye offset. See set_eye_offset()
  • set_eye_offset(pos1p, pos3p) — 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 {x=0,y=0,z=0} 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.
    • pos1p — Offset vector in first person view.
    • pos3p — Offset vector in third person view. Ranges: x=-10..10, y=-10..15, z=-5..5
  • get_local_animation(player) — Returns 4 frames and frame speed. See set_local_animation
  • set_local_animation({x=0, y=79}, {x=168, y=187}, {x=189, y=198}, {x=200, y=219}, frame_speed=30) — Sets animation for player model in third person view.

Inherited from ObjectRef

  • getpos() — returns {x=num, y=num, z=num}.
  • get_armor_groups() - Returns {group1=rating, group2=rating, ...})
note.png
Note: Documented in lua_api.txt but not yet implemented as of version 0.4.4


  • get_animation() - Returns frames, frame_speed, frame_blend, frame_loop.
  • frames - {x=int,y=int}
  • frame_speed - integer
  • frame_blend - integer
  • frame_loop - true if the animation is looping
  • get_hp() — returns number of hitpoints (2 * number of hearts).
  • get_inventory() — returns the InvRef of the object.
  • get_wielded_item() — returns the wielded item (ItemStack). This is essentially just a pseudonym for object:get_inventory():get_stack(object:get_wield_list(), object:get_wield_index()) so please note the caveats for inventory manipulation (changes will need to be "committed" by calling object:set_wielded_item(modifiedStack) after modifying the stack unless they are done in the context of a callback that implicitly modifies the stack; see minetest.register_node#on_use).
  • get_wield_index() — returns the index of the wielded item
  • get_wield_list() — returns the name of the inventory list the wielded item is in
  • moveto(pos, continuous=false) — interpolated move
  • punch(puncher, time_from_last_punch, tool_capabilities, direction)
  • puncher — an another ObjectRef
  • time_from_last_punch — time since last punch action of the puncher
  • direction: can be nil
  • clicker — another ObjectRef
Personal tools
Namespaces

Variants
Actions
Navigation
API
Toolbox