Piorun Posted February 9, 2012 Share Posted February 9, 2012 How to create Lua class and how to use it? Link to comment
Kernell Posted February 9, 2012 Share Posted February 9, 2012 Lua does not support classes by default. But you can make a pseudo-classes. If you want I can give his library to implement the classes. Link to comment
Kenix Posted February 9, 2012 Share Posted February 9, 2012 You can create pseudo-class with metatable. http://lua-users.org/wiki/LuaClassesWithMetatable Link to comment
Piorun Posted February 9, 2012 Author Share Posted February 9, 2012 Damn .. dont understand it. Any examples? Link to comment
Castillo Posted February 9, 2012 Share Posted February 9, 2012 As far as I know there are examples in that link. Link to comment
Kernell Posted February 9, 2012 Share Posted February 9, 2012 Class Lib: http://pastebin.com/RC1gN4Bs Class Vector3 for example: http://pastebin.com/WSgK0qFq Example: pos1 = Vector3( getElementPosition( element ) ); pos2 = Vector3( getElementPosition( element2 ) ); outputChatBox( "Distance between 'element' and 'element2' = " .. pos1:Distance( pos2 ) ); The Vector3 has operator overloading: op name example + Add v3 = v1 + v2 - Sub v3 = v1 - v2 * Mul v3 = v1 * v2 == Equality if v1 == v2 then ... end .. Concat outputDebugString( "Player pos: " .. vec ) Link to comment
Piorun Posted February 9, 2012 Author Share Posted February 9, 2012 K thanks. I know there are examples but it's more easier to uderstand when any user who is scripting try to explain it. Link to comment
YourMother Posted February 9, 2012 Share Posted February 9, 2012 http://github.com/pzduniak/openframe Link to comment
Kernell Posted February 9, 2012 Share Posted February 9, 2012 Piorun, It works just like in C++ Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now