--[[ autoload.lua - support automatic package loading This is example of using Lua addon. This script scans and executes (using dofile) scripts in a path specified by variable "autoload" or preference "kmeleon.plugins.luamacros.autoload". example setting of user.js user_pref("kmeleon.plugins.luamacros.autoload", "lua\\autoload\\"); Note: This script uses LuaFileSystem Addon (lfs.dll). You have to install into "package.cpath" (default is same as PREFPATH). http://luaforge.net/projects/luafilesystem ]] require "lfs" local pref = "kmeleon.plugins.luamacros.autoload" if not autoload or type(autoload) ~= "string" then autoload = BROWSERPATH..km.getpref(TYPE_STRING, pref) end if autoload then local a, i, f for i in lfs.dir(autoload) do f = autoload .. i a = lfs.attributes(f) if a and a.mode == "file" then dofile(f) end end end