Difference between revisions of "Code"

From Masq
m
 
(24 intermediate revisions by 3 users not shown)
Line 1: Line 1:
Various snippets of code can make one's life easier (or more complicated), and this is where you can grab them for your character.  Copy them from the page, then paste them into your MU* client, and enjoy!
+
Various snippets of code can make one's life easier (or more complicated), and this is where you can grab them for your character.  Copy them from the page, paste them into your MU* client, make sure to <code>@set me=!no_command</code>, and enjoy!
  
 
== Texting Code ==
 
== Texting Code ==
{|
+
{|width=100%
 
|-
 
|-
|'''This code is for sending IC text messages from a phone.  You'll need all three attributes. Syntax: ''+text name=message'''''
+
|'''This code is for sending IC text messages from a phone.  You'll need all three attributes.'''
 +
|width=300px|'''Syntax: ''+text name=message'''''
 
|-
 
|-
|style="padding: 1em;border: 1px dashed #2f6fab;color: black;background-color: #f9f9f9;line-height: 1.25em;font-family: monospace;"|&cmd-text me=$+text *=*:think if(isdbref(num(*%0)),[if(lte(strlen(%1),160),[u(fun-text_send,%0,%1)],[u(fun-text_proc,%0,%1)])],"%0" doesn't seem to be a valid player. Please try again!)
+
|colspan=2 style="padding: 1em;border: 1px dashed #2f6fab;color: black;background-color: #f9f9f9;line-height: 1.25em;font-family: monospace;"|&cmd-text me=$+text *=*:think if(isdbref(locate(%#,*%0,Pp)),[if(lte(strlen(%1),160),[u(fun-text_send,%0,%1)],[u(fun-text_proc,%0,%1)])],"%0" doesn't seem to be a valid player. Please try again!)
 
|-  
 
|-  
|style="padding: 1em;border: 1px dashed #2f6fab;color: black;background-color: #f9f9f9;line-height: 1.25em;font-family: monospace;"|&fun-text_proc me=[setq(0,%1)][setq(1,mid(%q0,0,160))][if(match(mid(%q0,160,1), ),[setq(0,mid(%q0,160,strlen(%q0)))],[setq(2,[strtrunc(%q1,sub(strlen(%q1),strlen(last(%q1))))])][setq(1,%q2)][setq(0,mid(%q0,strlen(%q2),strlen(%q0)))])][u(fun-text_send,%0,%q1)][if(strlen(%q0),u(fun-text_proc,%0,%q0))]  
+
|colspan=2 style="padding: 1em;border: 1px dashed #2f6fab;color: black;background-color: #f9f9f9;line-height: 1.25em;font-family: monospace;"|&fun-text_proc me=[setq(0,%1)][setq(1,mid(%q0,0,160))][if(match(mid(%q0,160,1), ),[setq(0,mid(%q0,160,strlen(%q0)))],[setq(2,[strtrunc(%q1,sub(strlen(%q1),strlen(last(%q1))))])][setq(1,%q2)][setq(0,mid(%q0,strlen(%q2),strlen(%q0)))])][u(fun-text_send,%0,%q1)][if(strlen(%q0),u(fun-text_proc,%0,%q0))]  
 
|-  
 
|-  
|style="padding: 1em;border: 1px dashed #2f6fab;color: black;background-color: #f9f9f9;line-height: 1.25em;font-family: monospace;"|&fun-text_send me=[pemit(%#,You text to [name(*%0)]: %1)][pemit(num(*%0),You receive a text from %N: %1)]
+
|colspan=2 style="padding: 1em;border: 1px dashed #2f6fab;color: black;background-color: #f9f9f9;line-height: 1.25em;font-family: monospace;"|&fun-text_send me=[pemit(%#,You text to [name(*%0)]: %1)][pemit(num(*%0),You receive a text from %N: %1)]
 
|-
 
|-
 
|Original code by [[Zack]], modified by [[Jai]].
 
|Original code by [[Zack]], modified by [[Jai]].
 +
|}
 +
 +
 +
== Non-truncated +Who ==
 +
{|width=100%
 +
|-
 +
|'''This code replaces +who with a wider version which doesn't truncate the location information.'''
 +
|width=300px|'''Syntax: ''+who'''''
 +
|-
 +
|colspan=2 style="padding: 1em;border: 1px dashed #2f6fab;color: black;background-color: #f9f9f9;line-height: 1.25em;font-family: monospace;"|&cmd-who me=$+who:@pemit me=%r[repeat(=,30)]>[center(The MASQUERADE,18, )]<[repeat(=,30)]%r [center(Player,18, )] Sex Alias [center(Idle,8, )][space(3)]Location[rjust(%xh%xyPlayer Count:%xc [words(setunion(lwho(),))],30, %xn)]%r [repeat(-,18)] [repeat(-,3)] [repeat(-,5)] [repeat(-,8)][space(3)][repeat(-,38)]%r [iter(setunion(lwho(),),[ljust(name(##),18)][center(ucstr(ljust(get_eval(##/sex),1)),5, )][center(get_eval(##/alias),5, )] [rjust(extract(exptime(idle(##)),1,2),8)][if(hasflag(##,staff),%b*%b,space(3))][if(match(where(##),#-1),%xrUnfindable%xn,name(where(##)))]%r)][repeat(=,80)]
 
|-
 
|-
 +
|Code by [[Devlin]], with debugging assistance from [[Charles]] and suggested look-and-feel modifications from [[Bill]]
 
|}
 
|}
 +
  
 
== Directed +Where ==
 
== Directed +Where ==
{|
+
{|width=100%
 
|-
 
|-
|'''This code works like +where, but for a specific person. Syntax: ''+where name'''''
+
|'''This code works like +where, but for a specific person.'''
 +
|width=300px|'''Syntax: ''+where name'''''
 
|-
 
|-
|style="padding: 1em;border: 1px dashed #2f6fab;color: black;background-color: #f9f9f9;line-height: 1.25em;font-family: monospace;"|&cmd-where me=$+where *:think [ansi(hr,REPORT:)] [setq(0,pmatch(%0))][if(%q0,[name(%q0)] [if(hasflag(%q0,connect),[if(loc(%q0),is currently at: [name([loc(%q0)])],cannot currently be found.)],is not currently online.)],"[capstr(%0)]" does not match any player.)]
+
|colspan=2 style="padding: 1em;border: 1px dashed #2f6fab;color: black;background-color: #f9f9f9;line-height: 1.25em;font-family: monospace;"|&cmd-where me=$+where *:think [ansi(hr,REPORT:)] [setq(0,pmatch(%0))][if(%q0,[name(%q0)] [if(hasflag(%q0,connect),[if(loc(%q0),is currently at: [name([loc(%q0)])],cannot currently be found.)],is not currently online.)],"[capstr(%0)]" does not match any player.)]
 
|-
 
|-
 
|Original code by [[Petra]], modified by [[Jai]]
 
|Original code by [[Petra]], modified by [[Jai]]
|-
 
 
|}
 
|}
 +
  
 
== Idle Time Checker ==
 
== Idle Time Checker ==
{|
+
{|width=100%
 +
|-
 +
|'''This code reports how long a specific person has been idle.'''
 +
|width=300px|'''Syntax: ''+idle name'''''
 +
|-
 +
|colspan=2 style="padding: 1em;border: 1px dashed #2f6fab;color: black;background-color: #f9f9f9;line-height: 1.25em;font-family: monospace;"|&cmd-idle me=$+idle *:think [ansi(hr,REPORT:)] [setq(0,pmatch(%0))][if(%q0,[name(%q0)] [if(hasflag(%q0,connect),has been idle [exptime(idle(%0))].,is not currently online.)],"[capstr(%0)]" does not match any player.)]
 +
|-
 +
|Original code by [[Petra]], modified by [[Jai]]
 +
|}
 +
 
 +
 
 +
== Connection Checker ==
 +
{|width=100%
 +
|-
 +
|'''This code tells you how long someone's been connected, or how long since they logged off.'''
 +
|width=300px|'''Syntax: ''+conn name'''''
 +
|-
 +
|colspan=2 style="padding: 1em;border: 1px dashed #2f6fab;color: black;background-color: #f9f9f9;line-height: 1.25em;font-family: monospace;"|&cmd-connected me=$+conn *:think ansi(hr,REPORT:) [setq(0,pmatch(%0))][if(%q0,[name(%q0)] [if(hasflag(%q0,connect),has been connected for [writetime(conn(%0))].,has been disconnected since [timefmt($A $B $d% at $I:$M $P,connleft(%0))] %([writetime(sub(secs(),connleft(%0)))] ago.%))],"[capstr(%0)]" does not match any player.)]
 +
|-
 +
|colspan=2| Code by [[Petra]], aided by [[Jai]].
 +
|}
 +
 
 +
 
 +
== Desc Identifier ==
 +
{|width=100%
 +
|-
 +
|'''This code prepends the desc of the person you're looking at with a line identifying whose desc it is.'''
 +
|width=300px|'''Syntax: ''+l name'''''
 +
|-
 +
|colspan=2 style="padding: 1em;border: 1px dashed #2f6fab;color: black;background-color: #f9f9f9;line-height: 1.25em;font-family: monospace;"|&cmd-look me=$+l *:@pemit me=[repeat(*,78)]%r[center(Desc of [name([num(%0)])],78)]%r[repeat(*,78)]%r;l %0
 +
|-
 +
|Code by [[Petra]], with some awesome help refining it from [[Jai]]
 +
|}
 +
 
 +
 
 +
== Random @Doing Picker ==
 +
{|width=100%
 +
|-
 +
|'''This code sets an @doing chosen randomly from your list.'''
 +
|width=300px|'''Syntax: ''+doing'''''
 +
|-
 +
|colspan=2 style="padding: 1em;border: 1px dashed #2f6fab;color: black;background-color: #f9f9f9;line-height: 1.25em;font-family: monospace;"|&cmd-doing me=$+doing:@doing/quiet [setr(0,pickrand(v(txt-doing_list),|))][pemit(me,@Doing set to: %q0)]
 +
|-
 +
|<br />
 +
'''This code lists the @doings in your list.'''
 +
|<br />
 +
'''Syntax: ''+doing/list'''''
 +
|-
 +
|colspan=2 style="padding: 1em;border: 1px dashed #2f6fab;color: black;background-color: #f9f9f9;line-height: 1.25em;font-family: monospace;"|&cmd-doing_list me=$+doing/list:think [center(Doings,51,=)][setq(1,strlen(words(setq(0,v(txt-doing_list)),|)))]%r%b[iter(%q0,ifelse(lt(strlen(#@),%q1),0#@,#@). ##%r,|)][repeat(=,51)]
 +
|-
 +
|<br />
 +
'''This code adds an @doing to your list of available @doings.'''
 +
|<br />
 +
'''Syntax: ''+doing/add yourdoing'''''
 
|-
 
|-
|'''This code reports how long a specific person has been idle. Syntax: ''+idle name'''''
+
|colspan=2 style="padding: 1em;border: 1px dashed #2f6fab;color: black;background-color: #f9f9f9;line-height: 1.25em;font-family: monospace;"|&cmd-doing_add me=$+doing/add *:think ifelse(lte(strlen(%0),45),set(me,txt-doing_list:[setunion(v(txt-doing_list),%0,|)]) The following new @doing was set: %0,That @doing is [setr(0,sub(strlen(%0),45))] character[if(eq(%q0,1),,s)] too long\, and has not been added.%rIt would have cut off at: [strtrunc(%0,45)])
 
|-
 
|-
|style="padding: 1em;border: 1px dashed #2f6fab;color: black;background-color: #f9f9f9;line-height: 1.25em;font-family: monospace;"|&cmd-idle me=$+idle *:think [ansi(hr,REPORT:)] [name(pmatch(%0))] has been idle [exptime(idle(%0))].
+
|<br />
 +
'''This code deletes a @doing from your list, using the reference number from +doing/list.'''
 +
|<br />
 +
'''Syntax: ''+doing/del #'''''
 
|-
 
|-
|Code by [[Petra]]
+
|colspan=2 style="padding: 1em;border: 1px dashed #2f6fab;color: black;background-color: #f9f9f9;line-height: 1.25em;font-family: monospace;"|&cmd-doing_del me=$+doing/del *:think ifelse(setr(0,elements(setr(1,v(txt-doing_list)),%0,|,|)),set(me,txt-doing_list:[elements(%q1,setdiff(lnum(add(words(%q1),1)),%0),|,|)]) You have removed "%q0" from your list of @doings.,That is not a number corresponding to an @doing in your list.)
 
|-
 
|-
 +
|colspan=2|Original random doing code by [[Haruspex]]; +doing and +doing/add modified and +doing/del and +doing/list added by [[Jai]].
 
|}
 
|}
 +
[[Category:Help]]
 +
__NOEDITSECTION__

Latest revision as of 04:03, 11 March 2014

Various snippets of code can make one's life easier (or more complicated), and this is where you can grab them for your character. Copy them from the page, paste them into your MU* client, make sure to @set me=!no_command, and enjoy!

Contents

Texting Code

This code is for sending IC text messages from a phone. You'll need all three attributes. Syntax: +text name=message
&cmd-text me=$+text *=*:think if(isdbref(locate(%#,*%0,Pp)),[if(lte(strlen(%1),160),[u(fun-text_send,%0,%1)],[u(fun-text_proc,%0,%1)])],"%0" doesn't seem to be a valid player. Please try again!)
&fun-text_proc me=[setq(0,%1)][setq(1,mid(%q0,0,160))][if(match(mid(%q0,160,1), ),[setq(0,mid(%q0,160,strlen(%q0)))],[setq(2,[strtrunc(%q1,sub(strlen(%q1),strlen(last(%q1))))])][setq(1,%q2)][setq(0,mid(%q0,strlen(%q2),strlen(%q0)))])][u(fun-text_send,%0,%q1)][if(strlen(%q0),u(fun-text_proc,%0,%q0))]
&fun-text_send me=[pemit(%#,You text to [name(*%0)]: %1)][pemit(num(*%0),You receive a text from %N: %1)]
Original code by Zack, modified by Jai.


Non-truncated +Who

This code replaces +who with a wider version which doesn't truncate the location information. Syntax: +who
&cmd-who me=$+who:@pemit me=%r[repeat(=,30)]>[center(The MASQUERADE,18, )]<[repeat(=,30)]%r [center(Player,18, )] Sex Alias [center(Idle,8, )][space(3)]Location[rjust(%xh%xyPlayer Count:%xc [words(setunion(lwho(),))],30, %xn)]%r [repeat(-,18)] [repeat(-,3)] [repeat(-,5)] [repeat(-,8)][space(3)][repeat(-,38)]%r [iter(setunion(lwho(),),[ljust(name(##),18)][center(ucstr(ljust(get_eval(##/sex),1)),5, )][center(get_eval(##/alias),5, )] [rjust(extract(exptime(idle(##)),1,2),8)][if(hasflag(##,staff),%b*%b,space(3))][if(match(where(##),#-1),%xrUnfindable%xn,name(where(##)))]%r)][repeat(=,80)]
Code by Devlin, with debugging assistance from Charles and suggested look-and-feel modifications from Bill


Directed +Where

This code works like +where, but for a specific person. Syntax: +where name
&cmd-where me=$+where *:think [ansi(hr,REPORT:)] [setq(0,pmatch(%0))][if(%q0,[name(%q0)] [if(hasflag(%q0,connect),[if(loc(%q0),is currently at: [name([loc(%q0)])],cannot currently be found.)],is not currently online.)],"[capstr(%0)]" does not match any player.)]
Original code by Petra, modified by Jai


Idle Time Checker

This code reports how long a specific person has been idle. Syntax: +idle name
&cmd-idle me=$+idle *:think [ansi(hr,REPORT:)] [setq(0,pmatch(%0))][if(%q0,[name(%q0)] [if(hasflag(%q0,connect),has been idle [exptime(idle(%0))].,is not currently online.)],"[capstr(%0)]" does not match any player.)]
Original code by Petra, modified by Jai


Connection Checker

This code tells you how long someone's been connected, or how long since they logged off. Syntax: +conn name
&cmd-connected me=$+conn *:think ansi(hr,REPORT:) [setq(0,pmatch(%0))][if(%q0,[name(%q0)] [if(hasflag(%q0,connect),has been connected for [writetime(conn(%0))].,has been disconnected since [timefmt($A $B $d% at $I:$M $P,connleft(%0))] %([writetime(sub(secs(),connleft(%0)))] ago.%))],"[capstr(%0)]" does not match any player.)]
Code by Petra, aided by Jai.


Desc Identifier

This code prepends the desc of the person you're looking at with a line identifying whose desc it is. Syntax: +l name
&cmd-look me=$+l *:@pemit me=[repeat(*,78)]%r[center(Desc of [name([num(%0)])],78)]%r[repeat(*,78)]%r;l %0
Code by Petra, with some awesome help refining it from Jai


Random @Doing Picker

This code sets an @doing chosen randomly from your list. Syntax: +doing
&cmd-doing me=$+doing:@doing/quiet [setr(0,pickrand(v(txt-doing_list),|))][pemit(me,@Doing set to: %q0)]

This code lists the @doings in your list.


Syntax: +doing/list

&cmd-doing_list me=$+doing/list:think [center(Doings,51,=)][setq(1,strlen(words(setq(0,v(txt-doing_list)),|)))]%r%b[iter(%q0,ifelse(lt(strlen(#@),%q1),0#@,#@). ##%r,|)][repeat(=,51)]

This code adds an @doing to your list of available @doings.


Syntax: +doing/add yourdoing

&cmd-doing_add me=$+doing/add *:think ifelse(lte(strlen(%0),45),set(me,txt-doing_list:[setunion(v(txt-doing_list),%0,|)]) The following new @doing was set: %0,That @doing is [setr(0,sub(strlen(%0),45))] character[if(eq(%q0,1),,s)] too long\, and has not been added.%rIt would have cut off at: [strtrunc(%0,45)])

This code deletes a @doing from your list, using the reference number from +doing/list.


Syntax: +doing/del #

&cmd-doing_del me=$+doing/del *:think ifelse(setr(0,elements(setr(1,v(txt-doing_list)),%0,|,|)),set(me,txt-doing_list:[elements(%q1,setdiff(lnum(add(words(%q1),1)),%0),|,|)]) You have removed "%q0" from your list of @doings.,That is not a number corresponding to an @doing in your list.)
Original random doing code by Haruspex; +doing and +doing/add modified and +doing/del and +doing/list added by Jai.