[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: individual globals for coroutines.
- From: David Morris-Oliveros <david@...>
- Date: Mon, 10 Oct 2005 10:52:13 +1000
Hi,
I'm on my next stage of integrating lua into our engine, and have come
to a point where it would be wise to ask for advice.
I want each coroutine to have their own individual global table. I know
that you can do this by creating a new table, filling it with whatever
you want, and doing a lua_setfenv().
Now, when I bind my code into lua, i create all sorts of tables and
cfunctions in the global table. I still want these new coroutines to be
able access my bound tables and cfunctions.
I think i have 2 or 3 options for doing this:
1) When i create a new coroutine, create a new table, and basically
duplicate all the entries that i want to carry into the new env from the
globals table, then pass that newly created and filled table as the new env.
2) When I create a new coroutine, create a table, and create an entry
called G or GG or whatever, that points to the original globals table,
and then change _all_ the scripts to use that instead:
entity = Entities.Create("Blah")
to:
entity = G.Entities.Create("Blah")
3) Dunno if this would work: Create a new coroutine, and a new table to
be the new env, and set the original globals as the metatable of this
new table. That way, when it goes to use something from the global
namespace, ie: entity = Entities.Create("Blah"), "Entities" won't be
found in he current globals, triggering lua to search for it in the
original globals... Does this even work?
Or how do people usually do it?
--
// David Morris-Oliveros
// Camera & Lua Coder
// Team Bondi
------------------------------------------------------------------------
Contact:
Team Bondi Pty Ltd
Level 2, 608 Harris Street
Ultimo, NSW 2007
Australia
Tel: +61 (0)2 8218 1500
Fax: +61 (0)2 8218 1507
Web: http://www.teambondi.com
------------------------------------------------------------------------
This email may contain confidential information. If you are not
the intended recipient, you may not copy or deliver this message to
anyone. In such case, you should destroy this message and kindly
notify the sender by reply email. Opinions, conclusions and other
information in this message that do not relate to the official business
of our firm shall be understood as neither given nor endorsed by it.
------------------------------------------------------------------------