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 }
end

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


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.

-Josh


-----Original Message-----
From: lua-bounces@bazar2.conectiva.com.br
[mailto:lua-bounces@bazar2.conectiva.com.br] 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
C++
>side?  If you use an object for each instance of the script in your
manager
>you could keep what info you needed with each script object, and pass
on
>what the next object will need to it when it is instantiated.  I think
this
>would work and it would avoid stomping on the global environment.
>
>Just a thought... I don't have many of them.
>
>Rich
>  
>
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.

Cheers
Martin