[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Some newb questions
- From: "David Holz" <davidh@...>
- Date: Mon, 24 Mar 2003 20:08:33 -0800
From: "Roger D. Vargas" <rogerdv@softhome.net>
> These are a very basic questions:
> I know how to push values to lua scripts using pushstring/setglobal, now,
how
> can i push a var from my c program and modify its value? And an struct (or
> c++ class)?
> Im using Lua 4.0.1, the procedure has changed for 5.0?
I'm new to Lua as well, but what I'm thinking would work to have Lua change
C/C++ variables is to give Lua a userdata object with accessor methods. So
if you've got
struct
{
int value;
} bob;
the Lua would get a userdata 'bob', with "getValue" and "setValue" methods
defined. These methods would be C functions which would update "value"
given the local of bob from the userdata void pointer.
There's also a couple of tools for taking header files and automagically
generating Lua glue logic to access classes from both methods. I haven't
seen how they work internally yet, and they're not for v5, but they're
probably worth a look.