Thread Tools Display Modes
10-23-12, 02:23 PM   #1
whoarrior
A Deviate Faerie Dragon
 
whoarrior's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2008
Posts: 14
if statement, where's my misconception? :(

Hey guys,

i'm looking at my code and don't see why it doesn't behave like i thought it should.

Code:
local buffList = {
    [1] = { id = "5171", name = "Slice and Dice" },
}

local function whoa_showBuff(id)
    for _,v in pairs(buffList) do
        print(v.id.."=="..id.."?")
        if (v.id == id) then
            print("yes")
            return true
        else
            print("no")
        end
    end
    return false
end
And the logging looks like...
Code:
5171==2823?
no
5171==5171?
no
What stupid mistake did i do?

Thanks in advance!
whoa
  Reply With Quote
10-23-12, 02:25 PM   #2
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,324
Is the value passed a string or a number? Remember, "5171" (string) does not equal 5171 (number).
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
10-23-12, 02:30 PM   #3
whoarrior
A Deviate Faerie Dragon
 
whoarrior's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2008
Posts: 14
number != string

That's it, thank you so much! I didn't see the wood for the trees!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » if statement, where's my misconception? :(


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off