[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Lua 5.2 creating globals with userdata (retry)
- From: James Norton <jamesnorton@...>
- Date: Tue, 10 Apr 2012 16:58:47 -0400
I asked this earlier with no response, so I'm thinking my original question was too verbose. So let me ask more generally: can anyone provide an example of how to create global userdata objects in C code that are accessible from Lua 5.2 scripts? I am able to bind my Objective C objects to Lua just fine and can instantiate them from a Lua script, but when I try to instantiate one as a global in C code (ala lua_setglobal) I cannot access it in a Lua script. Every attempt to do so results in the following error:
attempt to index global 'x' (a userdata value)
Where 'x' is the global variable created in my C routine.
In other words,
y = myLibrary.newObject()
y:doSomething()
works fine,
but
some_global_variable:doSomething()
fails (where some_global_variable is the global variable instantiated directly in a C routine using lua_setglobal).
So, can anyone tell me how this is done?
Thans,
James