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 --> <!-- MuClient version 5.07-pre -->
<!-- Plugin "FriendAgoSorted" generated by Plugin Wizard --> <!-- Plugin "FriendAgoSorted" generated by Plugin Wizard -->
<!-- Blame Kerith. He's a jerk. -->
<muclient> <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"> <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 -->
<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> <send>
resetValues() resetValues()
if "%1" == "-r" then
reverse = true
end
EnableTriggerGroup("friendCheck") EnableTriggerGroup("friendCheck")
Send("friend ago") Send("friend ago")
</send> </send>
@ -44,14 +48,15 @@
<![CDATA[ <![CDATA[
dofile(GetInfo(60) .. "aardwolf_colors.lua") dofile(GetInfo(60) .. "aardwolf_colors.lua")
local friendAgo = {} friendAgo = {}
local friendSeconds = {} friendSeconds = {}
local friendOther = {} friendOther = {}
local friendsAlpha = {} friendsAlpha = {}
local count = 0 count = 0
reverse = false
local strForm = "@w%3d) %-12s - @R(Offline %d day%s and %02d:%02d:%02d)\n" strForm = "@w%3d) - %-12s@R(Offline - %d day%s and %02d:%02d:%02d)\n"
local statForm = "@w%3d) %-12s - %s(%s)\n" statForm = "@w%3d) - %-12s%s(%s)\n"
function resetValues() function resetValues()
friendAgo = {} friendAgo = {}
@ -86,7 +91,13 @@ function sortTableByValue(tbl)
for k, v in pairs(tbl) do for k, v in pairs(tbl) do
table.insert(sortedTable, {key = k, value = v}) table.insert(sortedTable, {key = k, value = v})
end end
table.sort(sortedTable, function(a, b) return a.value > b.value 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 return sortedTable
end end

Loading…
Cancel
Save