Jump to content

  • Log In with Google      Sign In   
  • Create Account


Exposing class in Lua without exposing classes?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Joviex   Members   -  Reputation: 247

Like
Likes
Like

Posted 02 April 2003 - 06:46 PM

Pondering... I want to expose some class objects to LUA without exposing the constructor/destructors and most likely some internal support fuctions. Something along the lines of exposing say an APP object to initialize the screen and whatnot, but I don''t want LUA to be able to create the APP object itself. That is for the engine. Is it possible to do this function by function in a LUA table? I have done whole classes before, and made nice wrappers for an embedded interpreter in an engine, but I started thinking that the script language should only have access to certain things down the line. Previously I would just chuck the whole class exposed to LUA and just be smart in scripting. Seeing as it was me doing the scripting, this was a no brainer. But now what happens when I pull over people to write scripts. Some jamoke may actually try to init another APP or another Texturemanager class just cause they think they know what is going on. Any one have expereience with this? Docs are pretty tight on LUA and class exposure. Thanks in advance. "Five passengers set sail that day, for a three hour tour, a three hour tour...."

Sponsor:

#2 Tylon   Members   -  Reputation: 181

Like
Likes
Like

Posted 03 April 2003 - 04:23 AM

(I am assuming you are using ToLUA)

There are several ways to do this, but I guess the best method would be to expose a function getApp() to LUA, which returns the only instance of the app. Then to prevent people from creating their own app classes, just remove the C++ code ToLUA generates for '':new()''.

So then in your LUA code you can do:

theApp = getApp();
theApp.doThingsToYourApp();

or

getApp().doThingsToYourApp();

Hope this helps.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS