From 1dacc0f41ad04a75e9fa3ca2bb6289aac57b68a7 Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Mon, 3 Jul 2023 18:22:44 +1000 Subject: [PATCH] Add client world.players --- source/game/scripting/StarWorldLuaBindings.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) 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(world)) { callbacks.registerCallbackWithSignature("clientWindow", bind(ClientWorldCallbacks::clientWindow, clientWorld)); + callbacks.registerCallback("players", [clientWorld]() { + List playerIds; + + clientWorld->forAllEntities([&](EntityPtr const& entity) { + if (entity->entityType() == EntityType::Player) + playerIds.emplace_back(entity->entityId()); + }); + + return playerIds; + }); } if (auto serverWorld = as(world)) {