ObjectRef
From Minetest Developer Wiki
(Redirected from ObjectRef:get wielded item)
Moving things in the game are generally these (basically reference to a C++ ServerActiveObject
).
Note that all ObjectRef
s except player are actually LuaEntitySAO.
Methods
- 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 callingobject: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 anotherObjectRef
-
time_from_last_punch
— time since last punch action of thepuncher
-
direction
: can be nil
-
- remove() — remove object (after returning from Lua)
- right_click(clicker)
-
clicker
— anotherObjectRef
-
- set_pos(pos)
-
pos
— position
-
- 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:
-
parent
—ObjectRef
-
bone
—string
of the bone name -
position
: attachment position offset -
rotation
: fixed child attachment rotation
-
- set_bone_position("", {x=0,y=0,z=0}, {x=0,y=0,z=0})
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.