From 4afe7914a4d4f59703d14f9ba8470ed87831ddcb Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Thu, 1 May 2025 20:13:47 +0530 Subject: Add stdlib and web.utils --- src/LuaRuntime.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/LuaRuntime.cpp') diff --git a/src/LuaRuntime.cpp b/src/LuaRuntime.cpp index b4c39a2..73555e0 100644 --- a/src/LuaRuntime.cpp +++ b/src/LuaRuntime.cpp @@ -48,11 +48,15 @@ void LuaRuntime::init_web_api() { luaL_newlib(state, internals_api); lua_setglobal(state, internals_global_name); + require_module("null-browser.api"); +} + +void LuaRuntime::require_module(const QString &module_name) { preserve_top(state, { lua_getglobal(state, "require"); - lua_pushstring(state, "null-browser.api"); + lua_pushstring(state, module_name.toStdString().c_str()); if (lua_pcall(state, 1, 0, 0) != LUA_OK) { - qCritical() << "Unable to load browser api" << lua_tostring(state, -1); + qCritical() << "Unable to require module" << module_name << ":" << lua_tostring(state, -1); } }); } -- cgit v1.3.1