luaopen_luaplug
Some libraries (e.g. rings
) can create additional lua_State
instances from Lua scripts. To initialize those instances with libraries included in LuaFAR (far
, bit64
, win
, unicode
), call luaopen_luaplug()
passing it the lua_State*
to be initialized.
This function is also accessible from Lua as the global variable _luaplug
.
It is NOT intended to be called from the running lua_State
but rather to be passed
to another lua_State
for its initialization.
Alternatively, this function can be loaded via package.loadlib
as in the following example.
Example:
local rings = require "rings"
local r1 = rings.new()
r1:dostring([[
local modname = ...
assert(package.loadlib(modname, "luaopen_luaplug"))()
far.Message ("Hello world", "Called from a ring")
]], far.PluginStartupInfo().ModuleName)
Note: After replacing the standard Lua 5.1 DLL with one from LuaJIT 2.0, this example has stopped working. The issue is investigated.