From Minetest Developer Wiki
(Redirected from ObjectRef:get wielded item)
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.

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

Note that all ObjectRefs except player are actually LuaEntitySAO.


  • get_pos() — returns {x=num, y=num, z=num}.
  • get_armor_groups() - Returns {group1=rating, group2=rating, ...})
  • 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 (maximal 20 by default).
  • get_breath() — returns amount of remaining breath (maximal 11 by default).
  • 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
  • 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
  • set_pos(pos)
  • set_armor_groups({group1=rating, group2=rating, ...})
  • set_hp(hp) — set number of hitpoints (2 * number of hearts)
  • set_properties({object property table})
  • set_wielded_item(item) — replaces the wielded item, returns true if successful
  • set_animation({x=1,y=1}, frame_speed=15, frame_blend=0)
  • set_attach(parent, "", {x=0,y=0,z=0}, {x=0,y=0,z=0})
  • set_detach()
  • 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

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,


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