Cosmetic; and added '-r' argument to reverse offline list

master
AardCrowley 2 years ago committed by GitHub
parent b0ae796711
commit 082b982be4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -4,6 +4,7 @@
<!-- MuClient version 5.07-pre -->
<!-- Plugin "FriendAgoSorted" generated by Plugin Wizard -->
<!-- Blame Kerith. He's a jerk. -->
<muclient>
<plugin name="FriendAgoSorted" author="Crowley" id="d434e9b635dc35c2ff25e1c9" language="Lua" purpose="Sort Friend Ago" save_state="y" date_written="2023-02-22 13:55:27" requires="4.99" version="1.0">
@ -28,9 +29,12 @@
<!-- Aliases -->
<aliases>
<alias match="^friend ago$" enabled="y" regexp="y" send_to="12" sequence="100">
<alias match="^friend ago(?: (-r))?$" enabled="y" regexp="y" send_to="12" sequence="100">
<send>
resetValues()
if "%1" == "-r" then
reverse = true
end
EnableTriggerGroup("friendCheck")
Send("friend ago")
</send>
@ -44,14 +48,15 @@
<![CDATA[
dofile(GetInfo(60) .. "aardwolf_colors.lua")
local friendAgo = {}
local friendSeconds = {}
local friendOther = {}
local friendsAlpha = {}
local count = 0
friendAgo = {}
friendSeconds = {}
friendOther = {}
friendsAlpha = {}
count = 0
reverse = false
local strForm = "@w%3d) %-12s - @R(Offline %d day%s and %02d:%02d:%02d)\n"
local statForm = "@w%3d) %-12s - %s(%s)\n"
strForm = "@w%3d) - %-12s@R(Offline - %d day%s and %02d:%02d:%02d)\n"
statForm = "@w%3d) - %-12s%s(%s)\n"
function resetValues()
friendAgo = {}
@ -86,7 +91,13 @@ function sortTableByValue(tbl)
for k, v in pairs(tbl) do
table.insert(sortedTable, {key = k, value = v})
end
if reverse == true then
table.sort(sortedTable, function(b, a) return a.value > b.value end)
else
table.sort(sortedTable, function(a, b) return a.value > b.value end)
end
reverse = false
return sortedTable
end

Loading…
Cancel
Save