Friend Communicator System

A friend communicator system that allows players to track their friends, page them, view which of them is online, and view the other players who have added them as a friend.

Author: Dyason@GlobalMUSH
Category: Other

Instructions

Copy and paste the below code into a compatible MUSH or MUX.

MUSHCode for Friend Communicator System

@create Fobject
@lock Fobject==me
&FADD_COMMAND Fobject=$fadd *:@switch num(*%0)=#-1,@pemit %#=No such player,{@switch member([v(FLIST_%#)],[num(*%0)])=0,{&FLIST_%# me=[v(FLIST_%#)] [num(*%0)];&FON_[num(*%0)] me=[v(FON_[num(*%0)])] %#;@pemit %#=[name(*%0)] has been added!},@pemit %#=[name(*%0)] is alreay on your list!}
&FLIST_COMMAND Fobject=$flist:@pemit %#============================================%rYou have set the following friends.%r-------------------------------------------%r[u(COLUMN_FN,[switch(words([v(FLIST_%#)]),0,You haven't set any friends.,[parse([v(FLIST_%#)],[name(##)])])])]%r-------------------------------------------%rTotal of [words([v(FLIST_%#)])]%r===========================================
&FREM_COMMAND Fobject=$frem *:@switch num(*%0)=#-1,@pemit %#=No such player,{@switch member([v(FLIST_%#)],[num(*%0)])=0,@pemit %#=That player is not on your list.,{&FLIST_%# me=[setdiff([v(FLIST_%#)],[num(*%0)])];&FON_[num(*%0)] me=[setdiff([v(FON_[num(*%0)])],%#)];@pemit %#=[name(*%0)] has been removed.}}
@Desc Fobject=A friendly friend helper!%rType +help friends for help.
&HELP Fobject=$+help friends:@pemit %#=The friend communicator system.%r%rYou can set your friends by typing:-%r%tfadd <name>%rYou can remove them by typing:-%r%tfrem <name>%rYou can list them by typing:-%r%tflist%rYou can list people who've added you by typinh:-%r%tfothers%rYou can page all your friends by the command:-%r%tpf <message>%rYou can see which of your friends are on by typing:-%r%tfwho%r%b%bIn the fwho command you also see people who've added you but you've %r%b%bnot added. They appear within %[%] brackets%r%rSoon to come...friend emotions! Tell them how your feeling.
&FWHO_COMMAND Fobject=$fwho:@pemit %#============================================%rYou have the following friends connected.%r-------------------------------------------%r[switch([words([setinter([lwho()],[setunion([v(FLIST_%#)],[v(FON_%#)])])])],0,%[NO-ONE LISTED%],[u(COLUMN_FN,[parse(setinter([lwho()],[setdiff([v(FON_%#)],[v(FLIST_%#)])]),%b%[[name(##)]%])][parse([setinter([lwho()],[v(FLIST_%#)])],%b[name(##)])])])]%r-------------------------------------------%rTotal of [words([setinter([lwho()],[setunion([v(FLIST_%#)],[v(FON_%#)])])])]%r===========================================
&PAGE_FRIENDS Fobject=$pf ?*:@dolist [setunion([v(FLIST_%#)],[v(FON_%#)])]=@pemit ##=[switch(%0,:,{%[To you and %p friends%] %N %1},;,{%[To you and %p friends%] %N%1},{%[To you and %p friends%] %N says "%0%1"})];@pemit %#=[switch(%0,:,{%[Friends%] %N %1},;,{%[Friends%] %N%1},{%[Friends%] %N says "%0%1"})]
&FEELING_COMMAND Fobject=$ffeel *:
&FOTHERS_COMMAND Fobject=$fothers:@pemit %#============================================%rThe following people have set you friend.%r-------------------------------------------%r[u(COLUMN_FN,[switch(words([v(FON_%#)]),0,No-one has set you their friend.,[parse([v(FON_%#)],[name(##)])])])]%r-------------------------------------------%rTotal of [words([v(FON_%#)])]%r===========================================
&COLUMN_FN Fobject=[switch(gt(words(%0),3),0,[u(FORMAT_FN,%0)],[u(FORMAT_FN,extract(%0,1,3))]%r[u(COLUMN_FN,extract(%0,4,words(%0)))])]
&FORMAT_FN Fobject=[first(%0)]%t%t[first(rest(%0))]%t%t[rest(rest(%0))]
@set Fobject=COMMANDS