[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: Problem(?) with luaL_register
- From: "Tom Miles" <Tom@...>
- Date: Tue, 2 Oct 2007 13:53:35 +0100
>
> Tom Miles wrote:
> > This is another, "Am I going mad" type question, I'm kind
> of going on
> > what I think might be happening.
> >
> > A have several threads created with lua_newthread all
> running in their
> > own sandbox, but having access to their parents globals
> table (as per
> > all my other posts).
> >
> > In some states I register a load of functions with
> luaL_register which
> > all works fine the first time they are registered, but if I destroy
> > the state (I must admit, I don't clear up the functions), then
> > recreate it and try and re-register the functions, the global table
> > containing my functions isn't created. The only reason for
> this I can
> > determine is that when the functions are registered the
> second time,
> > the table already exists in packages.loaded, and seemingly
> this means
> > that it assumes the global exists as well. Is this the
> case, and if
> > so is there an easy fix? (At the moment I'm using lua_newtable(L);
> > luaL_register(L, NULL, funcs); lua_setfield(L, LUA_GLOBALSINDEX,
> > "MyFuncs"); to make sure that a global variable always
> exists, but why
> > use 3 lines of code, when
> > 1 should do ;) )
> >
> > Tom
> >
> >
> Have you tried setting package.loaded = nil from inside the thread?
>
I didn't really want to start playing around with the values stored in
"package". I'm aware that there are quite a few solutions to the
problem, one is to do as i did, another is to reset the values in
package as you suggest, but that doesn't get around the fact that the
luaL_register function doesn't always seem to do what it says on the
tin.
DISCLAIMER
This email is sent by The Creative Assembly Limited company No. 03425917, registered in England &Wales registered office 27 Great West Road, Middlesex, TW8 9BW, England. The contents of this e-mail and any attachments are confidential to the intended recipient and may also be legally privileged. Unless you are the named addressee (or authorised to receive for the addressee) of this email you may not copy, disclose or distribute it to anyone else. If you have received this email in error, please notify us immediately by e-mail on postmaster@creative-assembly.co.uk and then delete the email and any copies. The Creative Assembly Limited have made all reasonable efforts to ensure that this e-mail and any attached documents or software are free from software viruses, but it is the recipient's responsibility to confirm this.