ObjectRef

From Minetest Developer Wiki
(Redirected from ObjectRef:get hp)
Jump to: navigation, search
Mbox warning.png This page contains unofficial Lua API documentation and is likely to be outdated or wrong.
For the official and up-to-date documentation, refer to lua_api.txt found in your Minetest installation directory under doc.
Mbox warning.png This page has been proposed for deletion for the following reason: "Contains unofficial and potentially outdated, redundant and inconsistent Lua API information"
If you don't think that this page should be deleted, please explain why on the talk page.

Moving things in the game are generally these (basically reference to a C++ ServerActiveObject).

Note that all ObjectRefs except player are actually LuaEntitySAO.

Methods

  • get_pos() — returns {x=num, y=num, z=num}.
  • set_pos(pos)
  • move_to(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
  • get_hp() — returns number of hitpoints (maximal 20 by default).
  • set_hp(hp) — set number of hitpoints (2 * number of hearts)
  • get_inventory() — returns the InvRef of the object.
  • get_wield_list() — returns the name of the inventory list the wielded item is in
  • get_wield_index() — returns the index of the wielded item
  • 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).
  • set_wielded_item(item) — replaces the wielded item, returns true if successful
  • set_armor_groups({group1=rating, group2=rating, ...})
  • get_armor_groups() - Returns {group1=rating, group2=rating, ...})
  • set_animation({x=1,y=1}, frame_speed=15, frame_blend=0)
  • 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
  • set_animation_frame_speed(frame_speed)
  • frame_speed - number, default: 15.0
  • set_attach(parent, "", {x=0,y=0,z=0}, {x=0,y=0,z=0})
  • get_attach() — returns nil when not attached or multiple values:
  • parentObjectRef
  • bonestring of the bone name
  • position: attachment position offset
  • rotation: fixed child attachment rotation
  • set_detach()
  • set_bone_position(bone = "", position = {x=0,y=0,z=0}, rotation = {x=0,y=0,z=0})
  • get_bone_position(bone) - returns position and rotation of bone
  • set_properties({object property table})
  • get_properties() - returns object property table
  • is_player() - returns true for players, false otherwise
  • get_nametag_attributes() - returns table with attributes
  • set_nametag_attributes(attributes)
  • sets attributes of nametag of the object
  • attributes: {color = ColorSpec, text = string}

Object property table

{
    hp_max = 1,
    physical = true,
    weight = 5,
    collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
    visual = "cube"/"sprite"/"upright_sprite"/"mesh"/"wielditem",
    visual_size = {x=1, y=1},
    mesh = "model",
    textures = {}, -- number of required textures depends on visual
    colors = {}, -- number of required colors depends on visual
    spritediv = {x=1, y=1},
    initial_sprite_basepos = {x=0, y=0},
    is_visible = true,
    makes_footstep_sound = false,
    automatic_rotate = false,
}

"cube"/"sprite"/"upright_sprite"/"mesh"/"wielditem"

Mbox important.png This article is incomplete.
Please help expand this article to include more useful information.
Personal tools
Namespaces

Variants
Actions
Navigation
API
Toolbox