lua-users home
lua-l archive

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


Search the list archives for "sandboxing".
There are also a couple of Wiki articles.

The short (and incomplete) answer is that you want to use setfenv to assign
each script its own set of globals.  The long answer (not provided here)
details what items you will need to copy from the original globals table to
the per script tables.


-----Original Message-----
From: lua-bounces@bazar2.conectiva.com.br
[mailto:lua-bounces@bazar2.conectiva.com.br]On Behalf Of Enno Rehling
Sent: Tuesday, July 13, 2004 6:20 AM
To: lua@bazar2.conectiva.com.br
Subject: more modular scripts


I am loading a bunch of user-scripts from a list of files, and I'm
wondering how to keep them from messing with each other. If I have two
scripts defining the same identifier in the globals table (like two
functions called action(), or two variables called size), One of those
scripts is going to puke.

I suppose there's no easy way to do this, other than run each in its own
lua_state, but I'm just going to ignore my intuition and ask anyway: How
do others solve this?

Enno.
--
"Generally you don't see that kind of behavior in a major appliance." --
Dr. Peter Venkman