lua-users home
lua-l archive

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


On Wed, Nov 26, 2008 at 04:40:48PM -0500, RJP Computing wrote:
> I am writing a Lua GUI script runner that takes a file written for the
> console and pipes the 'print' function to display it in the the GUI output.
> This works great, but now I want to take another function and overwrite it.
> This function is required (using "require()") in the file that is being
> loaded (using "loadfile()").
> 
> Is there a way to get this to happen?

Could you just preload the module by calling 'require' yourself
before 'loadfile'?  That would give you the chance to update whatever
table the module returns or globals it creates.  Lua's module caching
will prevent the module's initialization stuff being run again after
you've fiddled with it.

-- 

--- Geoff Richards -------------><-------------- http://ungwe.org/ ---
"I tried to fling my shadow at the moon,
 The while my blood leapt with a wordless song."  --  Theodore Roethke