core library
This commit is contained in:
parent
124986199e
commit
0140fb8e3e
@ -114,16 +114,17 @@ void lua::LuaState::remove(const std::string& name) {
|
||||
}
|
||||
|
||||
void lua::LuaState::createLibs() {
|
||||
openlib("pack", packlib, 0);
|
||||
openlib("world", worldlib, 0);
|
||||
openlib("player", playerlib, 0);
|
||||
openlib("inventory", inventorylib, 0);
|
||||
openlib("audio", audiolib, 0);
|
||||
openlib("block", blocklib, 0);
|
||||
openlib("item", itemlib, 0);
|
||||
openlib("time", timelib, 0);
|
||||
openlib("core", corelib, 0);
|
||||
openlib("file", filelib, 0);
|
||||
openlib("gui", guilib, 0);
|
||||
openlib("audio", audiolib, 0);
|
||||
openlib("inventory", inventorylib, 0);
|
||||
openlib("item", itemlib, 0);
|
||||
openlib("pack", packlib, 0);
|
||||
openlib("player", playerlib, 0);
|
||||
openlib("time", timelib, 0);
|
||||
openlib("world", worldlib, 0);
|
||||
|
||||
addfunc("print", lua_wrap_errors<l_print>);
|
||||
}
|
||||
|
||||
@ -5,17 +5,18 @@
|
||||
#include "lua_commons.h"
|
||||
|
||||
// Libraries
|
||||
extern const luaL_Reg packlib [];
|
||||
extern const luaL_Reg timelib [];
|
||||
extern const luaL_Reg filelib [];
|
||||
extern const luaL_Reg worldlib [];
|
||||
extern const luaL_Reg audiolib [];
|
||||
extern const luaL_Reg blocklib [];
|
||||
extern const luaL_Reg itemlib [];
|
||||
extern const luaL_Reg playerlib [];
|
||||
extern const luaL_Reg inventorylib [];
|
||||
extern const luaL_Reg corelib [];
|
||||
extern const luaL_Reg filelib [];
|
||||
extern const luaL_Reg guilib [];
|
||||
extern const luaL_Reg hudlib [];
|
||||
extern const luaL_Reg audiolib [];
|
||||
extern const luaL_Reg inventorylib [];
|
||||
extern const luaL_Reg itemlib [];
|
||||
extern const luaL_Reg packlib [];
|
||||
extern const luaL_Reg playerlib [];
|
||||
extern const luaL_Reg timelib [];
|
||||
extern const luaL_Reg worldlib [];
|
||||
|
||||
|
||||
// Lua Overrides
|
||||
|
||||
25
src/logic/scripting/lua/libcore.cpp
Normal file
25
src/logic/scripting/lua/libcore.cpp
Normal 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}
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user