lua-users home
lua-l archive

Re: Xavante / Compat-5.1: reloading a module?

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Tuesday 02 August 2005 2:26 pm, William Trenker wrote:
> What is the "proper" way to reload a module on the fly? I am running
> Xavante and have a custom handler that uses a module. I want to be
> able to change the module's source code and have the changes re-loaded
> automatically without stopping Xavante.
i think in your case it's easier to use loadfile() instead of require()
something like:
local lastT = 0
local lastFunc
function getScript (n)
 local attr = lfs.attributes (n)
 local t = attr.modification
 if t > lastT then
 lastFunc = loadfile (n)
 lastT = attr.modification
 end
 return lastFunc
end
then you just call getScript(), and it'll reload your module only if it has 
been modified.
-- 
Javier

Attachment: pgpHg4Lp4OwWT.pgp
Description: PGP signature


AltStyle によって変換されたページ (->オリジナル) /