lua-users home
lua-l archive

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

Hi :)

I've never used luabind, but it seems like you'd want to pass the data
as parameters to a function rather than use globals.  Barring that,
couldn't you track the invocation parameters in a stack?

(My Lua is a bit rusty so forgive me if I mess up keywords and syntax)

For example, you could run functions before and after running the
process script that might do something like this:

function BeforeProcess()
  scriptRecursionDepth = scriptRecursionDepth + 1
  ParameterStack[ scriptRecursionDepth ] = { InputPath, InputFile }

function AfterProcess()
  ParameterStack[ scriptRecursionDepth ] = nil
  scriptRecursionDepth = scriptRecursionDepth - 1
  if scriptRecursionDepth > 0 then 
    InputPath, InputFile = ParameterStack[ scriptRecursionDepth ]
    InputPath = nil
    InputFile = nil

And of course make sure that scriptRecursionDepth is initialized to 0,
etc.  This is not the most efficient/clean way but I think it would work
and is fairly straightforward.


-----Original Message-----
[] On Behalf Of Martin Slater
Sent: Tuesday, June 28, 2005 5:32 PM
To: Lua list
Subject: Re: Setting the lua environment

Richard Ranft wrote:

>Is there some way to accomodate this from your script manager on the
>side?  If you use an object for each instance of the script in your
>you could keep what info you needed with each script object, and pass
>what the next object will need to it when it is instantiated.  I think
>would work and it would avoid stomping on the global environment.
>Just a thought... I don't have many of them.
Thanks for that one then;) Unfotuanetly isn't really possible, the whole

thing is based on dll's which bind there functions on initialisation and

its the script which manages everything from there, I could maybe keep a

global stack c side so every call of the convert function it overwrites 
and restores the globals on exit, in fact this may be a lot simpler than

trying to figure out the rather sparsely document lua_setfenv and 
accompanying code needed.