mirror of
https://github.com/minetest/minetest.git
synced 2024-12-24 15:12:23 +01:00
ObjectRef:get_entity_name() and fixing of comments in default/init.lua
This commit is contained in:
parent
49b7055cb3
commit
ff82b95800
@ -160,7 +160,7 @@
|
|||||||
-- - get_player_by_name(name) -- Get an ObjectRef to a player
|
-- - get_player_by_name(name) -- Get an ObjectRef to a player
|
||||||
-- - get_objects_inside_radius(pos, radius)
|
-- - get_objects_inside_radius(pos, radius)
|
||||||
--
|
--
|
||||||
-- NodeMetaRef
|
-- NodeMetaRef (this stuff is subject to change in a future version)
|
||||||
-- - get_type()
|
-- - get_type()
|
||||||
-- - allows_text_input()
|
-- - allows_text_input()
|
||||||
-- - set_text(text) -- eg. set the text of a sign
|
-- - set_text(text) -- eg. set the text of a sign
|
||||||
@ -194,18 +194,21 @@
|
|||||||
-- - right_click(clicker); clicker = an another ObjectRef
|
-- - right_click(clicker); clicker = an another ObjectRef
|
||||||
-- - get_wield_digging_properties() -> digging property table
|
-- - get_wield_digging_properties() -> digging property table
|
||||||
-- - damage_wielded_item(num) (item damage/wear range is 0-65535)
|
-- - damage_wielded_item(num) (item damage/wear range is 0-65535)
|
||||||
-- - add_to_inventory(itemstring): add an item to object inventory
|
-- - add_to_inventory(itemstring): add an item to object inventory (actually only works for the player as of now)
|
||||||
-- - add_to_inventory_later(itemstring): like above, but after callback returns (only allowed for craftitem callbacks)
|
-- - add_to_inventory_later(itemstring): like above, but after callback returns (only allowed for craftitem callbacks)
|
||||||
-- - get_hp(): returns number of hitpoints (2 * number of hearts)
|
-- - get_hp(): returns number of hitpoints (2 * number of hearts)
|
||||||
-- - set_hp(hp): set number of hitpoints (2 * number of hearts)
|
-- - set_hp(hp): set number of hitpoints (2 * number of hearts)
|
||||||
-- LuaEntitySAO-only:
|
-- LuaEntitySAO-only: (no-op for other objects)
|
||||||
-- - setvelocity({x=num, y=num, z=num})
|
-- - setvelocity({x=num, y=num, z=num})
|
||||||
-- - setacceleration({x=num, y=num, z=num})
|
-- - setacceleration({x=num, y=num, z=num})
|
||||||
-- - getacceleration() -> {x=num, y=num, z=num}
|
-- - getacceleration() -> {x=num, y=num, z=num}
|
||||||
-- - settexturemod(mod)
|
-- - settexturemod(mod)
|
||||||
-- - setsprite(p={x=0,y=0}, num_frames=1, framelength=0.2,
|
-- - setsprite(p={x=0,y=0}, num_frames=1, framelength=0.2,
|
||||||
-- - select_horiz_by_yawpitch=false)
|
-- - select_horiz_by_yawpitch=false)
|
||||||
-- Player-only:
|
-- - ^ Select sprite from spritesheet with optional animation and DM-style
|
||||||
|
-- - texture selection based on yaw relative to camera
|
||||||
|
-- - get_entity_name()
|
||||||
|
-- Player-only: (no-op for other objects)
|
||||||
-- - get_player_name(): will return nil if is not a player
|
-- - get_player_name(): will return nil if is not a player
|
||||||
-- - get_inventory() -> InvRef
|
-- - get_inventory() -> InvRef
|
||||||
-- - inventory_set_list(name, {item1, item2, ...})
|
-- - inventory_set_list(name, {item1, item2, ...})
|
||||||
@ -247,8 +250,11 @@
|
|||||||
-- {
|
-- {
|
||||||
-- physical = true,
|
-- physical = true,
|
||||||
-- collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
|
-- collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
|
||||||
-- visual = "cube",
|
-- visual = "cube"/"sprite",
|
||||||
|
-- visual_size = {x=1, y=1},
|
||||||
-- textures = {texture,texture,texture,texture,texture,texture},
|
-- textures = {texture,texture,texture,texture,texture,texture},
|
||||||
|
-- spritediv = {x=1, y=1},
|
||||||
|
-- initial_sprite_basepos = {x=0, y=0},
|
||||||
-- on_activate = function(self, staticdata),
|
-- on_activate = function(self, staticdata),
|
||||||
-- on_step = function(self, dtime),
|
-- on_step = function(self, dtime),
|
||||||
-- on_punch = function(self, hitter),
|
-- on_punch = function(self, hitter),
|
||||||
|
@ -1736,6 +1736,11 @@ void LuaEntitySAO::setSprite(v2s16 p, int num_frames, float framelength,
|
|||||||
m_messages_out.push_back(aom);
|
m_messages_out.push_back(aom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string LuaEntitySAO::getName()
|
||||||
|
{
|
||||||
|
return m_init_name;
|
||||||
|
}
|
||||||
|
|
||||||
void LuaEntitySAO::sendPosition(bool do_interpolate, bool is_movement_end)
|
void LuaEntitySAO::sendPosition(bool do_interpolate, bool is_movement_end)
|
||||||
{
|
{
|
||||||
m_last_sent_move_precision = m_base_position.getDistanceFrom(
|
m_last_sent_move_precision = m_base_position.getDistanceFrom(
|
||||||
|
@ -218,6 +218,7 @@ public:
|
|||||||
void setTextureMod(const std::string &mod);
|
void setTextureMod(const std::string &mod);
|
||||||
void setSprite(v2s16 p, int num_frames, float framelength,
|
void setSprite(v2s16 p, int num_frames, float framelength,
|
||||||
bool select_horiz_by_yawpitch);
|
bool select_horiz_by_yawpitch);
|
||||||
|
std::string getName();
|
||||||
private:
|
private:
|
||||||
void sendPosition(bool do_interpolate, bool is_movement_end);
|
void sendPosition(bool do_interpolate, bool is_movement_end);
|
||||||
|
|
||||||
|
@ -1989,6 +1989,18 @@ private:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get_entity_name(self)
|
||||||
|
static int l_get_entity_name(lua_State *L)
|
||||||
|
{
|
||||||
|
ObjectRef *ref = checkobject(L, 1);
|
||||||
|
LuaEntitySAO *co = getluaobject(ref);
|
||||||
|
if(co == NULL) return 0;
|
||||||
|
// Do it
|
||||||
|
std::string name = co->getName();
|
||||||
|
lua_pushstring(L, name.c_str());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Player-only */
|
/* Player-only */
|
||||||
|
|
||||||
// get_player_name(self)
|
// get_player_name(self)
|
||||||
@ -2190,6 +2202,7 @@ const luaL_reg ObjectRef::methods[] = {
|
|||||||
method(ObjectRef, getacceleration),
|
method(ObjectRef, getacceleration),
|
||||||
method(ObjectRef, settexturemod),
|
method(ObjectRef, settexturemod),
|
||||||
method(ObjectRef, setsprite),
|
method(ObjectRef, setsprite),
|
||||||
|
method(ObjectRef, get_entity_name),
|
||||||
// Player-only
|
// Player-only
|
||||||
method(ObjectRef, get_player_name),
|
method(ObjectRef, get_player_name),
|
||||||
method(ObjectRef, get_inventory),
|
method(ObjectRef, get_inventory),
|
||||||
|
Loading…
Reference in New Issue
Block a user