[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Unable to access table using lua after creation of table in C
- From: "Dr Christopher S Kirk" <drcskirk@...>
- Date: Wed, 11 Mar 2009 12:43:25 +0000
Will you be kind enough to point me to examples for the treatment of
tables across the stack for the following case.
I have carefully followed the PIL work on pages 231-234 of 2nd edn PIL.
(Table manipulation).
I seek to create a table in lua and populate it with data, then access
it from 'C' and update (change) values and then to read and manipulate
in lua.
In this case I am creating a lua engine which calls 'C' functions.
I am able to correctly read values from the original lua table (when in
'C') and to manipulate them. I then wish to store the values (as
changed) back in the lua table for later manipulation in lua.
I have only found a lua_newtable capability to create a lua table (I can
use lua_getglobal to read an existing table but receive an 'Unknown
Error' when using that to develop a method to store values using
setfield. So being unable to update an existing table I created a new
table (whilst in 'C' using setglobal) [eg lua_setglobal(L,
"tablename2");] and I could then read it to check it whilst still in 'C'
using [lua_getglobal(L,tablename2");] but then on returning control to
lua I cannot open the new table tablename2 as it is reported as having a
'nil' value (non-existant maybe).
Will you be kind enough to point me to an area where I might resolve
these issues?
Overview:
Open a table and populate in lua
Modify some contents in C
Use a metatable modification to signal when the table has been changed
__newindex
Print out or report using lua after manipulation of incoming data
Object: to replace a callback in a C function with a lua callback-type
function which sends a 'C-structure' to a lua table
Very many thanks
Chris
--
Dr Christopher S Kirk
private email services: http://www.fastmail.fm