Execute *.lua files that have lua requires for external lua files
knightswatch3 opened this issue · comments
practice.lua
local expr = require 'expr'
function internal(org)
print("Started the internal function",org+100);
return org+10
end
return internal
index.js
const fengari = require('fengari')
const lua = fengari.lua;
const lauxlib = fengari.lauxlib;
const lualib = fengari.lualib;
const L = lauxlib.luaL_newstate();
lualib.luaL_openlibs(L);
lauxlib.luaL_dofile(L, "./tql/practice.lua")
console.log(lua.lua_gettop(L))
lua.lua_pcall(L,1,1,1)
The above code doesn't return anything. Wondering why. But when I comment the expr require line in the lua file. Things work as expected. What are the ways to get this sorted out? I have a library of lua written already (huge) and would just love to import them and execute in the nodejs part of the project. Please help. TIA.
lauxlib.luaL_dofile(L, "./tql/front_end_validate.lua")
What does this return?
I've corrected my question above. The filename was supposed to be practice.lua. So just to make sure it's understood. The issue still persits.
So when the line local expr = require 'expr' is mentioned in the lua file I am executing via fengari, I do not get any ouput. The execution of the script stops. If I move the line local expr = require 'expr' after the print statement in the lua file the execution stops. No error messages or anything.
Also, my issue seems similar to this issue:
lauxlib.luaL_dofile(L, "./tql/front_end_validate.lua")
What does this return?
The response I get is only the number 1. And I know that's because of the dofile command pushing it onto the stack.
The response I get is only the number 1
from luaL_dofile
? that's LUA_YIELD
: you must be trying to yield from your file.