From 72d55371d2d5bc2a14567c20a7c391a24c9f1837 Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Tue, 3 Jun 2025 09:32:41 +1000 Subject: add player.nametag, player.setNametag, world.entityNametag --- source/game/scripting/StarWorldLuaBindings.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'source/game/scripting/StarWorldLuaBindings.cpp') diff --git a/source/game/scripting/StarWorldLuaBindings.cpp b/source/game/scripting/StarWorldLuaBindings.cpp index 2d952ea..64d1f30 100644 --- a/source/game/scripting/StarWorldLuaBindings.cpp +++ b/source/game/scripting/StarWorldLuaBindings.cpp @@ -512,6 +512,7 @@ namespace LuaBindings { callbacks.registerCallbackWithSignature, EntityId>("entitySpecies", bind(WorldEntityCallbacks::entitySpecies, world, _1)); callbacks.registerCallbackWithSignature, EntityId>("entityGender", bind(WorldEntityCallbacks::entityGender, world, _1)); callbacks.registerCallbackWithSignature, EntityId>("entityName", bind(WorldEntityCallbacks::entityName, world, _1)); + callbacks.registerCallbackWithSignature, EntityId>("entityNametag", bind(WorldEntityCallbacks::entityNametag, world, _1)); callbacks.registerCallbackWithSignature, EntityId, Maybe>("entityDescription", bind(WorldEntityCallbacks::entityDescription, world, _1, _2)); callbacks.registerCallbackWithSignature>>, EntityId, String>("entityPortrait", bind(WorldEntityCallbacks::entityPortrait, world, _1, _2)); callbacks.registerCallbackWithSignature, EntityId, String>("entityHandItem", bind(WorldEntityCallbacks::entityHandItem, world, _1, _2)); @@ -1451,6 +1452,21 @@ namespace LuaBindings { return {}; } + Maybe WorldEntityCallbacks::entityNametag(World* world, EntityId entityId) { + auto entity = world->entity(entityId); + + if (auto nametagEntity = as(entity)) { + return JsonObject{ + {"nametag", nametagEntity->nametag()}, + {"displayed", nametagEntity->displayNametag()}, + {"color", jsonFromColor(Color::rgb(nametagEntity->nametagColor()))}, + {"origin", jsonFromVec2F(nametagEntity->nametagOrigin())}, + }; + } + + return {}; + } + Maybe WorldEntityCallbacks::entityDescription(World* world, EntityId entityId, Maybe const& species) { if (auto entity = world->entity(entityId)) { if (auto inspectableEntity = as(entity)) { -- cgit v1.2.3