MCPcopy Create free account
hub / github.com/MihailRis/voxelcore / initialize

Method initialize

src/logic/scripting/lua/lua_engine.cpp:62–104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60}
61
62void lua::initialize() {
63 logger.info() << LUA_VERSION;
64 logger.info() << LUAJIT_VERSION;
65
66 auto L = luaL_newstate();
67 if (L == nullptr) {
68 throw luaerror("could not to initialize Lua");
69 }
70 main_thread = L;
71 // Allowed standard libraries
72 pop(L, luaopen_base(L));
73 pop(L, luaopen_math(L));
74 pop(L, luaopen_string(L));
75 pop(L, luaopen_table(L));
76 pop(L, luaopen_debug(L));
77 pop(L, luaopen_jit(L));
78 pop(L, luaopen_bit(L));
79 pop(L, luaopen_os(L));
80 const char* removed_os[] {
81 "execute",
82 "exit",
83 "remove",
84 "rename",
85 "setlocale",
86 "tmpname",
87 nullptr
88 };
89 remove_lib_funcs(L, "os", removed_os);
90 create_libs(L);
91
92 pushglobals(L);
93 setglobal(L, env_name(0));
94
95 createtable(L, 0, 0);
96 setglobal(L, LAMBDAS_TABLE);
97
98 createtable(L, 0, 0);
99 setglobal(L, CHUNKS_TABLE);
100
101 initialize_libs_extends(L);
102
103 newusertype<Bytearray, Bytearray::createMetatable>(L, "bytearray");
104}
105
106void lua::finalize() {
107 lua_close(main_thread);

Callers

nothing calls this directly

Calls 9

luaerrorClass · 0.85
popFunction · 0.85
remove_lib_funcsFunction · 0.85
create_libsFunction · 0.85
pushglobalsFunction · 0.85
setglobalFunction · 0.85
createtableFunction · 0.85
initialize_libs_extendsFunction · 0.85
infoMethod · 0.80

Tested by

no test coverage detected