scripting.h fix + input library

This commit is contained in:
MihailRis
2024-05-05 00:28:30 +03:00
parent f9dd865bee
commit f02edcf15a
12 changed files with 121 additions and 34 deletions
+13 -1
View File
@@ -127,13 +127,14 @@ void lua::LuaState::createLibs() {
openlib("core", corelib, 0);
openlib("file", filelib, 0);
openlib("gui", guilib, 0);
openlib("input", inputlib, 0);
openlib("inventory", inventorylib, 0);
openlib("item", itemlib, 0);
openlib("json", jsonlib, 0);
openlib("pack", packlib, 0);
openlib("player", playerlib, 0);
openlib("time", timelib, 0);
openlib("world", worldlib, 0);
openlib("json", jsonlib, 0);
addfunc("print", lua_wrap_errors<l_print>);
}
@@ -426,6 +427,17 @@ void lua::LuaState::removeEnvironment(int id) {
logger.debug() << "removed environment " << envName(id);
}
bool lua::LuaState::emit_event(const std::string &name, std::function<int(lua::LuaState *)> args) {
getglobal("events");
getfield("emit");
pushstring(name);
callNoThrow(args(this) + 1);
bool result = toboolean(-1);
pop(2);
return result;
}
void lua::LuaState::dumpStack() {
int top = gettop();
for (int i = 1; i <= top; i++) {