Jump to content

table find


drk

Recommended Posts

Posted

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?

Posted

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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...