Player teammembers

This commit is contained in:
Degranon 2024-10-19 21:10:39 +05:00
parent aac3e53941
commit f270c3f168
4 changed files with 26 additions and 0 deletions

View File

@ -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`

View File

@ -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(); }

View File

@ -316,6 +316,8 @@ public:
void updateIdentity();
JsonArray teamMembers();
void setBodyDirectives(String const& directives);
void setEmoteDirectives(String const& directives);

View File

@ -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)); });