Use as3 objects created outside lua script in lua script

44 views
Skip to first unread message

retrogamer4ever

unread,
Oct 28, 2011, 1:15:55 AM10/28/11
to lua-alchemy-dev
Apologies if this has already been asked, but I couldn't find an
answer... I can see you can create as3 objects in lua scripts and even
access static properties of as3 objects. But lets say I create an
instance of a particular as3 object in an as3 script first, then load
up a lua script... Is there any way for me to access that existing as3
object in the newly loaded lua script?

Thanks!

Alexander Gladysh

unread,
Oct 28, 2011, 1:36:37 PM10/28/11
to lua-alc...@googlegroups.com
Hi!

Thanks for your interest to the LuaAlchemy!

Just expose it to Lua state as a global variable via setGlobal().

HTH,
Alexander.

Jhon Vilkovich

unread,
Oct 31, 2011, 5:57:02 PM10/31/11
to lua-alchemy-dev
Hi,
I'm creating simple class in AS3, like
public class MyModel {
public var _value1:int;
public var _value2:int;
}

then I create instance and expose it to Lua, like
lua = new LuaAlchemy("builtin://");
lua.setGlobal("model", mymodel);

the problem is that when I do type(model._value1) in lua I get
'table'.
Is this a correct behaviour? I expeced a 'number' here.
Thanks.


On 28 окт, 13:36, Alexander Gladysh <aglad...@gmail.com> wrote:
> Hi!
>
> Thanks for your interest to the LuaAlchemy!
>
> On Fri, Oct 28, 2011 at 09:15, retrogamer4ever
>

Alexander Gladysh

unread,
Oct 31, 2011, 6:08:45 PM10/31/11
to lua-alc...@googlegroups.com
Hi!

On Tue, Nov 1, 2011 at 01:57, Jhon Vilkovich <myfakee...@gmail.com> wrote:

Thank you for your interest in Lua Alchemy!

> I'm creating simple class in AS3, like
> public class MyModel {
>    public var _value1:int;
>    public var _value2:int;
> }
>
> then I create instance and expose it to Lua, like
> lua = new LuaAlchemy("builtin://");
> lua.setGlobal("model", mymodel);
>
> the problem is that when I do type(model._value1) in lua I get
> 'table'.
> Is this a correct behaviour? I expeced a 'number' here.

Yes, it is correct. It still a boxed AS3 value. To convert it to Lua
value, use as3.tolua(), or enable sugar autoconversion feature:

https://github.com/lua-alchemy/lua-alchemy/blob/312965c1f0ac3c665c4fdbe1f1b6860f5077cd0e/HISTORY#L20

Alexander.

Reply all
Reply to author
Forward
0 new messages