Thread Tools Display Modes
08-07-17, 07:58 AM   #21
Mortimerlol
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Jul 2017
Posts: 71
Originally Posted by Kakjens View Post
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
  Reply With Quote
08-07-17, 11:23 AM   #22
Banknorris
A Chromatic Dragonspawn
 
Banknorris's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 153
Originally Posted by Mortimerlol View Post
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.
  Reply With Quote
08-07-17, 12:06 PM   #23
Mortimerlol
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Jul 2017
Posts: 71
I go to check then, sry.
  Reply With Quote
08-07-17, 12:16 PM   #24
Mortimerlol
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Jul 2017
Posts: 71
no good values, i dont understand
Lua Code:
  1. table.sort(numbers)
  2. for i=#numbers,1,-1 do
  3.     table.sort(names[numbers[i]])
  4.     for j=1,#names[numbers[i]] do
  5.         print(numbers[1],names[numbers[1]][j])
  6.         print(numbers[2],names[numbers[2]][j])
  7.     end
  8. end
  Reply With Quote
08-07-17, 12:26 PM   #25
Mortimerlol
A Cliff Giant
AddOn Author - Click to view addons
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:
  1. print("TOP 1: "..numbers[1], names[numbers[1]][1])
  2.         print("TOP 2: "..numbers[2], names[numbers[2]][2])
  3.         print("TOP 3: "..numbers[3], names[numbers[3]][3])

I dont see that I do wrong.
  Reply With Quote
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 *
  Reply With Quote
08-07-17, 01:17 PM   #27
Mortimerlol
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Jul 2017
Posts: 71
yes but, i need line per line but with 1, 2, 3, 4:

Lua Code:
  1. Gui.func1frame.htopkills2:AddMessage("BANGS", 1, .8, 0, 1)
  2.         if numbers[1] then
  3.             Gui.func1frame.htopkills2:AddMessage(numbers[1], 0, .8, 0, 1)
  4.         else
  5.             Gui.func1frame.htopkills2:AddMessage("0", 0, .8, 0, 1)
  6.         end
  7.                 if numbers[2] then
  8.             Gui.func1frame.htopkills2:AddMessage(numbers[2], 0, .8, 0, 1)
  9.         else
  10.             Gui.func1frame.htopkills2:AddMessage("0", 0, .8, 0, 1)
  11.         end
  12.                         if numbers[3] then
  13.             Gui.func1frame.htopkills2:AddMessage(numbers[3], 0, .8, 0, 1)
  14.         else
  15.             Gui.func1frame.htopkills2:AddMessage("0", 0, .8, 0, 1)
  16.         end
  17. --......
  18.         if names[numbers[1]][j] then
  19.             Gui.func1frame.htopkills4:AddMessage(names[numbers[1]][j], .9, .9, .9, 1)
  20.         else
  21.             Gui.func1frame.htopkills4:AddMessage("0", .9, .9, .9, 1)
  22.         end
  23.                 if names[numbers[2]][j] then
  24.             Gui.func1frame.htopkills4:AddMessage(names[numbers[2]][j], .7, .7, .7, 1)
  25.         else
  26.             Gui.func1frame.htopkills4:AddMessage("0", .7, .7, .7, 1)
  27.         end
  28.         if names[numbers[3]][j] then
  29.             Gui.func1frame.htopkills4:AddMessage(names[numbers[3]][j], .6, .6, .6, 1)
  30.         else
  31.             Gui.func1frame.htopkills4:AddMessage("0", .6, .6, .6, 1)
  32.         end
  Reply With Quote
08-07-17, 01:19 PM   #28
Mortimerlol
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Jul 2017
Posts: 71
I only need can do:

Lua Code:
  1. print("TOP 1: "..numbers[1111111], names[numbers[1111111]][11111111])
  2.        -----blablabla
  3.         print("TOP 2: "..numbers[22222], names[numbers[2222]][222222])
  Reply With Quote
08-07-17, 01:24 PM   #29
Mortimerlol
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Jul 2017
Posts: 71
Yeah, now works as like/need. THANKS !

Lua Code:
  1. if which == 1 then print("TOP 1"..numbers[i], names[numbers[i]][j]) end
  2.         if which == 2 then print("TOP 2"..numbers[i], names[numbers[i]][j]) end
  3.         if which == 3 then print("TOP 3"..numbers[i], names[numbers[i]][j]) end
  4.         if which == 4 then print("TOP 4"..numbers[i], names[numbers[i]][j]) end
  Reply With Quote
08-07-17, 01:39 PM   #30
Mortimerlol
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Jul 2017
Posts: 71
no, no works, im crazy with it
  Reply With Quote
08-07-17, 01:58 PM   #31
Kakjens
A Cliff Giant
Join Date: Apr 2017
Posts: 75
Originally Posted by Mortimerlol View Post
no, no works, im crazy with it
Pasting more code to see the context would help.
  Reply With Quote
08-07-17, 02:04 PM   #32
Mortimerlol
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Jul 2017
Posts: 71
Thanks...

Lua Code:
  1. function hTops()
  2.     local names = {}
  3.     local numbers = {}
  4.      
  5.     for char_name,number_of_kills in pairs(BangKills) do
  6.         if BangHateds[char_name] then
  7.             if not names[number_of_kills] then
  8.                 numbers[#numbers+1] = number_of_kills
  9.                 names[number_of_kills] = {char_name}
  10.             else
  11.                 names[number_of_kills][#names[number_of_kills]+1] = char_name
  12.             end
  13.         end
  14.     end
  15.  
  16. table.sort(numbers, function(a,b)
  17.     return b < a
  18. end)
  19.  
  20. for i=1,1, -1 do
  21. for j=1,1 do
  22.  
  23.     --foreach(numbers, print)
  24. Gui.func1frame.htopkills1 = CreateFrame("MessageFrame", nil, Gui.func1frame)
  25. Gui.func1frame.htopkills1:SetSize(50,100)
  26. Gui.func1frame.htopkills1:SetPoint("TOP", -110, 40)
  27. Gui.func1frame.htopkills1:SetFont("Fonts\\FRIZQT__.ttf", 12, "THINOUTLINE")
  28. Gui.func1frame.htopkills1:SetFading(false)
  29. Gui.func1frame.htopkills1:SetSpacing(0)
  30. Gui.func1frame.htopkills1:SetJustifyH("CENTER")
  31. Gui.func1frame.htopkills1:AddMessage("TOP ", 1, .8, 0, 1)
  32. Gui.func1frame.htopkills1:AddMessage("#1", 1, .7, .05, 1)
  33. Gui.func1frame.htopkills1:AddMessage("#2", .65, .65, .65, 1)
  34. Gui.func1frame.htopkills1:AddMessage("#3", .6, .35, 0, 1)
  35. --
  36. Gui.func1frame.htopkills2 = CreateFrame("MessageFrame", nil, Gui.func1frame)
  37. Gui.func1frame.htopkills2:SetSize(50,100)
  38. Gui.func1frame.htopkills2:SetPoint("TOP", -60, 40)
  39. Gui.func1frame.htopkills2:SetFont("Fonts\\FRIZQT__.ttf", 12, "THINOUTLINE")
  40. Gui.func1frame.htopkills2:SetFading(false)
  41. Gui.func1frame.htopkills2:SetSpacing(0)
  42. Gui.func1frame.htopkills2:SetJustifyH("CENTER")
  43. Gui.func1frame.htopkills2:AddMessage("BANGS", 1, .8, 0, 1)
  44.         if numbers[1] then
  45.             Gui.func1frame.htopkills2:AddMessage(numbers[1], 0, .8, 0, 1)
  46.         else
  47.             Gui.func1frame.htopkills2:AddMessage("0", 0, .8, 0, 1)
  48.         end
  49.         if numbers[2] then
  50.             Gui.func1frame.htopkills2:AddMessage(numbers[2], 0, .8, 0, 1)
  51.         else
  52.             Gui.func1frame.htopkills2:AddMessage("0", 0, .8, 0, 1)
  53.         end
  54.         if numbers[3] then
  55.             Gui.func1frame.htopkills2:AddMessage(numbers[3], 0, .8, 0, 1)
  56.         else
  57.             Gui.func1frame.htopkills2:AddMessage("0", 0, .8, 0, 1)
  58.         end
  59. --
  60. Gui.func1frame.htopkills3 = CreateFrame("MessageFrame", nil, Gui.func1frame)
  61. Gui.func1frame.htopkills3:SetSize(50,100)
  62. Gui.func1frame.htopkills3:SetPoint("TOP", 0, 40)
  63. Gui.func1frame.htopkills3:SetFont("Fonts\\FRIZQT__.ttf", 12, "THINOUTLINE")
  64. Gui.func1frame.htopkills3:SetFading(false)
  65. Gui.func1frame.htopkills3:SetSpacing(0)
  66. Gui.func1frame.htopkills3:SetJustifyH("CENTER")
  67. Gui.func1frame.htopkills3:AddMessage("DEATHS", 1, .8, 0, 1)
  68.         if BangDeaths[names[numbers[1]][j]] then
  69.             Gui.func1frame.htopkills3:AddMessage(BangDeaths[names[numbers[1]][j]], .8, 0, 0, 1)
  70.         else
  71.             Gui.func1frame.htopkills3:AddMessage("0", .8, 0, 0, 1)
  72.         end
  73.         if BangDeaths[names[numbers[2]][j]] then
  74.             Gui.func1frame.htopkills3:AddMessage(BangDeaths[names[numbers[2]][j]], .8, 0, 0, 1)
  75.         else
  76.             Gui.func1frame.htopkills3:AddMessage("0", .8, 0, 0, 1)
  77.         end
  78.         if BangDeaths[names[numbers[3]][j]] then
  79.             Gui.func1frame.htopkills3:AddMessage(BangDeaths[names[numbers[3]][j]], .8, 0, 0, 1)
  80.         else
  81.             Gui.func1frame.htopkills3:AddMessage("0", .8, 0, 0, 1)
  82.         end
  83. --
  84. Gui.func1frame.htopkills4 = CreateFrame("MessageFrame", nil, Gui.func1frame)
  85. Gui.func1frame.htopkills4:SetSize(250,100)
  86. Gui.func1frame.htopkills4:SetPoint("TOP", 165, 40)
  87. Gui.func1frame.htopkills4:SetFont("Fonts\\FRIZQT__.ttf", 12, "THINOUTLINE")
  88. Gui.func1frame.htopkills4:SetFading(false)
  89. Gui.func1frame.htopkills4:SetSpacing(0)
  90. Gui.func1frame.htopkills4:SetJustifyH("LEFT")
  91. Gui.func1frame.htopkills4:AddMessage("WANTED NAME", 1, .8, 0, 1)
  92.         if names[numbers[1]][j] then
  93.             Gui.func1frame.htopkills4:AddMessage(names[numbers[1]][j], .9, .9, .9, 1)
  94.         else
  95.             Gui.func1frame.htopkills4:AddMessage("0", .9, .9, .9, 1)
  96.         end
  97.         if names[numbers[2]][j] then
  98.             Gui.func1frame.htopkills4:AddMessage(names[numbers[2]][j], .7, .7, .7, 1)
  99.         else
  100.             Gui.func1frame.htopkills4:AddMessage("0", .7, .7, .7, 1)
  101.         end
  102.         if names[numbers[3]][j] then
  103.             Gui.func1frame.htopkills4:AddMessage(names[numbers[3]][j], .6, .6, .6, 1)
  104.         else
  105.             Gui.func1frame.htopkills4:AddMessage("0", .6, .6, .6, 1)
  106.         end
  107. end
  108. end
  109. end
  Reply With Quote
08-07-17, 02:32 PM   #33
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
Originally Posted by Kakjens View Post
P.S. I am crying.
I-I'd have to reinstall wow after using that addon

  Reply With Quote
08-07-17, 02:42 PM   #34
Mortimerlol
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Jul 2017
Posts: 71
¬.¬ ¬.¬ ¬.¬ ¬.¬ ¬.¬
  Reply With Quote
08-07-17, 03:06 PM   #35
Banknorris
A Chromatic Dragonspawn
 
Banknorris's Avatar
AddOn Author - Click to view addons
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.
  Reply With Quote
08-07-17, 06:47 PM   #36
MunkDev
A Scalebane Royal Guard
 
MunkDev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 431
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:
  1. -- found in core.lua
  2. function VENDER()
  3.     total = 0
  4.     for bolsos = 0,4 do
  5.         for huecos = 1, GetContainerNumSlots(bolsos) do
  6.             producto = GetContainerItemLink(bolsos, huecos)
  7.                 if producto then
  8.                     _, _, raro, _, _, _, _, _, _, _, precio = GetItemInfo(producto)
  9.                     _, items = GetContainerItemInfo(bolsos, huecos)
  10.                     if raro == 0 and precio ~= 0 then
  11.                         total = total + (precio * items)
  12.                         print("|cff555555Sold "..items.." "..producto.. " |cff555555" .. GetCoinTextureString(precio * items))
  13.                         UseContainerItem(bolsos, huecos)
  14.                     end
  15.                 end
  16.         end
  17.     end
  18.     if total ~= 0 then
  19.         print("|cff555555--")
  20.         print("Total money gained: " .. GetCoinTextureString(total))
  21.     else
  22.         print("|cff555555No grey items to sell.")
  23.     end
  24. end
  25.  
  26. local BotonVender = CreateFrame( "Button" , nil, MerchantFrame, "UIPanelButtonTemplate" )
  27. BotonVender:SetText("Sell Junk")
  28. BotonVender:SetWidth(90)
  29. BotonVender:SetHeight(21)
  30. BotonVender:SetPoint("TopRight", -180, -30 )
  31. BotonVender:RegisterForClicks("AnyUp")
  32. BotonVender:SetScript("Onclick", VENDER)
  33. --
__________________

Last edited by MunkDev : 08-07-17 at 06:56 PM.
  Reply With Quote
08-07-17, 08:52 PM   #37
Mortimerlol
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Jul 2017
Posts: 71
Because I want do it. Thanks for speak bad about my proyect all time.
  Reply With Quote
08-07-17, 09:03 PM   #38
briskman3000
A Flamescale Wyrmkin
 
briskman3000's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 108
Originally Posted by Kakjens View Post
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
__________________
My Addons: Convert Ratings Honor Track
  Reply With Quote
08-07-17, 09:14 PM   #39
lightspark
A Rage Talon Dragon Guard
 
lightspark's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2012
Posts: 341
Originally Posted by Mortimerlol View Post
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.
  Reply With Quote
08-07-17, 10:26 PM   #40
Mortimerlol
A Cliff Giant
AddOn Author - Click to view addons
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.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Help comparison tables

Thread Tools
Display Modes

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