drk Posted March 24, 2012 Share Posted March 24, 2012 Hi. I need help with "find a string in the table". Here the code: -- Anims by Ezz Anim = { } Anim.__index = Anim local validTypes = { pulseOut = true, fadeIn = true, fadeOut = true, move = true, moveResize = true } function Anim:Create ( aElem, aType, aTable ) if ( validTypes [ aType ] ) then outputChatBox ( "Passed statement" ) end end If I use "if ( validTypes [ aType ] ) then" and I put "myAnim = Anim:Create ( myElem, pulseOut, { } )" or other thing in pulseOut it doesn't output nothing. If I put "if ( not validTypes [ aType ] ) then" when I put something who isn't in the table it output anyway. Any help? Link to comment
Aibo Posted March 24, 2012 Share Posted March 24, 2012 Anim:Create ( myElem, pulseOut, { } ) — pulseOut here is not a string, it's a variable, probably nil. if you're still making this kind of errors, perhaps it's not the time to dive into OOP and classes. Link to comment
Kenix Posted March 24, 2012 Share Posted March 24, 2012 You need use metatables for create something like oop. http://lua-users.org/wiki/ObjectOrientationTutorial Link to comment
drk Posted March 24, 2012 Author Share Posted March 24, 2012 Oh thanks! I read about setmetatable and I put it to work Tnx Kenix 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