LuaRuntime constructor

LuaRuntime()

Implementation

LuaRuntime() {
  // Load the Lua shared library
  final dylib = _openDynamicLibrary();
  lua = LuaBindings(dylib);

  L = lua.luaL_newstate();
  lua.luaL_openlibs(L);

  // register custom print() as lua print() outsput to stdout which flutter doesn't capture
  final printFunc = Pointer.fromFunction<Int32 Function(Pointer<lua_State>)>(
    luaPrint,
    0,
  );

  registerFunction("print", printFunc);
}