lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Thanks for your help Adam. I finally got it working:

x = Channel.INVERSE

(without the enum name)


Date: Thu, 28 Jun 2012 08:34:25 -0500
From: Coda Highland <chighland@gmail.com>
Subject: Re: C++ internal class structs in toLua++
To: Lua mailing list <lua-l@lists.lua.org>
Message-ID:
       <CAFE_sBFOZn+EQsf6hWfgK5hShyASv9VxuTRbNcv9MPeDYFR4XQ@mail.gmail.com>
Content-Type: text/plain; charset=windows-1252

> How can I use the enum values in a lua script? I’ve tried something like
>
>
> x = Channel:ChannelDirection:
INVERSE
>
>
> but I get the following error: “function arguments expected near ':'”

The error message should be a clue: The : operator is used for member
function calls. Use the . operator to access member variables. (I'm
using C++-speak for your sake; they're not called "member functions"
or "member variables" in Lua but I know you'll understand me.)

/s/ Adam



2012/6/28 Alberto Salguero <agsalguero@gmail.com>

Hi. I’m using toLua++ to make my c++ game engine accessible from lua scripts. All is working as expected but I’m wondering if there is any way to access internal structures of c++ classes (structs, enums…) from lua. The problem is that I don’t know how to specify the scope of those structures in lua scripts. Given the following class in c++ (which is parsed correctly by toLua++):


class Channel

{

      enum ChannelDirection

      {

            INVERSE = -1, DIRECT = 1

      };

     

      ...

};


How can I use the enum values in a lua script? I’ve tried something like


x = Channel:ChannelDirection:INVERSE


but I get the following error: “function arguments expected near ':'”


Thanks in advance,

Alberto