lua-users home
lua-l archive

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


> I would like to be able to change the following lua function at run time:
> 
> function new_foo()
>     local foo_update = function()
>     -- do something
>     end
>     
>     return { foo_update = foo_update }
> end
> 
> foo.foo_update() -- foo was created during initialization 
> 
> Is there any way to change foo_update during run time? If not, then is there another way to create objects which allows me to change them at run time?

Unless I'm missing something, you can just do
	foo.foo_update = function () <do something else here> end