diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2025-06-03 09:32:41 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2025-06-03 09:32:41 +1000 |
commit | 72d55371d2d5bc2a14567c20a7c391a24c9f1837 (patch) | |
tree | ba4214a8f15b70596f45d02dfe899d9e09b51e67 /source/game/scripting/StarWorldLuaBindings.cpp | |
parent | d575ca382bc9803f4d8711a11043897449cf3146 (diff) |
add player.nametag, player.setNametag, world.entityNametag
Diffstat (limited to 'source/game/scripting/StarWorldLuaBindings.cpp')
-rw-r--r-- | source/game/scripting/StarWorldLuaBindings.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
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<Maybe<String>, EntityId>("entitySpecies", bind(WorldEntityCallbacks::entitySpecies, world, _1)); callbacks.registerCallbackWithSignature<Maybe<String>, EntityId>("entityGender", bind(WorldEntityCallbacks::entityGender, world, _1)); callbacks.registerCallbackWithSignature<Maybe<String>, EntityId>("entityName", bind(WorldEntityCallbacks::entityName, world, _1)); + callbacks.registerCallbackWithSignature<Maybe<Json>, EntityId>("entityNametag", bind(WorldEntityCallbacks::entityNametag, world, _1)); callbacks.registerCallbackWithSignature<Maybe<String>, EntityId, Maybe<String>>("entityDescription", bind(WorldEntityCallbacks::entityDescription, world, _1, _2)); callbacks.registerCallbackWithSignature<LuaNullTermWrapper<Maybe<List<Drawable>>>, EntityId, String>("entityPortrait", bind(WorldEntityCallbacks::entityPortrait, world, _1, _2)); callbacks.registerCallbackWithSignature<Maybe<String>, EntityId, String>("entityHandItem", bind(WorldEntityCallbacks::entityHandItem, world, _1, _2)); @@ -1451,6 +1452,21 @@ namespace LuaBindings { return {}; } + Maybe<Json> WorldEntityCallbacks::entityNametag(World* world, EntityId entityId) { + auto entity = world->entity(entityId); + + if (auto nametagEntity = as<NametagEntity>(entity)) { + return JsonObject{ + {"nametag", nametagEntity->nametag()}, + {"displayed", nametagEntity->displayNametag()}, + {"color", jsonFromColor(Color::rgb(nametagEntity->nametagColor()))}, + {"origin", jsonFromVec2F(nametagEntity->nametagOrigin())}, + }; + } + + return {}; + } + Maybe<String> WorldEntityCallbacks::entityDescription(World* world, EntityId entityId, Maybe<String> const& species) { if (auto entity = world->entity(entityId)) { if (auto inspectableEntity = as<InspectableEntity>(entity)) { |