get luaentity name

Post Reply
juli
Member
Posts: 217
Joined: Sat Jun 11, 2016 10:31
GitHub: cpdef
In-game: juli

get luaentity name

by juli » Post

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 ...

User avatar
kaeza
Moderator
Posts: 2162
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza
Location: Montevideo, Uruguay
Contact:

Re: get luaentity name

by kaeza » Post

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
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal

juli
Member
Posts: 217
Joined: Sat Jun 11, 2016 10:31
GitHub: cpdef
In-game: juli

Re: get luaentity name

by juli » Post

thank u it works!

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests