Page 1 of 1

get luaentity name

PostPosted: Fri Apr 07, 2017 06:03
by juli
How can i get the name of an luaentity from pointed_thing?
For example if i click with a item on an fish, it sends the name of the fish as a chat message.

i know the method LuaEntitySAO.get_entity_name() but this is Deprecated ...

Re: get luaentity name

PostPosted: Fri Apr 07, 2017 06:21
by kaeza
You can get the "name" of an object with `object:get_luaentity().name`.

You can check if a pointed thing is for an object by checking its `type`, and then get the object with the `ref` field:

Code: Select all
if pointed_thing.type == "object" then
  local obj = pointed_thing.ref
  local name = obj:get_luaentity().name
  -- do something here
end

Re: get luaentity name

PostPosted: Fri Apr 07, 2017 06:25
by juli
thank u it works!