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

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2023-07-03 18:22:44 +1000
committerKae <80987908+Novaenia@users.noreply.github.com>2023-07-03 18:22:44 +1000
commit1dacc0f41ad04a75e9fa3ca2bb6289aac57b68a7 (patch)
treed0992ef3fdff08bafb39a5b4b8bda7efe6514145
parent1742b04eec86a581707fcf622a8e91e7fddbd091 (diff)
Add client world.players
-rw-r--r--source/game/scripting/StarWorldLuaBindings.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/source/game/scripting/StarWorldLuaBindings.cpp b/source/game/scripting/StarWorldLuaBindings.cpp
index 9906eec..8d7d1bd 100644
--- a/source/game/scripting/StarWorldLuaBindings.cpp
+++ b/source/game/scripting/StarWorldLuaBindings.cpp
@@ -357,6 +357,16 @@ namespace LuaBindings {
if (auto clientWorld = as<WorldClient>(world)) {
callbacks.registerCallbackWithSignature<RectI>("clientWindow", bind(ClientWorldCallbacks::clientWindow, clientWorld));
+ callbacks.registerCallback("players", [clientWorld]() {
+ List<EntityId> playerIds;
+
+ clientWorld->forAllEntities([&](EntityPtr const& entity) {
+ if (entity->entityType() == EntityType::Player)
+ playerIds.emplace_back(entity->entityId());
+ });
+
+ return playerIds;
+ });
}
if (auto serverWorld = as<WorldServer>(world)) {