lua-users home
lua-l archive

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


On 18 September 2011 18:06, Jason White
<whitewaterssoftwareinfo@gmail.com> wrote:
> Hello Lua mailing list, I am trying to add scripting support to a game
> I'm writing. If I have 2 functions `init` and `update` in a script
> plus a few global variables. I want to run multiple instances of this
> script within the game. How could I do that without name space
> conflicts ? I have a few ideas about doing this* but I'd like advise
> on what the "best" way would be to do this without making the scripter
> jump through too many hoops since I'm fairly new to Lua.

I use loadfile and setfenv instead of require for loading the script
so I can load multiple copies that have different 'global' tables.
It's a bit finicky to get the environment just right though, if you're
new to lua.

    henk