This commit is contained in:
Kae 2024-03-22 20:59:12 +11:00
commit 4d84152609
3 changed files with 7 additions and 1 deletions

View File

@ -111,7 +111,7 @@ Assets::Assets(Settings settings, StringList assetSources) {
auto luaEngine = LuaEngine::create(); auto luaEngine = LuaEngine::create();
m_luaEngine = luaEngine; m_luaEngine = luaEngine;
auto pushGlobalContext = [&luaEngine](String const& name, LuaCallbacks & callbacks) { auto pushGlobalContext = [&luaEngine](String const& name, LuaCallbacks && callbacks) {
auto table = luaEngine->createTable(); auto table = luaEngine->createTable();
for (auto const& p : callbacks.callbacks()) for (auto const& p : callbacks.callbacks())
table.set(p.first, luaEngine->createWrappedFunction(p.second)); table.set(p.first, luaEngine->createWrappedFunction(p.second));

View File

@ -375,6 +375,7 @@ namespace LuaBindings {
callbacks.registerCallback("isClient", []() { return false; }); callbacks.registerCallback("isClient", []() { return false; });
callbacks.registerCallback("isServer", []() { return true; }); callbacks.registerCallback("isServer", []() { return true; });
callbacks.registerCallbackWithSignature<String>("id", bind(ServerWorldCallbacks::id, serverWorld));
callbacks.registerCallbackWithSignature<bool, EntityId, bool>("breakObject", bind(ServerWorldCallbacks::breakObject, serverWorld, _1, _2)); callbacks.registerCallbackWithSignature<bool, EntityId, bool>("breakObject", bind(ServerWorldCallbacks::breakObject, serverWorld, _1, _2));
callbacks.registerCallbackWithSignature<bool, RectF>("isVisibleToPlayer", bind(ServerWorldCallbacks::isVisibleToPlayer, serverWorld, _1)); callbacks.registerCallbackWithSignature<bool, RectF>("isVisibleToPlayer", bind(ServerWorldCallbacks::isVisibleToPlayer, serverWorld, _1));
callbacks.registerCallbackWithSignature<bool, RectF>("loadRegion", bind(ServerWorldCallbacks::loadRegion, serverWorld, _1)); callbacks.registerCallbackWithSignature<bool, RectF>("loadRegion", bind(ServerWorldCallbacks::loadRegion, serverWorld, _1));
@ -1086,6 +1087,10 @@ namespace LuaBindings {
return world->clientWindow(); return world->clientWindow();
} }
String ServerWorldCallbacks::id(WorldServer* world) {
return world->worldId();
}
bool ServerWorldCallbacks::breakObject(WorldServer* world, EntityId arg1, bool arg2) { bool ServerWorldCallbacks::breakObject(WorldServer* world, EntityId arg1, bool arg2) {
if (auto entity = world->get<Object>(arg1)) { if (auto entity = world->get<Object>(arg1)) {
bool smash = arg2; bool smash = arg2;

View File

@ -73,6 +73,7 @@ namespace LuaBindings {
} }
namespace ServerWorldCallbacks { namespace ServerWorldCallbacks {
String id(WorldServer* world);
bool breakObject(WorldServer* world, EntityId arg1, bool arg2); bool breakObject(WorldServer* world, EntityId arg1, bool arg2);
bool isVisibleToPlayer(WorldServer* world, RectF const& arg1); bool isVisibleToPlayer(WorldServer* world, RectF const& arg1);
bool loadRegion(WorldServer* world, RectF const& arg1); bool loadRegion(WorldServer* world, RectF const& arg1);