🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Can you do this w/ lua?

Started by
0 comments, last by yodaman 20 years, 10 months ago
Hiya *I havent bothered yet to really learn lua so im not sure what exactly it can and cant do* In the engine im making right now I plan on interfacing it with lua. The engine however uses quite a few enums, now if you had a cpp function like so: void SetStyle(BlendStyle pStyle), you would simple set the param with a member of the particular enum structure, but now in lua you wouldn''t have access to the enums (or is there a way to expose them to lua?) or would I probably just have to make the function take in a string and then use a switch statement...ex:

void SetStyle(char* pStyle)
{
   switch(pStyle)
   {
   case ''transparent'':
        m_Blendstyle = BS_TRANSPARENT;
    break;
   etc...
}
and also, is there a way to make pointers in lua to hardcoded classes? lua file...CMesh *m_tree; m_tree->style = "transparent" etc. Thanx a lot in advance! Cheers!
www.jinx.com www.thebroken.org www.suprnova.org www.mozilla.org
Advertisement
For enums, just assign the values to lua variables, then you can use them just like in c.

The latter requires the use of lua tables; it will work, but you''ll have to register everything and encapsulate parameters.
Or you simple use one of the wrappers out there (i prefer luabind, it''s quite mighty; tolua would be an alternative too).

Regards,
Endurion

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

This topic is closed to new replies.

Advertisement