core library

This commit is contained in:
MihailRis
2024-03-20 22:19:24 +03:00
parent 124986199e
commit 0140fb8e3e
3 changed files with 42 additions and 15 deletions
+25
View File
@@ -0,0 +1,25 @@
#include "lua_commons.h"
#include "api_lua.h"
#include "../../../engine.h"
#include "../../../files/engine_paths.h"
#include "../scripting.h"
#include <vector>
static int l_get_worlds_list(lua_State* L) {
auto paths = scripting::engine->getPaths();
auto worlds = paths->scanForWorlds();
lua_createtable(L, worlds.size(), 0);
for (size_t i = 0; i < worlds.size(); i++) {
lua_pushstring(L, worlds[i].filename().u8string().c_str());
lua_rawseti(L, -2, i + 1);
}
return 1;
}
const luaL_Reg corelib [] = {
{"get_worlds_list", lua_wrap_errors<l_get_worlds_list>},
{NULL, NULL}
};