lua-users home
lua-l archive

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


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 
 








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.