I will try explaining this as good as i can...
Trying to build an addon to collect random roll results, and list them nicely with name, roll size, if roll is valid (1-100) and then sort the table, so highest roll shows at top.
I first thought collecting the rolls in a table:
Lua Code:
local RollCollector = {}
function RollMaster:CHAT_MSG_SYSTEM(event, ...)
local arg1 = select(1, ...)
if arg1 then
local name, roll, minRoll, maxRoll = arg1:match("^(.+) rolls (%d+) %((%d+)%-(%d+)%)$")
for i = 1, 20 do
if RollCollector[i] and RollCollector[i][1] == name then
print(name.." rolled twice")
roll = nil
end
end
if roll then
table.insert(RollCollector, 1, 0)
RollCollector[1] = {name, roll, minRoll, maxRoll}
end
end
end
However, i'm not sure about how to sort a table like that (if even possible).
Then i thought about doing like 4 tables:
Lua Code:
local RollCollector = {
name = {},
roll = {},
minRoll = {},
maxRoll{},
}
and saving each arguement to its own table... But when running the table.sort method like this, it will only sort the rolls, which would remove the link between name and roll...
Anyone got a solution for this?
(Hope you understand the question, beside my rusty english!!)
Thanks alot on advance!