Merge pull request #47 from ErodeesFleurs/useful

Fix compilation error and add the 'world.id' function
This commit is contained in:
Kae 2024-03-22 20:58:19 +11:00 committed by GitHub
commit a08fe284d3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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);