[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Advice on using Lua for game scripting
- From: Henk Boom <henk@...>
- Date: Tue, 20 Sep 2011 22:00:25 -0400
On 18 September 2011 18:06, Jason White
> 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.