summaryrefslogtreecommitdiffstats
path: root/src/lua.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lua.c')
-rw-r--r--src/lua.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/lua.c b/src/lua.c
index fd54bb5..d7f6259 100644
--- a/src/lua.c
+++ b/src/lua.c
@@ -295,7 +295,7 @@ LC_NUMBER2(curcol,curcol)
LC_NUMBER2(maxcols,maxcols)
LC_NUMBER2(maxrows,maxrows)
-static const luaL_reg sclib[] = {
+static const luaL_Reg sclib[] = {
{ "lgetnum", l_getnum },
{ "lsetnum", l_setnum },
{ "lsetform", l_setform },
@@ -312,6 +312,13 @@ static const luaL_reg sclib[] = {
{NULL,NULL}
};
+static int registerLuaFuncs(lua_State *L) {
+#if LUA_VERSION_NUM >= 502
+ luaL_newlib(L, sclib); /* Load SC specific LUA commands after init.lua exec*/
+#endif
+ return 1;
+}
+
/**
* \brief TODO Document doLuainit()
*
@@ -334,7 +341,13 @@ void doLuainit() {
if (lua_pcall(L, 0, 0, 0)) /* PRIMING RUN. FORGET THIS AND YOU'RE TOAST */
fprintf(stderr, "\nFATAL ERROR:\n Couldn't initialized Lua: %s\n\n", lua_tostring(L,-1));
}
+
+
+#if LUA_VERSION_NUM >= 502
+ luaL_requiref(L, "sc", registerLuaFuncs, 1); /* sc = require("sc") */
+#else
luaL_register(L, "sc", sclib); /* Load SC specific LUA commands after init.lua exec*/
+#endif
return;
}