In the meantime a simple workaround would be a loadrequire.fh_lua Plugin from the Plugin Store that when run simply renames itself to loadrequire.lua. Then to provide the loadrequire() function any Plugin could use:
Code: Select all
local loadrequire = require("loadrequire").loadrequire
Code: Select all
--[[
@Module: loadrequire
@Author: Mike Tate
@Version: 1.0
@LastUpdated: 20 Oct 2013
@Description: loadrequire() function plugin & module.
@V1.0: Initial version.
]]
require "lfs"
require "luacom"
if not ... then
local plugins = fhGetContextInfo('CI_APP_DATA_FOLDER')..'\\Plugins\\'
local source = 'loadrequire.fh_lua'
local target = 'loadrequire.lua'
if lfs.attributes(plugins..source,'mode') == 'file' then
if lfs.attributes(plugins..target,'mode') == 'file' then
local res, err = os.remove (plugins..target)
if not res then print(err) end
end
local res, err = os.rename (plugins..source, plugins..target)
if not res then print(err) end
return
end
error("\n\nThis is a Library Module, and so it can not be executed on its own.")
end
local fh = {} -- Local environment table
package.seeall(fh) -- Enable all globals
module("...",package.seeall) -- Create matching module name
setfenv(1,fh) -- All public names are added to local fh table
function loadrequire(module,extended)
... { standard loadrequire function body goes here } ...
end -- function loadrequire
return fh
To catch module errors, other than simply a missing module file, the fragment:
Code: Select all
res = pcall(requiref,extended)
if not(res) then
{ load library modules }
endCode: Select all
local res, err = pcall(requiref,extended) -- was: res = pcall(requiref,extended)
if not(res) then
if err:match("module '"..extended:gsub("(%W)","%%%1").."' not found") then
{ load library modules }
else
fhMessageBox('Error from require("'..module..'") command:\n'..err)
return false
end
endCode: Select all
return {
['fh/encoder_v1.lua']=13728,
['fh/encoder_v2.lua']=16117,
['fh/general_v1.lua']=7750,
['fh/stringx_v1.lua']=2636
}Code: Select all
local modlist = loadstring(http.ResponseBody)
for x,y in pairs(modlist()) do
if type(x) == 'number' and type(y) == 'string' then
x = y -- revert to original numbered modlist
y = 0
end
if not(installmodule(module,x,y)) then
break
end
endCode: Select all
local attr = lfs.attributes(storein..filename)
if attr and attr.mode == 'file' and attr.size == size then return true end
-- Get file down and install it