Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/lua/player.md6
-rw-r--r--source/game/StarPlayer.cpp16
-rw-r--r--source/game/StarPlayer.hpp2
-rw-r--r--source/game/scripting/StarPlayerLuaBindings.cpp2
4 files changed, 26 insertions, 0 deletions
diff --git a/doc/lua/player.md b/doc/lua/player.md
index fd8ebd4..f281bad 100644
--- a/doc/lua/player.md
+++ b/doc/lua/player.md
@@ -527,3 +527,9 @@ Returns uuid, type, and orbits for all system objects in the specified system;
#### `List<String>` player.collectables(`String` collectionName)
Returns a list of names of the collectables the player has unlocked in the specified collection.
+
+---
+
+#### `List<Json>` player.teamMembers()
+
+Returns an array, each entry being a table with `name`, `uuid`, `entity`, `healthPercentage` and `energyPercentage`
diff --git a/source/game/StarPlayer.cpp b/source/game/StarPlayer.cpp
index 8ee6d7a..15890bb 100644
--- a/source/game/StarPlayer.cpp
+++ b/source/game/StarPlayer.cpp
@@ -35,6 +35,8 @@
#include "StarInspectionTool.hpp"
#include "StarUtilityLuaBindings.hpp"
#include "StarCelestialLuaBindings.hpp"
+#include "StarUniverseClient.hpp"
+#include "StarTeamClient.hpp"
namespace Star {
@@ -2072,6 +2074,20 @@ Vec2F Player::nametagOrigin() const {
void Player::updateIdentity()
{ m_identityUpdated = true; m_humanoid->setIdentity(m_identity); }
+JsonArray Player::teamMembers() {
+ JsonArray jarray;
+ for (auto member : m_client->teamClient()->members()) {
+ jarray.push_back(JsonObject{
+ {"name", member.name},
+ {"uuid", member.uuid.hex()},
+ {"entity", member.entity},
+ {"healthPercentage", member.healthPercentage},
+ {"energyPercentage", member.energyPercentage}
+ });
+ }
+ return jarray;
+}
+
void Player::setBodyDirectives(String const& directives)
{ m_identity.bodyDirectives = directives; updateIdentity(); }
diff --git a/source/game/StarPlayer.hpp b/source/game/StarPlayer.hpp
index f6e32e0..fe97fce 100644
--- a/source/game/StarPlayer.hpp
+++ b/source/game/StarPlayer.hpp
@@ -316,6 +316,8 @@ public:
void updateIdentity();
+ JsonArray teamMembers();
+
void setBodyDirectives(String const& directives);
void setEmoteDirectives(String const& directives);
diff --git a/source/game/scripting/StarPlayerLuaBindings.cpp b/source/game/scripting/StarPlayerLuaBindings.cpp
index 7952f30..4343531 100644
--- a/source/game/scripting/StarPlayerLuaBindings.cpp
+++ b/source/game/scripting/StarPlayerLuaBindings.cpp
@@ -27,6 +27,8 @@ LuaCallbacks LuaBindings::makePlayerCallbacks(Player* player) {
}
});
+ callbacks.registerCallback("teamMembers", [player]() { return player->teamMembers(); });
+
callbacks.registerCallback( "humanoidIdentity", [player]() { return player->humanoid()->identity().toJson(); });
callbacks.registerCallback("setHumanoidIdentity", [player](Json const& id) { player->setIdentity(HumanoidIdentity(id)); });