ObjectRef

From Minetest Developer Wiki
(Redirected from ObjectRef:set detach)
Jump to: navigation, search

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_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_armor_groups() - Returns {group1=rating, group2=rating, ...})
  • get_attach() — returns nil when not attached or multiple values:
    • parentObjectRef
    • bone — bone name (string)
    • position — attachment position offset (vector)
    • rotation — fixed child attachment rotation (vector)
  • get_bone_position(bone_name) — returns multiple values:
    • position — attachment position offset (vector)
    • rotation — attachment rotation (vector)
  • get_breath() — returns amount of remaining breath (maximum 11 by default).
  • get_hp() — returns number of hitpoints (maximal 20 by default).
  • get_inventory() — returns the InvRef of the object.
  • get_pos() — returns {x=num, y=num, z=num}.
  • 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
  • get_wielded_item() — returns the wielded item (ItemStack). This is essentially just a shortcut 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).
  • 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
  • remove() — remove object (after returning from Lua)
  • right_click(clicker)
    • clicker — another ObjectRef
  • set_animation({x=1,y=1}, frame_speed=15, frame_blend=0)
  • set_armor_groups({group1=rating, group2=rating, ...})
  • set_attach(parent, bone_name, {x=0,y=0,z=0}, {x=0,y=0,z=0}) — attaches the object to a bone of another object
  • set_bone_position(bone_name, {x=0,y=0,z=0}, {x=0,y=0,z=0}) — set position offset and rotation of a bone
  • set_detach() — detaches object
  • set_hp(hp) — set number of hitpoints (2 * number of hearts)
  • set_pos(pos)
  • set_properties({object property table})
  • set_wielded_item(item) — replaces the wielded item, returns true if successful

Bones

The bone names that can be used with set_bone_position, get_bone_position, set_attach and returned by get_attach are those defined in the corresponding 3D model file.

For the default player model provided with Minetest Game (model file character.b3d), the following bone names are defined:

  • Body
  • Head
  • Arm_Left
  • Arm_Right
  • Leg_Left
  • Leg_Right

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"


This article is incomplete.


Personal tools
Namespaces

Variants
Actions
Navigation
API
Toolbox