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 ...
get luaentity name
- 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
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:
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
Check out my stuff! | Donations greatly appreciated! PayPal
Re: get luaentity name
thank u it works!
Who is online
Users browsing this forum: No registered users and 4 guests