pointed_thing entity name

User avatar
runs
Member
 
Posts: 176
Joined: Sat Oct 27, 2018 08:32
GitHub: runsy

pointed_thing entity name

by runs » Fri Dec 28, 2018 12:25

I want to get the name given with 'minetest.register_entity' for a specific entity object.

Code: Select all
local pointed_thing_object = pointed_thing.ref


How can I get the name of this object? (If a player or mob)
 

User avatar
Pyrollo
Member
 
Posts: 223
Joined: Mon Jan 08, 2018 15:14
Location: Paris
GitHub: pyrollo
In-game: Naj
 

User avatar
runs
Member
 
Posts: 176
Joined: Sat Oct 27, 2018 08:32
GitHub: runsy

Re: pointed_thing entity name

by runs » Fri Dec 28, 2018 19:06

Pyrollo wrote:From ObjectRef, get_luaentity(), field name
https://dev.minetest.net/ObjectRef
https://dev.minetest.net/LuaEntitySAO


I've tried the following:

Code: Select all
local pointed_thing_object = pointed_thing.ref
local entity = pointed_thing_object:get_luaentity()
if (entity.name == "")
...
...


And it works OK for normal LUA Entities (mobs), but not for players: the server crashes with 'entity.name' being nil.

Any explanation about this?

Well, I could do a workaround checking 'pointed_thing_object:is_player()' and acting in consequence. But I want to know why player.name = nil.
 

User avatar
Pyrollo
Member
 
Posts: 223
Joined: Mon Jan 08, 2018 15:14
Location: Paris
GitHub: pyrollo
In-game: Naj

Re: pointed_thing entity name

by Pyrollo » Fri Dec 28, 2018 19:56

Players are not entities, you have to have two different parts of code for players and entities (yes, using :is_player() :) )
For players, you have to call :get_player_name()
Actually everything is in minetest dev wiki and lua_api.txt.
[ Display Modpack ] - [ Digiterms ] - [ Crater MG ] - [ LATE ]
 

User avatar
runs
Member
 
Posts: 176
Joined: Sat Oct 27, 2018 08:32
GitHub: runsy

Re: pointed_thing entity name

by runs » Fri Dec 28, 2018 21:16

Pyrollo wrote:Players are not entities, you have to have two different parts of code for players and entities (yes, using :is_player() :) )
For players, you have to call :get_player_name()
Actually everything is in minetest dev wiki and lua_api.txt.


Thanx!
 


Return to Modding Discussion



Who is online

Users browsing this forum: No registered users and 1 guest