HM-CODE / Haunted-Memories

A repository for Haunted Memories code.
http://www.haunted-memories.net/
BSD 3-Clause "New" or "Revised" License
4 stars 5 forks source link

Sort +watch/who alphabetically #97

Open Bradamante opened 13 years ago

Bradamante commented 13 years ago

Tweak +watch/who to display names sorted alphabetically rather than by dbref.

hmmorpheus commented 13 years ago

This will do that:

&c.+watch/who #151=$+watch/who:@pemit %#=[header(+watch)]%R[iter([iter(sort(iter(u(%#/friends),name(##):##)),rest(##,:))],[switch(type(##),PLAYER,{%r%t [ljust([name(##)] [if(hasattr(##,alias),%([get(##/alias)]%),)],53,.)]%b[switch(and(or(not(member(u(NOWATCH),##)),member(get(##/watchpermit),%#)),objeval(%#,hasflag(##,connected)),not(hasflag(##,dark))),1,%ch%cgOnline%cn,%ch%crOffline%cn)]})])]%R%R[tail()]

It's not the prettiest piece of code, but it will take the current list of dbrefs, pull out names, sort by those names, strip out the names again and process it through the original code to insure that the new code works with the current storage system and preserves the more efficient dbref storage as well as giving the alphabetic sort requested.

nivthefox commented 12 years ago

Morpheus' function is a bit ugly. Better to make a sortby().