Languages System (+say and +speak)
Adds +say and +speak commands to allow players to speak in foreign languages. Note that you will need to retrofit this to your MU*'s stats system.
Instructions
Copy and paste the below code into a compatible MUSH or MUX.
MUSHCode for Languages System (+say and +speak)
@create Globals: +say +speak=10
&CAN-SPEAK Globals: +say +speak=[u(fn-speaks,%0,%q2)]
&FN-LANG Globals: +say +speak=[switch(gt(words(%0),10),0,extract(v(data-words),words(%0),1,|),something)]
&DATA-WORDS Globals: +say +speak=a single word|a couple of words|a couple of words|a few words|a few words|a few words|something quickly|something quickly|something brief|something brief
&CMD-SAY Globals: +say +speak=$+say *:@switch [u(fn-speaking,%#)]=,@pemit %#=You don't have a default language set.,{@remit %l=%N[setq(0,mid(%0,0,1))][setq(1,delete(%0,0,1))][setq(2,u(fn-speaking,%#))][switch(%q0,:,%b[u(fn-parse,%q1)],;,[u(fn-parse,%q1)],%bsays [u(fn-lang,%0)] in %q2.)];@pemit/list [filter(can-speak,lcon(%l))]=%N[switch(%q0,:,%b%q1,;,%q1,%bsays "%0")]}
&FN-SPEAKS Globals: +say +speak=[gt(member(get(*%0/LANGUAGES),capstr(lcstr(%1))),0)]
&FN-PARSE Globals: +say +speak=[setq(3,first(%0,"))][setq(5,last(%0,"))][setq(4,remove(remove(%0,%q5,"),%q3,"))][%q3[switch(mid(%q3,sub(strlen(%q3),2),1),.,%S says%b)][u(fn-lang,%q4)] in %q2[setq(6,mid(%q4,sub(strlen(%q4),1),1))][switch(%q6,.,.)][switch(%q5,,switch(%q6,.,,.),%q5)]]
&FN-SPEAKING Globals: +say +speak=[get(%0/SPEAKING)]
&CMD-SPEAK Globals: +say +speak=$+speak *:@switch [u(fn-speaks,%#,%0)]=0,@pemit %#=I'm sorry. You can't speak [capstr(lcstr(%0))].,{@pemit %#=Your default language is now [capstr(lcstr(%0))].;&SPEAKING %#=[capstr(lcstr(%0))];@chown %#/SPEAKING=#3}
&CMD-SAY-ALT Globals: +say +speak=$+" *:@switch [u(fn-speaking,%#)]=,@pemit %#=You don't have a default language set.,{@remit %l=%N[setq(0,mid(%0,0,1))][setq(1,delete(%0,0,1))][setq(2,u(fn-speaking,%#))][switch(%q0,:,%b[u(fn-parse,%q1)],;,[u(fn-parse,%q1)],%bsays [u(fn-lang,%0)] in %q2.)];@pemit/list [filter(can-speak,lcon(%l))]=%N[switch(%q0,:,%b%q1,;,%q1,%bsays "%0")]}
&CMD-SPEAK0 Globals: +say +speak=$+speak:@pemit %#=[setq(0,get(%#/SPEAKING))][switch(%q0,,You have no default language set.,Your default language is %q0.)]
&DATA-+HELP Globals: +say +speak=+say|+" <message>%r+speak \[<language>\]%r%r+speak <language> sets you're default langue - +speak on its own tells you what it is.%r%r+say/+" <messsage> allow you to use that language, and only be understood by those who speak it (though everyone knows what language you speak).%r%rCredits: Michael@Conspiracy!
@set Globals: +say +speak=INHERIT
@set Globals: +say +speak=STICKY
@set Globals: +say +speak=VISUAL
@set Globals: +say +speak=SAFE
@force Globals: +say +speak="I assume that the player's known languages live on his &LANGUAGES attribute (in lower case + initial capital), and I set his &SPEAKING attribute to the language he's currently using. My +help text is on my &DATA-+HELP - please preserve the credits notice."
&CAN-SPEAK Globals: +say +speak=[u(fn-speaks,%0,%q2)]
&FN-LANG Globals: +say +speak=[switch(gt(words(%0),10),0,extract(v(data-words),words(%0),1,|),something)]
&DATA-WORDS Globals: +say +speak=a single word|a couple of words|a couple of words|a few words|a few words|a few words|something quickly|something quickly|something brief|something brief
&CMD-SAY Globals: +say +speak=$+say *:@switch [u(fn-speaking,%#)]=,@pemit %#=You don't have a default language set.,{@remit %l=%N[setq(0,mid(%0,0,1))][setq(1,delete(%0,0,1))][setq(2,u(fn-speaking,%#))][switch(%q0,:,%b[u(fn-parse,%q1)],;,[u(fn-parse,%q1)],%bsays [u(fn-lang,%0)] in %q2.)];@pemit/list [filter(can-speak,lcon(%l))]=%N[switch(%q0,:,%b%q1,;,%q1,%bsays "%0")]}
&FN-SPEAKS Globals: +say +speak=[gt(member(get(*%0/LANGUAGES),capstr(lcstr(%1))),0)]
&FN-PARSE Globals: +say +speak=[setq(3,first(%0,"))][setq(5,last(%0,"))][setq(4,remove(remove(%0,%q5,"),%q3,"))][%q3[switch(mid(%q3,sub(strlen(%q3),2),1),.,%S says%b)][u(fn-lang,%q4)] in %q2[setq(6,mid(%q4,sub(strlen(%q4),1),1))][switch(%q6,.,.)][switch(%q5,,switch(%q6,.,,.),%q5)]]
&FN-SPEAKING Globals: +say +speak=[get(%0/SPEAKING)]
&CMD-SPEAK Globals: +say +speak=$+speak *:@switch [u(fn-speaks,%#,%0)]=0,@pemit %#=I'm sorry. You can't speak [capstr(lcstr(%0))].,{@pemit %#=Your default language is now [capstr(lcstr(%0))].;&SPEAKING %#=[capstr(lcstr(%0))];@chown %#/SPEAKING=#3}
&CMD-SAY-ALT Globals: +say +speak=$+" *:@switch [u(fn-speaking,%#)]=,@pemit %#=You don't have a default language set.,{@remit %l=%N[setq(0,mid(%0,0,1))][setq(1,delete(%0,0,1))][setq(2,u(fn-speaking,%#))][switch(%q0,:,%b[u(fn-parse,%q1)],;,[u(fn-parse,%q1)],%bsays [u(fn-lang,%0)] in %q2.)];@pemit/list [filter(can-speak,lcon(%l))]=%N[switch(%q0,:,%b%q1,;,%q1,%bsays "%0")]}
&CMD-SPEAK0 Globals: +say +speak=$+speak:@pemit %#=[setq(0,get(%#/SPEAKING))][switch(%q0,,You have no default language set.,Your default language is %q0.)]
&DATA-+HELP Globals: +say +speak=+say|+" <message>%r+speak \[<language>\]%r%r+speak <language> sets you're default langue - +speak on its own tells you what it is.%r%r+say/+" <messsage> allow you to use that language, and only be understood by those who speak it (though everyone knows what language you speak).%r%rCredits: Michael@Conspiracy!
@set Globals: +say +speak=INHERIT
@set Globals: +say +speak=STICKY
@set Globals: +say +speak=VISUAL
@set Globals: +say +speak=SAFE
@force Globals: +say +speak="I assume that the player's known languages live on his &LANGUAGES attribute (in lower case + initial capital), and I set his &SPEAKING attribute to the language he's currently using. My +help text is on my &DATA-+HELP - please preserve the credits notice."