Help comparison tables - Page 2 - WoWInterface
08-07-17, 07:58 AM   #21
Mortimerlol
A Cliff Giant
Join Date: Jul 2017
Posts: 71
 Originally Posted by Kakjens pas06, both for loops are strange. Mortimerlol, make Paco, Anabel and Francisco have the same number of kills, and test what happens.
Only print one name if have same kills

08-07-17, 11:23 AM   #22
Banknorris
A Chromatic Dragonspawn

Join Date: Oct 2014
Posts: 153
 Originally Posted by Mortimerlol Only print one name if have same kills
Weird, I just tested my code by setting 10 kills for Paco, Anabel and Francisco and it showed the three names corretly.

My guess is that you did something wrong in the adaptation.
__________________
"In this world nothing can be said to be certain, except that fractional reserve banking is a Ponzi scheme and that you won't believe it." - Mandrill

Last edited by Banknorris : 08-07-17 at 11:40 AM.

08-07-17, 12:06 PM   #23
Mortimerlol
A Cliff Giant
Join Date: Jul 2017
Posts: 71
I go to check then, sry.

08-07-17, 12:16 PM   #24
Mortimerlol
A Cliff Giant
Join Date: Jul 2017
Posts: 71
no good values, i dont understand
Lua Code:
`table.sort(numbers)for i=#numbers,1,-1 do    table.sort(names[numbers[i]])    for j=1,#names[numbers[i]] do        print(numbers[1],names[numbers[1]][j])        print(numbers[2],names[numbers[2]][j])    endend`

08-07-17, 12:26 PM   #25
Mortimerlol
A Cliff Giant
Join Date: Jul 2017
Posts: 71
Your code woks but I dont understand why I can't print line per line, as for example:

Lua Code:
`print("TOP 1: "..numbers[1], names[numbers[1]][1])        print("TOP 2: "..numbers[2], names[numbers[2]][2])        print("TOP 3: "..numbers[3], names[numbers[3]][3])`

I dont see that I do wrong.

08-07-17, 12:46 PM   #26
Kakjens
A Cliff Giant
Join Date: Apr 2017
Posts: 75
That's because sorted table has different structure - there's an extra dimension.
Code:
```local which = 0
table.sort(numbers)
for i=#numbers,1,-1 do
table.sort(names[numbers[i]])
for j=1,#names[numbers[i]] do
which = which +1
print("TOP",which,": "..numbers[i], names[numbers[i]][j])
end
end```
Figure yourself how to stop printing.

Last edited by Kakjens : 08-07-17 at 12:48 PM. Reason: tabs are converted into *

08-07-17, 01:17 PM   #27
Mortimerlol
A Cliff Giant
Join Date: Jul 2017
Posts: 71
yes but, i need line per line but with 1, 2, 3, 4:

Lua Code:
`Gui.func1frame.htopkills2:AddMessage("BANGS", 1, .8, 0, 1)        if numbers[1] then            Gui.func1frame.htopkills2:AddMessage(numbers[1], 0, .8, 0, 1)        else            Gui.func1frame.htopkills2:AddMessage("0", 0, .8, 0, 1)        end                if numbers[2] then            Gui.func1frame.htopkills2:AddMessage(numbers[2], 0, .8, 0, 1)        else            Gui.func1frame.htopkills2:AddMessage("0", 0, .8, 0, 1)        end                        if numbers[3] then            Gui.func1frame.htopkills2:AddMessage(numbers[3], 0, .8, 0, 1)        else            Gui.func1frame.htopkills2:AddMessage("0", 0, .8, 0, 1)        end--......        if names[numbers[1]][j] then            Gui.func1frame.htopkills4:AddMessage(names[numbers[1]][j], .9, .9, .9, 1)        else            Gui.func1frame.htopkills4:AddMessage("0", .9, .9, .9, 1)        end                if names[numbers[2]][j] then            Gui.func1frame.htopkills4:AddMessage(names[numbers[2]][j], .7, .7, .7, 1)        else            Gui.func1frame.htopkills4:AddMessage("0", .7, .7, .7, 1)        end        if names[numbers[3]][j] then            Gui.func1frame.htopkills4:AddMessage(names[numbers[3]][j], .6, .6, .6, 1)        else            Gui.func1frame.htopkills4:AddMessage("0", .6, .6, .6, 1)        end`

08-07-17, 01:19 PM   #28
Mortimerlol
A Cliff Giant
Join Date: Jul 2017
Posts: 71
I only need can do:

Lua Code:
`print("TOP 1: "..numbers[1111111], names[numbers[1111111]][11111111])       -----blablabla        print("TOP 2: "..numbers[22222], names[numbers[2222]][222222])`

08-07-17, 01:24 PM   #29
Mortimerlol
A Cliff Giant
Join Date: Jul 2017
Posts: 71
Yeah, now works as like/need. THANKS !

Lua Code:
`if which == 1 then print("TOP 1"..numbers[i], names[numbers[i]][j]) end        if which == 2 then print("TOP 2"..numbers[i], names[numbers[i]][j]) end        if which == 3 then print("TOP 3"..numbers[i], names[numbers[i]][j]) end        if which == 4 then print("TOP 4"..numbers[i], names[numbers[i]][j]) end`

08-07-17, 01:39 PM   #30
Mortimerlol
A Cliff Giant
Join Date: Jul 2017
Posts: 71
no, no works, im crazy with it

08-07-17, 01:58 PM   #31
Kakjens
A Cliff Giant
Join Date: Apr 2017
Posts: 75
 Originally Posted by Mortimerlol no, no works, im crazy with it
Pasting more code to see the context would help.

08-07-17, 02:04 PM   #32
Mortimerlol
A Cliff Giant
Join Date: Jul 2017
Posts: 71
Thanks...

Lua Code:
`function hTops()    local names = {}    local numbers = {}         for char_name,number_of_kills in pairs(BangKills) do        if BangHateds[char_name] then            if not names[number_of_kills] then                numbers[#numbers+1] = number_of_kills                names[number_of_kills] = {char_name}            else                names[number_of_kills][#names[number_of_kills]+1] = char_name            end        end    end table.sort(numbers, function(a,b)    return b < aend) for i=1,1, -1 dofor j=1,1 do     --foreach(numbers, print)Gui.func1frame.htopkills1 = CreateFrame("MessageFrame", nil, Gui.func1frame)Gui.func1frame.htopkills1:SetSize(50,100)Gui.func1frame.htopkills1:SetPoint("TOP", -110, 40)Gui.func1frame.htopkills1:SetFont("Fonts\\FRIZQT__.ttf", 12, "THINOUTLINE")Gui.func1frame.htopkills1:SetFading(false)Gui.func1frame.htopkills1:SetSpacing(0)Gui.func1frame.htopkills1:SetJustifyH("CENTER")Gui.func1frame.htopkills1:AddMessage("TOP ", 1, .8, 0, 1)Gui.func1frame.htopkills1:AddMessage("#1", 1, .7, .05, 1)Gui.func1frame.htopkills1:AddMessage("#2", .65, .65, .65, 1)Gui.func1frame.htopkills1:AddMessage("#3", .6, .35, 0, 1)--Gui.func1frame.htopkills2 = CreateFrame("MessageFrame", nil, Gui.func1frame)Gui.func1frame.htopkills2:SetSize(50,100)Gui.func1frame.htopkills2:SetPoint("TOP", -60, 40)Gui.func1frame.htopkills2:SetFont("Fonts\\FRIZQT__.ttf", 12, "THINOUTLINE")Gui.func1frame.htopkills2:SetFading(false)Gui.func1frame.htopkills2:SetSpacing(0)Gui.func1frame.htopkills2:SetJustifyH("CENTER")Gui.func1frame.htopkills2:AddMessage("BANGS", 1, .8, 0, 1)        if numbers[1] then            Gui.func1frame.htopkills2:AddMessage(numbers[1], 0, .8, 0, 1)        else            Gui.func1frame.htopkills2:AddMessage("0", 0, .8, 0, 1)        end        if numbers[2] then            Gui.func1frame.htopkills2:AddMessage(numbers[2], 0, .8, 0, 1)        else            Gui.func1frame.htopkills2:AddMessage("0", 0, .8, 0, 1)        end        if numbers[3] then            Gui.func1frame.htopkills2:AddMessage(numbers[3], 0, .8, 0, 1)        else            Gui.func1frame.htopkills2:AddMessage("0", 0, .8, 0, 1)        end--Gui.func1frame.htopkills3 = CreateFrame("MessageFrame", nil, Gui.func1frame)Gui.func1frame.htopkills3:SetSize(50,100)Gui.func1frame.htopkills3:SetPoint("TOP", 0, 40)Gui.func1frame.htopkills3:SetFont("Fonts\\FRIZQT__.ttf", 12, "THINOUTLINE")Gui.func1frame.htopkills3:SetFading(false)Gui.func1frame.htopkills3:SetSpacing(0)Gui.func1frame.htopkills3:SetJustifyH("CENTER")Gui.func1frame.htopkills3:AddMessage("DEATHS", 1, .8, 0, 1)        if BangDeaths[names[numbers[1]][j]] then            Gui.func1frame.htopkills3:AddMessage(BangDeaths[names[numbers[1]][j]], .8, 0, 0, 1)        else            Gui.func1frame.htopkills3:AddMessage("0", .8, 0, 0, 1)        end        if BangDeaths[names[numbers[2]][j]] then            Gui.func1frame.htopkills3:AddMessage(BangDeaths[names[numbers[2]][j]], .8, 0, 0, 1)        else            Gui.func1frame.htopkills3:AddMessage("0", .8, 0, 0, 1)        end        if BangDeaths[names[numbers[3]][j]] then            Gui.func1frame.htopkills3:AddMessage(BangDeaths[names[numbers[3]][j]], .8, 0, 0, 1)        else            Gui.func1frame.htopkills3:AddMessage("0", .8, 0, 0, 1)        end--Gui.func1frame.htopkills4 = CreateFrame("MessageFrame", nil, Gui.func1frame)Gui.func1frame.htopkills4:SetSize(250,100)Gui.func1frame.htopkills4:SetPoint("TOP", 165, 40)Gui.func1frame.htopkills4:SetFont("Fonts\\FRIZQT__.ttf", 12, "THINOUTLINE")Gui.func1frame.htopkills4:SetFading(false)Gui.func1frame.htopkills4:SetSpacing(0)Gui.func1frame.htopkills4:SetJustifyH("LEFT")Gui.func1frame.htopkills4:AddMessage("WANTED NAME", 1, .8, 0, 1)        if names[numbers[1]][j] then            Gui.func1frame.htopkills4:AddMessage(names[numbers[1]][j], .9, .9, .9, 1)        else            Gui.func1frame.htopkills4:AddMessage("0", .9, .9, .9, 1)        end        if names[numbers[2]][j] then            Gui.func1frame.htopkills4:AddMessage(names[numbers[2]][j], .7, .7, .7, 1)        else            Gui.func1frame.htopkills4:AddMessage("0", .7, .7, .7, 1)        end        if names[numbers[3]][j] then            Gui.func1frame.htopkills4:AddMessage(names[numbers[3]][j], .6, .6, .6, 1)        else            Gui.func1frame.htopkills4:AddMessage("0", .6, .6, .6, 1)        endendendend`

08-07-17, 02:32 PM   #33
Ketho
A Molten Giant

Join Date: Mar 2010
Posts: 931
 Originally Posted by Kakjens P.S. I am crying.
I-I'd have to reinstall wow after using that addon

08-07-17, 02:42 PM   #34
Mortimerlol
A Cliff Giant
Join Date: Jul 2017
Posts: 71
¬.¬ ¬.¬ ¬.¬ ¬.¬ ¬.¬

08-07-17, 03:06 PM   #35
Banknorris
A Chromatic Dragonspawn

Join Date: Oct 2014
Posts: 153
What I can do is to explain my code. I will use this data

local BangCharHateds = {
["Paco"] = true,
["Anabel"] = true,
["Francisco"] = true,
}

local BangCharKills = {
["Tarmanu"] = 43,
["Anabel"] = 56,
["Armario"] = 23,
["Paco"] = 56,
["Francisco"] = 11,
["Casiopea"] = 22,
["Artamundo"] = 16,
["Costera"] = 7,
}

numbers
This is an array.
Hence keys are 1,2,3,...
#numbers is the number of DISTINCT kill counts

numbers[1] = 56
numbers[2] = 11

names
This is a hash table.
keys are kills counts
values are arrays of all names with that kill count

names = {} --hash table

names[56] = {} --array
names[56][1] = "Anabel"
names[56][2] = "Paco"

name[11] = {} --array
name[11][1] = {"Francisco"}

So my loops were traversing numbers in decrescent order and then for each number looping through all names, then going to the next highest kill count, listing all names with the kill count and so on.
__________________
"In this world nothing can be said to be certain, except that fractional reserve banking is a Ponzi scheme and that you won't believe it." - Mandrill

Last edited by Banknorris : 08-07-17 at 06:23 PM.

08-07-17, 06:47 PM   #36
MunkDev
A Scalebane Royal Guard

Join Date: Mar 2015
Posts: 428
I downloaded Bang Bang! just to check it out and the design is simply atrocious. Ever heard of local variables?
Because it's basically 100% spaghetti coded you must be using a ton of memory compared to what you should be using for a mod like this.

Also, why would you put a Sell Junk button in an addon aimed towards recounting your PvP activity?
Lua Code:
`-- found in core.luafunction VENDER()    total = 0    for bolsos = 0,4 do        for huecos = 1, GetContainerNumSlots(bolsos) do            producto = GetContainerItemLink(bolsos, huecos)                if producto then                    _, _, raro, _, _, _, _, _, _, _, precio = GetItemInfo(producto)                    _, items = GetContainerItemInfo(bolsos, huecos)                    if raro == 0 and precio ~= 0 then                        total = total + (precio * items)                        print("|cff555555Sold "..items.." "..producto.. " |cff555555" .. GetCoinTextureString(precio * items))                        UseContainerItem(bolsos, huecos)                    end                end        end    end    if total ~= 0 then        print("|cff555555--")        print("Total money gained: " .. GetCoinTextureString(total))    else        print("|cff555555No grey items to sell.")    endend local BotonVender = CreateFrame( "Button" , nil, MerchantFrame, "UIPanelButtonTemplate" )BotonVender:SetText("Sell Junk")BotonVender:SetWidth(90)BotonVender:SetHeight(21)BotonVender:SetPoint("TopRight", -180, -30 )BotonVender:RegisterForClicks("AnyUp")BotonVender:SetScript("Onclick", VENDER)--`
__________________

Last edited by MunkDev : 08-07-17 at 06:56 PM.

08-07-17, 08:52 PM   #37
Mortimerlol
A Cliff Giant
Join Date: Jul 2017
Posts: 71
Because I want do it. Thanks for speak bad about my proyect all time.

08-07-17, 09:03 PM   #38
briskman3000
A Cliff Giant
Join Date: Mar 2009
Posts: 75
 Originally Posted by Kakjens In provided code I don't see the reason for repeated printing. You can add a variable to count how many times you have printed and with the help of it exit the loops. P.S. I am crying.
WAIT ...

so this addon is using the variables

Code:
```lhprestigemax
lhprestige
lhhonorlevelmax
lhhonorlevel```
Those are clearly variable names from my honor addon Legion Honor

08-07-17, 09:14 PM   #39
lightspark
A Rage Talon Dragon Guard

Join Date: Sep 2012
Posts: 328
 Originally Posted by Mortimerlol Because I want do it. Thanks for speak bad about my proyect all time.
It's called critique and you may actually want to listen to these people.

You're ignoring many good practices, thus making your and everyone else's lives a lot harder. For instance, you define a lot of global variables. It's actually quite risky, because it may interfere w/ other addons and, even worse, Blizz code.
__________________

Last edited by lightspark : 08-07-17 at 11:34 PM.

08-07-17, 10:26 PM   #40
Mortimerlol
A Cliff Giant
Join Date: Jul 2017
Posts: 71
Yes but not really... Some people is saying that is horrible and these is FALSE, not using a lot memory or similar... nah, i must leave... bye.

 WoWInterface » Help comparison tables

 Thread Tools Display Modes Linear Mode

 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