Function Snippet Machine
A machine that records and displays code snippets for various user-defined functions. Includes 29 function snippets.
Functions:
add(),
align(),
ansi(),
baseconv(),
capstr(),
center(),
condall(),
config(),
convsecs(),
dec(),
default(),
edit(),
elements(),
endtag(),
entrances(),
eq(),
extract(),
fdiv(),
filter(),
filterbool(),
first(),
firstof(),
foreach(),
get(),
grab(),
grepi(),
gt(),
hasflag(),
home(),
if(),
ifelse(),
inc(),
isdbref(),
itemize(),
iter(),
last(),
lattr(),
lcon(),
left(),
letq(),
lit(),
ljust(),
lmath(),
lnum(),
loc(),
lpos(),
lsearch(),
lt(),
lte(),
match(),
max(),
member(),
min(),
mul(),
name(),
nattr(),
neq(),
nlsearch(),
nspemit(),
objid(),
or(),
pickrand(),
pmatch(),
power(),
rand(),
randword(),
regedit(),
regeditall(),
regeditalli(),
repeat(),
rest(),
rjust(),
round(),
secs(),
setdiff(),
setq(),
setr(),
sort(),
space(),
sqrt(),
strfirstof(),
strlen(),
strmatch(),
sub(),
switch(),
tag(),
testlock(),
trim(),
u(),
ucstr(),
udefault(),
unique(),
v(),
val(),
visible(),
vsub(),
width(),
wildgrep(),
wildgrepi(),
words(),
wrap(),
xattr().
Compatibility:
PennMUSH.
Instructions
Copy and paste the below code into a compatible MUSH or MUX.
MUSHCode for Function Snippet Machine
@create Function Snippet Machine
@lock Function Snippet Machine==me
@set Function Snippet Machine=!NO_COMMAND
&ARCHIVE Function Snippet Machine=Contains the snippets.
&ARCHIVE`1 Function Snippet Machine=lsearch(all,type,players,start,rand(nlsearch(all,type,players)),count,1)
@set Function Snippet Machine/ARCHIVE`1=public
&ARCHIVE`1`CC Function Snippet Machine=* r:dbref:random_player
&ARCHIVE`1`CREATOR Function Snippet Machine=#11735:1172513110|Mercutio|1266604874
&ARCHIVE`1`DOC Function Snippet Machine=Returns a random playerdbref, without running into buffer problems on large databases - as one would with a randword() function.
&ARCHIVE`1`TITLE Function Snippet Machine=Random Player Picker
&ARCHIVE`12 Function Snippet Machine=foreach(#lambda/[lit(ansi(pickrand(f h i)[pickrand(r g b y c m w hx)],%0))],%0)
@set Function Snippet Machine/ARCHIVE`12=public
&ARCHIVE`12`CC Function Snippet Machine=text r:colored_text
&ARCHIVE`12`CREATOR Function Snippet Machine=#11735:1172513110|Mercutio|1268936347
&ARCHIVE`12`DOC Function Snippet Machine=It randomizes the color of every letter inside of the TEXT input. It even makes them flash... sometimes.
&ARCHIVE`12`TITLE Function Snippet Machine=Horrible Text-ansifier
&ARCHIVE`13 Function Snippet Machine=regeditall(regeditalli(%0,((?<!\\.)(\[\\.!?\]\\s+)(\[a-z\]))(\[a-z\]+),if(member(v(exceptionlist),$3$4),$1$4,ucstr($1)$4)),\\si(\\b|'),%bI$1)
@set Function Snippet Machine/ARCHIVE`13=public
&ARCHIVE`13`CC Function Snippet Machine=text r:capitalized_text
&ARCHIVE`13`CREATOR Function Snippet Machine=#11735:1172513110|Mercutio|1268937009
&ARCHIVE`13`DOC Function Snippet Machine=It takes in TEXT, then near-perfectly capitalizes after punctuation, and capitalizes 'i' at proper points. It will leave most 'smileys' alone however. Example: 'x.x' will remain 'x.x'. Note that it does NOT capilize the first sentence! Use capstr() for it, or place a . in front of the text, and then edit it out afterwards using trim(). Note that you can use `exceptionlist' to ignore certain words.
&ARCHIVE`13`TITLE Function Snippet Machine=Capitalizer
&ARCHIVE`14 Function Snippet Machine=[tag(a,xch_cmd="[ifelse(strlen(%1),%1,%0)]")]%0[endtag(A)]
@set Function Snippet Machine/ARCHIVE`14=public
&ARCHIVE`14`CC Function Snippet Machine=text:*:command r:clickabletext
&ARCHIVE`14`CREATOR Function Snippet Machine=#10010:1216593752|Minion|1268937839
&ARCHIVE`14`DOC Function Snippet Machine=Turns TEXT into a clickable link (for clients that support). If COMMAND is specified, it is used as the resulting command, otherwise <text> is used as the command.
&ARCHIVE`14`TITLE Function Snippet Machine=Command links for Pueblo
&ARCHIVE`15 Function Snippet Machine=[tag(a,href="[edit(ifelse(strlen(%1),%1,%0),&,&)]")]%0[endtag(A)]
@set Function Snippet Machine/ARCHIVE`15=public
&ARCHIVE`15`CC Function Snippet Machine=text:*:url r:clickabletext
&ARCHIVE`15`CREATOR Function Snippet Machine=#10010:1216593752|Minion|1268937847
&ARCHIVE`15`DOC Function Snippet Machine=Turns TEXT into a clickable link (for clients that support). If URL is specified, it is used as the resulting browser page request, otherwise <text> is used as the url.
&ARCHIVE`15`TITLE Function Snippet Machine=HTML links for Pueblo
&ARCHIVE`16 Function Snippet Machine=iter(wrap(%0,%1,setr(7,ifelse(%7,%7,%1))),[switch(#@,1,setq(1,%q7),[space(ifelse(%5,%5,0))][setq(1,%1)])]%3[switch(%2,c*,center(%i0,%q1),r*,rjust(%i0,%q1),ljust(%i0,%q1))]%4,%r,ifelse(%6,%6,%r))
@set Function Snippet Machine/ARCHIVE`16=public
&ARCHIVE`16`CC Function Snippet Machine=text:width:*:just:lefttxt:righttxt:hanging:osep:width1 qreg
&ARCHIVE`16`CREATOR Function Snippet Machine=#10010:1216593752|Minion|1269911970
&ARCHIVE`16`DOC Function Snippet Machine=PennMUSH version of MUX's 7-arg wrap() command. Wraps TEXT to WIDTH. JUST may be 'l', 'r', or 'c'. LEFTTXT and RIGHTTXT specify borders. HANGING specifies an optional number of spaces to insert on the left margin for any line that is not the first line. OSEP is the output separator, and it defaults to %%r. WIDTH1 is the width of the first line (default of <width>).
&ARCHIVE`16`TITLE Function Snippet Machine=MUX version of wrap()
&ARCHIVE`18 Function Snippet Machine=elements(%0,lmath(min,firstof(filterbool(#lambda/%%0,iter(%1,match(%0,%i0,%2),%2)),0)),%2)
@set Function Snippet Machine/ARCHIVE`18=public
&ARCHIVE`18`CC Function Snippet Machine=list:patternlist:*:delimiter
&ARCHIVE`18`CREATOR Function Snippet Machine=#10010:1216593752|Minion|1275927846
&ARCHIVE`18`DOC Function Snippet Machine=Extension of grab() which returns the first word in LIST which matches any of the patterns in PATTERNLIST. Both <list> and <patternlist> must use the same DELIMITER, if specified (defaults to space.)%R%RExample: listgrab(foo bar baz qux,ba* qu*) --> bar
&ARCHIVE`18`TITLE Function Snippet Machine=LISTGRAB
&ARCHIVE`19 Function Snippet Machine=switch(0,eq(setr(m,words(%0)),words(%1)),#-1,lmath(lt,%0),#-1,neq(last(%0),%2),last(%1),lt(0,setr(n,words(filter(#lambda/lte(%%0,%2),%0))),%qm),#-1,add(first(setr(y,extract(%1,%qn,2))),mul(fdiv(sub(%2,first(setr(x,extract(%0,%qn,2)))),lmath(sub,%qx)),lmath(sub,%qy))))
@set Function Snippet Machine/ARCHIVE`19=public
&ARCHIVE`19`CC Function Snippet Machine=xlist:ylist:x qreg
&ARCHIVE`19`CREATOR Function Snippet Machine=#10010:1216593752|Minion|1276498604
&ARCHIVE`19`DOC Function Snippet Machine=Given a strictly monotonically increasing XLIST and corresponding values in YLIST, returns a y value that would fall along an interpolation of the function at the given X.
&ARCHIVE`19`TITLE Function Snippet Machine=Interpolation Function
&ARCHIVE`21 Function Snippet Machine=repeat(%b%b__%b%b,%0)[iter(lnum(%1),%r%b[iter(lnum(%0),/[rjust(baseconv(add(mul(%i1,36),inc(mul(%i0,2))),10,36),2)]\\[switch(%i0,<[dec(%0)],__)],,)]%r%b[iter(lnum(%0),\\__/[rjust(switch(%i1,<[dec(%1)],switch(%i0,<[dec(%0)],baseconv(add(mul(%i1,36),mul(inc(%i0),2)),10,36))),2)],,)])]
@set Function Snippet Machine/ARCHIVE`21=public
&ARCHIVE`21`CC Function Snippet Machine=width:length r:hexmap
&ARCHIVE`21`CREATOR Function Snippet Machine=#11735:1172513110|Mercutio|1280095473
&ARCHIVE`21`DOC Function Snippet Machine=By giving the function a LENGTH and WIDTH argument, it will return a drawn hex-map, with base36 numbers to identify each hex. Do not go past a number of 1295!
&ARCHIVE`21`TITLE Function Snippet Machine=Hex Map Creator
&ARCHIVE`22 Function Snippet Machine=th iter(lcon(#2),iter(wildgrep(##,**,$*:*),nspemit(%#,align(40 80,[ljust(%i1,6)]:%i0,regedit(get(%i1/%i0),^\\$(.+?)(?<!\\\\):.*$,$1))),,%r))
@set Function Snippet Machine/ARCHIVE`22=public
&ARCHIVE`22`CC Function Snippet Machine=*
&ARCHIVE`22`CREATOR Function Snippet Machine=#8454:1007465045|Qa'toq|1282008706
&ARCHIVE`22`DOC Function Snippet Machine=just quote the function list into your client, it will then list all @commands (regexp or not) that are found in #2 (The Master Room)
&ARCHIVE`22`TITLE Function Snippet Machine=Globals Commands
&ARCHIVE`23 Function Snippet Machine=regeditall(sort(%0),\\b(\\w+)\\b( \\1\\b)*,%r$1: [words($0)])
@set Function Snippet Machine/ARCHIVE`23=public
&ARCHIVE`23`CC Function Snippet Machine=list r:visual-number-list
&ARCHIVE`23`CREATOR Function Snippet Machine=#11735:1172513110|Mercutio|1283309444
&ARCHIVE`23`DOC Function Snippet Machine=You put in a LIST, and in return will get a visual representation of how often each word in that list... appeared in the list.
&ARCHIVE`23`TITLE Function Snippet Machine=Words In List Counter
&ARCHIVE`24 Function Snippet Machine=round(fdiv(power(fdiv(add(1,sqrt(5)),2),%0),sqrt(5)),0)
@set Function Snippet Machine/ARCHIVE`24=public
&ARCHIVE`24`CC Function Snippet Machine=a:* r:FIBONACCI_NUMBER
&ARCHIVE`24`CREATOR Function Snippet Machine=#11735:1172513110|Mercutio|1285365768
&ARCHIVE`24`DOC Function Snippet Machine=Insert A to have the function return the FIBONACCI_NUMBER associated with it. It is an almost perfectly accurate estimate.%r%rAccuracy requires a higher float_precision than default in PennMUSH. 15 is a solid candidate. Note that, due to the limit of 32bit INT and the inaccuracy in floating point numbers, this function is only accurate until A~69
&ARCHIVE`24`TITLE Function Snippet Machine=Fibonacci Sequence Resolver
&ARCHIVE`26 Function Snippet Machine=filter(#lambda/match(home(\%0),loc(%0)),entrances(%L))
@set Function Snippet Machine/ARCHIVE`26=public
&ARCHIVE`26`CC Function Snippet Machine=exitDBref
&ARCHIVE`26`CREATOR Function Snippet Machine=#8454:1007465045|Qa'toq|1295407741
&ARCHIVE`26`DOC Function Snippet Machine=By giving the EXITDBREF, it will return you all the exits in the room it leads to - that returned to your current room.
&ARCHIVE`26`TITLE Function Snippet Machine=Opposite Exit
&ARCHIVE`27 Function Snippet Machine=letq(d,strfirstof(%1,%b),lmath(max,vsub(lpos(%0%qd,%qd),lpos(%qd%0,%qd))))
@set Function Snippet Machine/ARCHIVE`27=public
&ARCHIVE`27`CC Function Snippet Machine=list:*:delimiter r:int:length_of_longest_word func
&ARCHIVE`27`CREATOR Function Snippet Machine=#9814:1028393906|Jules|1316498159
@set Function Snippet Machine/ARCHIVE`27`CREATOR=no_command
&ARCHIVE`27`DOC Function Snippet Machine=O(1) function (6 calls) to get the length of the longest word in a list. Takes one to two arguments. LIST is a DELIMITER separated list of items. The delimiter defaults to space if not given or if null.
&ARCHIVE`27`TITLE Function Snippet Machine=O(1) Max Word Length
&ARCHIVE`28 Function Snippet Machine=elements(%0,lmatch(%1,%2,strfirstof(%3,%b)),strfirstof(%3,%b),strfirstof(%4,%b))
@set Function Snippet Machine/ARCHIVE`28=public
&ARCHIVE`28`CC Function Snippet Machine=values:columninfo:columnnames:delim:osep r:columnvalues
&ARCHIVE`28`CREATOR Function Snippet Machine=#11735:1172513110|Mercutio|1374723708
&ARCHIVE`28`DOC Function Snippet Machine=This function allows you to grab the values in a delimited VALUES list, by giving the function a COLUMNINFO for its second attribute that contains the aliases or names of the locations of the values. The COLUMNNAMES list then withdraws the values found at the locations in the VALUES list, corresponding to the names found in COLUMNINFO. The DELIM item is the delimiter, and the OSEP is the outseperator.%r%rExample: u(archive`28,-5 6 88 3,DEX AGI MAG FIRE,MAG DEX) --> 88 -5 %r%r!! This uses the lmatch() function found below in snippet 29 !!
&ARCHIVE`28`TITLE Function Snippet Machine=A_GRAB
&ARCHIVE`29 Function Snippet Machine=iter(%1,match(%0,%i0,strfirstof(%2,%b)),strfirstof(%2,%b),strfirstof(%3,%b))
&ARCHIVE`29`CC Function Snippet Machine=originlist:searchitemlist:delim:osep r:foundlist
&ARCHIVE`29`CREATOR Function Snippet Machine=#11735:1172513110|Mercutio|1374723904
&ARCHIVE`29`DOC Function Snippet Machine=This function compares SEARCHITEMLIST to ORIGINLIST, and returns the locations of the found items from SEARCHITEMLIST in ORIGINLIST as FOUNDLIST. The DELIM and OSEP are delimiter and Out Seperator.
&ARCHIVE`29`TITLE Function Snippet Machine=LMATCH
&ARCHIVE`5 Function Snippet Machine=first(setdiff(lnum(1,inc(lmath(max,%0))),%0))
@set Function Snippet Machine/ARCHIVE`5=public
&ARCHIVE`5`CC Function Snippet Machine=number_list r:integer:next_free func
&ARCHIVE`5`CREATOR Function Snippet Machine=#6388:960071784|Cheetah|1268677743
&ARCHIVE`5`DOC Function Snippet Machine=Given a list of integers in NUMBER_LIST, returns the next free number. This either means the lowest positive number not present in the list, or the number after the highest number in the list, whichever is lowest.
&ARCHIVE`5`TITLE Function Snippet Machine=Next number
&ARCHIVE`6 Function Snippet Machine=sort(setdiff(unique(sort(iter(%0,lnum(max([first(%i0,-)],[last(%i0,-)]),min([first(%i0,-)],[last(%i0,-)]))))),if(%1,THISSNIPPETATTRIBUTE(%1))),n)
@set Function Snippet Machine/ARCHIVE`6=public
&ARCHIVE`6`CC Function Snippet Machine=numberrange-list1:*:numberrange-list2 r:list:numbers
&ARCHIVE`6`CREATOR Function Snippet Machine=#11735:1172513110|Mercutio|1268679896
&ARCHIVE`6`DOC Function Snippet Machine=Takes in two lists in the form of: '4-6 9-10 30 35-38', which creates a number list based on NUMBERRANGE-LIST1, and then removes numbers based on NUMBERRANGE-LIST2. Return value of example: 4 5 6 9 10 30 35 36 37 38
&ARCHIVE`6`TITLE Function Snippet Machine=Number Range Expander
@set Function Snippet Machine=ARCHIVE`7:[ansi(hc,ATTR1)]: trim\(fold\(me/[ansi(hc,ATTR2)]\,unique\(sort\(\%0\,n\)\)\)\)%r%r[ansi(hc,ATTR2)]: if\(eq\(\%1\,inc\(last\(last\(\%0\)\,-\)\)\)\,strcat\(extract\(\%0\,1\,dec\(words\(\%0\)\)\)\,\%b\,first\(last\(\%0\)\,-\)\,-\,\%1\)\,\%0 \%1\)
@set Function Snippet Machine/ARCHIVE`7=public
&ARCHIVE`7`CC Function Snippet Machine=numberlist r:collapsed-numberlist
&ARCHIVE`7`CREATOR Function Snippet Machine=#11735:1172513110|Mercutio|1268931542
&ARCHIVE`7`DOC Function Snippet Machine=Takes in a list of numbers, like '1 2 3 4 5 10 99 100 101 8 9'NUMBERLIST and returns the COLLAPSED-NUMBERLIST '1-5 8-10 99-101'.
&ARCHIVE`7`TITLE Function Snippet Machine=Integer Squish
&CMD Function Snippet Machine=Contains the commands.
&CMD`ADD Function Snippet Machine=$+snippet/add *=*/*:@@ {%0: Title|%1: Snippet DBref|%2: Snippet Base Attribute} ; @break u(fn`is`atmaxattrs)=@pemit %#=u(fn`msg,fulldatabase) ; @assert lt(v(data`titlelen`min),strlen(%0),v(data`titlelen`max))=@pemit %#=u(fn`msg,longtitle) ; @break setr(T,u(fn`is`existingtitle,%0))=@pemit %#=u(fn`msg,titleexists,%qT) ; @assert visible(%!,setr(O,switch(%1,me,%#,%1))/%2)=@pemit %#=u(fn`msg,cannotsee) ; @break setr(E,u(fn`is`exactsamecode,%qD))=@pemit %#=u(fn`msg`exactsamecode,%qE) ; @assert lt(v(data`snippetlen`min),strlen(setr(S,get(%qO/%2))),v(data`snippetlen`max))=@pemit %#=u(fn`msg,badsnippetlen) ; @assert setr(C,get(%qO/%2`cc))=@pemit %#=u(fn`msg,nocallingconvention) ; @assert setr(D,get(%qO/%2`doc))=@pemit %#=u(fn`msg,nodoc) ; @set me=[setr(A,archive`[setr(N,inc(u(fn`get`lastsnippetnum)))])]:%qS ; @set me=%qA`cc:%qC ; @set me=%qA`doc:%qD ; @set me=%qA`creator:%:|%N|[secs()] ; @set me=%qA`title:%0 ; @pemit %#=u(fn`msg,snippetadded,%qN,%0) ; &data`lastnum me=inc(v(data`lastnum))
&CMD`DEL Function Snippet Machine=$+snippet/del *:@@ {%0: Snippet ID} ; @assert setr(I,rest(u(fn`snippetfind,%0),`))=@pemit %#=u(fn`msg,nosuchsnippet) ; @assert u(fn`is`abletomod,%qI,%:)=@pemit %#=u(fn`msg,cannotmod) ; @wipe me/archive`%qI ; @pemit %#=u(fn`msg,snippetdeleted,%qI)
&CMD`HELP Function Snippet Machine=$+snippet/help:@pemit %#=u(fn`display`help)
&CMD`LIST Function Snippet Machine=$^\+snippet(?\:/list)?$:@dolist header [sort(lattr(me/archive`),m)] footer=@pemit %#=u(fn`display`shortsnip,##)
@set Function Snippet Machine/CMD`LIST=regexp
&CMD`OVERWRITE Function Snippet Machine=$+snippet/overwrite *=*/*:@@ {%0: Snippet Number|%1: Snippet DBref|%2: Snippet Base Attribute} ; @assert setr(I,u(fn`snippetfind,%0))=@pemit %#=u(fn`msg,nosuchsnippet) ; @assert eq(words(%qI),1)=@pemit %#=u(fn`msg,ambigsnippet,%qI) ; @assert u(fn`is`owner,last(%qI,`),%#)=@pemit %#=u(fn`msg,youdontown); @assert visible(%!,setr(O,switch(%1,me,%#,%1))/%2)=@pemit %#=u(fn`msg,cannotsee) ; @break setr(E,u(fn`is`exactsamecode,%qD))=@pemit %#=u(fn`msg`exactsamecode,%qE) ; @assert lt(v(data`snippetlen`min),strlen(setr(S,get(%qO/%2))),v(data`snippetlen`max))=@pemit %#=u(fn`msg,badsnippetlen) ; @assert setr(C,get(%qO/%2`cc))=@pemit %#=u(fn`msg,nocallingconvention) ; @assert setr(D,get(%qO/%2`doc))=@pemit %#=u(fn`msg,nodoc) ; @set me=%qi:%qS ; @set me=%qi`cc:%qC ; @set me=%qi`doc:%qD ; @set me=%qi`creator:%:|%N|[secs()] ; @pemit %#=u(fn`msg,snippetoverwritten,last(%qi,`))
&CMD`SEARCH Function Snippet Machine=$+snippet/search *:@@ {%0: Search wildcard} ; @pemit %#=u(fn`display`search,%0)
&CMD`VIEW Function Snippet Machine=$^\+snippet(?\:/view)?\s+(.+)$:@@ {%1: Snippet ID, or wildcard for title.} ;@assert setr(I,u(fn`snippetfind,%1))=@pemit %#=u(fn`msg,nosuchsnippet) ; @assert eq(words(%qI),1)=@pemit %#=u(fn`msg,ambigsnippet,%qI) ; @pemit %#=u(fn`display`snippet,extract(%qI,2,1,`))
@set Function Snippet Machine/CMD`VIEW=regexp
&DATA Function Snippet Machine=Contains static data. Can be seen as the system's "settings".
&DATA`DOCOBJ Function Snippet Machine=#10120
&DATA`LASTNUM Function Snippet Machine=29
&DATA`SNIPPETLEN Function Snippet Machine=Defines the min and max length of a code snippet.
&DATA`SNIPPETLEN`MAX Function Snippet Machine=300
&DATA`SNIPPETLEN`MIN Function Snippet Machine=5
&DATA`TITLELEN Function Snippet Machine=Defines the min and max length of a code title.
&DATA`TITLELEN`MAX Function Snippet Machine=30
&DATA`TITLELEN`MIN Function Snippet Machine=5
&DESCRIBE Function Snippet Machine=A tool for submitting and viewing function-snippets for code - for the 'Snippet Of The Day' project, to potentially replace 'Function Of the Day'.%r%r+snippet/help to start!
@set Function Snippet Machine/DESCRIBE=no_command visual prefixmatch public nearby
&FN Function Snippet Machine=Contains functions.
&FN`DISPLAY Function Snippet Machine=Display functions.
&FN`DISPLAY`HELP Function Snippet Machine=.[center(> Snippet Help <,sub(width(%#),2),-)].%r%b[ansi(hw,Commands)]:%r%r%b[ansi(hc,+snippet/add)] <[ansi(hc,Title)]>=<[ansi(hc,Object)]>/<[ansi(hc,Attribute)]>%r[align(4 [sub(width(%#),5)],,{Will add a snippet with the title indicated, using the attribute you give as the snippet. It is suggested this object is @set to VISUAL. This command will not evaluate your snippet, mind you - and the command also requires you to add a `cc and `doc subattribute, as defined in '[ansi(hc,docf/help)]'!})]%r%b[ansi(hc,+snippet/overwrite)] <[ansi(hc,Snippet-title Or Number)]>=<[ansi(hc,Object)]>/<[ansi(hc,Attribute)]>%r[align(4 [sub(width(%#),5)],,{Overwrites one of your own snippets with an updated version.})]%r%b[ansi(hc,+snippet/del)] <[ansi(hc,Snippet-title or number)]>%r[align(4 [sub(width(%#),5)],,{Will remove the snippet, assuming you are staff or the owner.})]%r%b[ansi(hc,+snippet/search)] <[ansi(hc,wildcard)]>%r[align(4 [sub(width(%#),5)],,{find you snippets which match your wildcard in any of their fields.})]%r%b[ansi(hc,+snippet/view)] <[ansi(hc,Snippet-title or number)]>%r[align(4 [sub(width(%#),5)],,{Will display the snippet to you.})]%r%b[ansi(hc,+snippet/list)]%r[align(4 [sub(width(%#),5)],,{Lists all snippets, with a small description. Can get big!})]%r%b[ansi(hc,+snippet/help)]%r[align(4 [sub(width(%#),5)],,{This file, obviously!})]%r'[repeat(-,sub(width(%#),2))]'
&FN`DISPLAY`SEARCH Function Snippet Machine=setq(S,wildgrepi(me,archive`,%0))[setq(C,wildgrepi(me,archive`*`cc,%0))][setq(P,wildgrepi(me,archive`*`creator,%0))][setq(D,wildgrepi(me,archive`*`doc,%0))][setq(T,wildgrepi(me,archive`*`title,%0))][setq(u,fn`display`search`short)][@@(That was no fun to prep - but makes coding easier :/)][condall(%qS,u(%qU,%qS,Snippet,),%qT,u(%qU,%qT,Title,title),%qC,u(%qU,%qC,Calling Convention,cc),%qD,u(%qU,%qD,Description,doc),%qP,u(%qU,%qP,Creator,creator),No results found!)]
&FN`DISPLAY`SEARCH`SHORT Function Snippet Machine=if(eq(strlen(%0),[strlen(repeat(-,99999))]),%1: Too many found!,%rFound ([words(%0)]) item[switch(words(%0),1,,s)] by [ansi(hw,%1)]:%r--> [iter(%0,first(rest(%i0,`),`),,%r-->%b)]%r)
&FN`DISPLAY`SHORTSNIP Function Snippet Machine=switch(%0,footer,'[repeat(-,sub(width(%#),2))]',header,.[center(< [ansi(hw,List of Snippets)] >,sub(width(%#),2),-)].,[ansi(hg,rjust(rest(%0,`),4,0))]: [setr(T,[ljust(([u(fn`get`snippet`ownername,rest(%0,`))]),26)] [ansi(hw,u(fn`get`snippet`title,rest(%0,`)))])]:%r--> [left(setr(D,u(fn`get`snippet`desc,rest(%0,`))),sub(width(%#),5))][if(gt(strlen(%qD),sub(width(%#),5)),~)])
&FN`DISPLAY`SNIPPET Function Snippet Machine=.[center(< [ansi(hw,Snippet #%0)] >,sub(width(%#),2),-)].%r[center(< [ansi(hw,u(fn`get`snippet`title,%0))] >,width(%#),-)]%r[u(fn`get`snippet,%0)]%r[center(< [ansi(hw,Information)] >,width(%#),-)]%r[u(fn`get`doc,%!,archive`%0,1)]%r'[center(< By [ansi(g,if(isdbref(u(fn`get`snippet`owner,%0)),name(u(fn`get`snippet`owner,%0)) \([u(fn`get`snippet`owner,%0)]\),u(fn`get`snippet`owner,%0)))] on [ansi(g,convsecs(u(fn`get`snippet`time,%0)))] >,sub(width(%#),2),-)]'
&FN`GET Function Snippet Machine=Gets information.
&FN`GET`DOC Function Snippet Machine=u(v(data`docobj)/fun_document_mortal,%0,%1,%2)
&FN`GET`LASTSNIPPETNUM Function Snippet Machine=v(data`lastnum)
&FN`GET`NEXTSNIPPETNUM Function Snippet Machine=first(setdiff(lnum(1,inc(lmath(max,edit(lattr(me/archive`),ARCHIVE`,)))),%0))
&FN`GET`RANDOMSNIPPETID Function Snippet Machine=xattr(me/archive`,rand(nattr(me/archive`)),1)
&FN`GET`SNIPPET Function Snippet Machine=default(me/archive`%0,#-1 NO SUCH SNIPPET ID)
&FN`GET`SNIPPET`CC Function Snippet Machine=default(me/archive`%0`CC,#-1 NO SUCH SNIPPET ID OR CALLING CONVENTION)
&FN`GET`SNIPPET`DESC Function Snippet Machine=default(me/archive`%0`DOC,#-1 NO SUCH SNIPPET ID OR DESCRIPTION)
&FN`GET`SNIPPET`OWNER Function Snippet Machine=firstof(pmatch(extract(get(me/archive`%0`creator),1,1,|)),extract(get(me/archive`%0`creator),2,1,|),#-1 NO SUCH SNIPPET ID OR NO OWNER DEFINED)
&FN`GET`SNIPPET`OWNERNAME Function Snippet Machine=firstof(extract(get(me/archive`%0`creator),2,1,|),#-1 NO SUCH SNIPPET ID OR NO OWNER DEFINED)
&FN`GET`SNIPPET`TIME Function Snippet Machine=last(default(me/archive`%0`creator,#-1 NO SUCH SNIPPET ID OR DESCRIPTION),|)
&FN`GET`SNIPPET`TITLE Function Snippet Machine=default(me/archive`%0`title,#-1 NO SUCH SNIPPET ID OR TITLE)
&FN`IS Function Snippet Machine=Returns boolean values.
&FN`IS`ABLETOMOD Function Snippet Machine=or(u(fn`is`staff,%1),u(fn`is`owner,%0,%1))
&FN`IS`ATMAXATTRS Function Snippet Machine=eq(config(max_attrs_per_obj),add(nattr(me),5))
&FN`IS`EXACTSAMECODE Function Snippet Machine=grepi(me,archive`,%0)
&FN`IS`EXISTINGTITLE Function Snippet Machine=grepi(me,archive`*`title,%0)
&FN`IS`OWNER Function Snippet Machine=strmatch(first(v(archive`%0`creator),|),objid(%1))
&FN`IS`STAFF Function Snippet Machine=or(switch([isstaff(%0)],#-1 FUNCTION*,hasflag(%0,Wr),#$),testlock($%!,%0))
&FN`MSG Function Snippet Machine=[ansi(hw,SNIPPET>)] [udefault(me/msg`%0,%0,%:,%1,%2,%3,%4,%5,%6,%7,%8,%9)]
&FN`SNIPPET Function Snippet Machine=
&FN`SNIPPETFIND Function Snippet Machine=firstof(lattr(me/archive`[val(%0)]),edit(wildgrepi(me,archive`*`title,%0),`TITLE,),#-1 NO SUCH SNIPPET)
&MSG Function Snippet Machine=Contains the messages to be used by fn`msg.
&MSG`AMBIGSNIPPET Function Snippet Machine=Ambiguous snippet match. The following ones matched: [itemize(iter(%1,extract(%i0,2,1,`)))].
&MSG`BADSNIPPETLEN Function Snippet Machine=That is an inappropiate length to your snippet. Try to keep it between [v(data`snippetlen`min)] and [v(data`snippetlen`max)] characters!
&MSG`CANNOTMOD Function Snippet Machine=Sorry. You do not have the permissions required to modify that snippet.
&MSG`CANNOTSEE Function Snippet Machine=Sorry, I cannot see (anything in) that attribute. Are you sure you have set the object, or the attribute (and everything under it) set VISUAL?
&MSG`EXACTSAMECODE Function Snippet Machine=Sorry, but the exact same code was found in code snippet #[last(%1,`)]! If it is yours, use [ansi(hw,+snippet/del)] to remove it, and add then proceeed to add the fixed version anew.
&MSG`FULLDATABASE Function Snippet Machine=We're sorry, the database is full! No more code-snippets can be added.
&MSG`LONGTITLE Function Snippet Machine=That title is too long. Try to keep it between [v(data`titlelen`min)] and [v(data`titlelen`max)] characters!
&MSG`NOCALLINGCONVENTION Function Snippet Machine=No calling convention defined, or it is not VISUAL. Please use &[ansi(hw,<)]yoursnippetattribute[ansi(hw,>)]`cc [ansi(hw,<)]object[ansi(hw,>)]=something - to define your calling convention. See 'docf/help' and 'docf/syntax' for help!
&MSG`NODESC Function Snippet Machine=No function documentation defined, or it is not VISUAL. Please use &[ansi(hw,<)]yoursnippetattribute[ansi(hw,>)]`doc [ansi(hw,<)]object[ansi(hw,>)]=howyourcodeworks - to define your calling convention. See 'docf/help' for help!
&MSG`NOSUCHSNIPPET Function Snippet Machine=That is not a valid Snippet ID, or title. Please check +snippet/list.
&MSG`SNIPPETADDED Function Snippet Machine=A snippet was added with the title '%2' under the ID '%1'.
&MSG`SNIPPETDELETED Function Snippet Machine=Snippet #%1 was deleted.
&MSG`SNIPPETOVERWRITTEN Function Snippet Machine=Your snippet '[u(fn`get`snippet`title,%1)]' (%1) was overwritten.
&MSG`TITLEEXISTS Function Snippet Machine=Sorry, that title already is taken by snippet #[extract(%1,2,1,`)].
&MSG`YOUDONTOWN Function Snippet Machine=You cannot change that, as you do not own that.
look Function Snippet Machine
@lock Function Snippet Machine==me
@set Function Snippet Machine=!NO_COMMAND
&ARCHIVE Function Snippet Machine=Contains the snippets.
&ARCHIVE`1 Function Snippet Machine=lsearch(all,type,players,start,rand(nlsearch(all,type,players)),count,1)
@set Function Snippet Machine/ARCHIVE`1=public
&ARCHIVE`1`CC Function Snippet Machine=* r:dbref:random_player
&ARCHIVE`1`CREATOR Function Snippet Machine=#11735:1172513110|Mercutio|1266604874
&ARCHIVE`1`DOC Function Snippet Machine=Returns a random playerdbref, without running into buffer problems on large databases - as one would with a randword() function.
&ARCHIVE`1`TITLE Function Snippet Machine=Random Player Picker
&ARCHIVE`12 Function Snippet Machine=foreach(#lambda/[lit(ansi(pickrand(f h i)[pickrand(r g b y c m w hx)],%0))],%0)
@set Function Snippet Machine/ARCHIVE`12=public
&ARCHIVE`12`CC Function Snippet Machine=text r:colored_text
&ARCHIVE`12`CREATOR Function Snippet Machine=#11735:1172513110|Mercutio|1268936347
&ARCHIVE`12`DOC Function Snippet Machine=It randomizes the color of every letter inside of the TEXT input. It even makes them flash... sometimes.
&ARCHIVE`12`TITLE Function Snippet Machine=Horrible Text-ansifier
&ARCHIVE`13 Function Snippet Machine=regeditall(regeditalli(%0,((?<!\\.)(\[\\.!?\]\\s+)(\[a-z\]))(\[a-z\]+),if(member(v(exceptionlist),$3$4),$1$4,ucstr($1)$4)),\\si(\\b|'),%bI$1)
@set Function Snippet Machine/ARCHIVE`13=public
&ARCHIVE`13`CC Function Snippet Machine=text r:capitalized_text
&ARCHIVE`13`CREATOR Function Snippet Machine=#11735:1172513110|Mercutio|1268937009
&ARCHIVE`13`DOC Function Snippet Machine=It takes in TEXT, then near-perfectly capitalizes after punctuation, and capitalizes 'i' at proper points. It will leave most 'smileys' alone however. Example: 'x.x' will remain 'x.x'. Note that it does NOT capilize the first sentence! Use capstr() for it, or place a . in front of the text, and then edit it out afterwards using trim(). Note that you can use `exceptionlist' to ignore certain words.
&ARCHIVE`13`TITLE Function Snippet Machine=Capitalizer
&ARCHIVE`14 Function Snippet Machine=[tag(a,xch_cmd="[ifelse(strlen(%1),%1,%0)]")]%0[endtag(A)]
@set Function Snippet Machine/ARCHIVE`14=public
&ARCHIVE`14`CC Function Snippet Machine=text:*:command r:clickabletext
&ARCHIVE`14`CREATOR Function Snippet Machine=#10010:1216593752|Minion|1268937839
&ARCHIVE`14`DOC Function Snippet Machine=Turns TEXT into a clickable link (for clients that support). If COMMAND is specified, it is used as the resulting command, otherwise <text> is used as the command.
&ARCHIVE`14`TITLE Function Snippet Machine=Command links for Pueblo
&ARCHIVE`15 Function Snippet Machine=[tag(a,href="[edit(ifelse(strlen(%1),%1,%0),&,&)]")]%0[endtag(A)]
@set Function Snippet Machine/ARCHIVE`15=public
&ARCHIVE`15`CC Function Snippet Machine=text:*:url r:clickabletext
&ARCHIVE`15`CREATOR Function Snippet Machine=#10010:1216593752|Minion|1268937847
&ARCHIVE`15`DOC Function Snippet Machine=Turns TEXT into a clickable link (for clients that support). If URL is specified, it is used as the resulting browser page request, otherwise <text> is used as the url.
&ARCHIVE`15`TITLE Function Snippet Machine=HTML links for Pueblo
&ARCHIVE`16 Function Snippet Machine=iter(wrap(%0,%1,setr(7,ifelse(%7,%7,%1))),[switch(#@,1,setq(1,%q7),[space(ifelse(%5,%5,0))][setq(1,%1)])]%3[switch(%2,c*,center(%i0,%q1),r*,rjust(%i0,%q1),ljust(%i0,%q1))]%4,%r,ifelse(%6,%6,%r))
@set Function Snippet Machine/ARCHIVE`16=public
&ARCHIVE`16`CC Function Snippet Machine=text:width:*:just:lefttxt:righttxt:hanging:osep:width1 qreg
&ARCHIVE`16`CREATOR Function Snippet Machine=#10010:1216593752|Minion|1269911970
&ARCHIVE`16`DOC Function Snippet Machine=PennMUSH version of MUX's 7-arg wrap() command. Wraps TEXT to WIDTH. JUST may be 'l', 'r', or 'c'. LEFTTXT and RIGHTTXT specify borders. HANGING specifies an optional number of spaces to insert on the left margin for any line that is not the first line. OSEP is the output separator, and it defaults to %%r. WIDTH1 is the width of the first line (default of <width>).
&ARCHIVE`16`TITLE Function Snippet Machine=MUX version of wrap()
&ARCHIVE`18 Function Snippet Machine=elements(%0,lmath(min,firstof(filterbool(#lambda/%%0,iter(%1,match(%0,%i0,%2),%2)),0)),%2)
@set Function Snippet Machine/ARCHIVE`18=public
&ARCHIVE`18`CC Function Snippet Machine=list:patternlist:*:delimiter
&ARCHIVE`18`CREATOR Function Snippet Machine=#10010:1216593752|Minion|1275927846
&ARCHIVE`18`DOC Function Snippet Machine=Extension of grab() which returns the first word in LIST which matches any of the patterns in PATTERNLIST. Both <list> and <patternlist> must use the same DELIMITER, if specified (defaults to space.)%R%RExample: listgrab(foo bar baz qux,ba* qu*) --> bar
&ARCHIVE`18`TITLE Function Snippet Machine=LISTGRAB
&ARCHIVE`19 Function Snippet Machine=switch(0,eq(setr(m,words(%0)),words(%1)),#-1,lmath(lt,%0),#-1,neq(last(%0),%2),last(%1),lt(0,setr(n,words(filter(#lambda/lte(%%0,%2),%0))),%qm),#-1,add(first(setr(y,extract(%1,%qn,2))),mul(fdiv(sub(%2,first(setr(x,extract(%0,%qn,2)))),lmath(sub,%qx)),lmath(sub,%qy))))
@set Function Snippet Machine/ARCHIVE`19=public
&ARCHIVE`19`CC Function Snippet Machine=xlist:ylist:x qreg
&ARCHIVE`19`CREATOR Function Snippet Machine=#10010:1216593752|Minion|1276498604
&ARCHIVE`19`DOC Function Snippet Machine=Given a strictly monotonically increasing XLIST and corresponding values in YLIST, returns a y value that would fall along an interpolation of the function at the given X.
&ARCHIVE`19`TITLE Function Snippet Machine=Interpolation Function
&ARCHIVE`21 Function Snippet Machine=repeat(%b%b__%b%b,%0)[iter(lnum(%1),%r%b[iter(lnum(%0),/[rjust(baseconv(add(mul(%i1,36),inc(mul(%i0,2))),10,36),2)]\\[switch(%i0,<[dec(%0)],__)],,)]%r%b[iter(lnum(%0),\\__/[rjust(switch(%i1,<[dec(%1)],switch(%i0,<[dec(%0)],baseconv(add(mul(%i1,36),mul(inc(%i0),2)),10,36))),2)],,)])]
@set Function Snippet Machine/ARCHIVE`21=public
&ARCHIVE`21`CC Function Snippet Machine=width:length r:hexmap
&ARCHIVE`21`CREATOR Function Snippet Machine=#11735:1172513110|Mercutio|1280095473
&ARCHIVE`21`DOC Function Snippet Machine=By giving the function a LENGTH and WIDTH argument, it will return a drawn hex-map, with base36 numbers to identify each hex. Do not go past a number of 1295!
&ARCHIVE`21`TITLE Function Snippet Machine=Hex Map Creator
&ARCHIVE`22 Function Snippet Machine=th iter(lcon(#2),iter(wildgrep(##,**,$*:*),nspemit(%#,align(40 80,[ljust(%i1,6)]:%i0,regedit(get(%i1/%i0),^\\$(.+?)(?<!\\\\):.*$,$1))),,%r))
@set Function Snippet Machine/ARCHIVE`22=public
&ARCHIVE`22`CC Function Snippet Machine=*
&ARCHIVE`22`CREATOR Function Snippet Machine=#8454:1007465045|Qa'toq|1282008706
&ARCHIVE`22`DOC Function Snippet Machine=just quote the function list into your client, it will then list all @commands (regexp or not) that are found in #2 (The Master Room)
&ARCHIVE`22`TITLE Function Snippet Machine=Globals Commands
&ARCHIVE`23 Function Snippet Machine=regeditall(sort(%0),\\b(\\w+)\\b( \\1\\b)*,%r$1: [words($0)])
@set Function Snippet Machine/ARCHIVE`23=public
&ARCHIVE`23`CC Function Snippet Machine=list r:visual-number-list
&ARCHIVE`23`CREATOR Function Snippet Machine=#11735:1172513110|Mercutio|1283309444
&ARCHIVE`23`DOC Function Snippet Machine=You put in a LIST, and in return will get a visual representation of how often each word in that list... appeared in the list.
&ARCHIVE`23`TITLE Function Snippet Machine=Words In List Counter
&ARCHIVE`24 Function Snippet Machine=round(fdiv(power(fdiv(add(1,sqrt(5)),2),%0),sqrt(5)),0)
@set Function Snippet Machine/ARCHIVE`24=public
&ARCHIVE`24`CC Function Snippet Machine=a:* r:FIBONACCI_NUMBER
&ARCHIVE`24`CREATOR Function Snippet Machine=#11735:1172513110|Mercutio|1285365768
&ARCHIVE`24`DOC Function Snippet Machine=Insert A to have the function return the FIBONACCI_NUMBER associated with it. It is an almost perfectly accurate estimate.%r%rAccuracy requires a higher float_precision than default in PennMUSH. 15 is a solid candidate. Note that, due to the limit of 32bit INT and the inaccuracy in floating point numbers, this function is only accurate until A~69
&ARCHIVE`24`TITLE Function Snippet Machine=Fibonacci Sequence Resolver
&ARCHIVE`26 Function Snippet Machine=filter(#lambda/match(home(\%0),loc(%0)),entrances(%L))
@set Function Snippet Machine/ARCHIVE`26=public
&ARCHIVE`26`CC Function Snippet Machine=exitDBref
&ARCHIVE`26`CREATOR Function Snippet Machine=#8454:1007465045|Qa'toq|1295407741
&ARCHIVE`26`DOC Function Snippet Machine=By giving the EXITDBREF, it will return you all the exits in the room it leads to - that returned to your current room.
&ARCHIVE`26`TITLE Function Snippet Machine=Opposite Exit
&ARCHIVE`27 Function Snippet Machine=letq(d,strfirstof(%1,%b),lmath(max,vsub(lpos(%0%qd,%qd),lpos(%qd%0,%qd))))
@set Function Snippet Machine/ARCHIVE`27=public
&ARCHIVE`27`CC Function Snippet Machine=list:*:delimiter r:int:length_of_longest_word func
&ARCHIVE`27`CREATOR Function Snippet Machine=#9814:1028393906|Jules|1316498159
@set Function Snippet Machine/ARCHIVE`27`CREATOR=no_command
&ARCHIVE`27`DOC Function Snippet Machine=O(1) function (6 calls) to get the length of the longest word in a list. Takes one to two arguments. LIST is a DELIMITER separated list of items. The delimiter defaults to space if not given or if null.
&ARCHIVE`27`TITLE Function Snippet Machine=O(1) Max Word Length
&ARCHIVE`28 Function Snippet Machine=elements(%0,lmatch(%1,%2,strfirstof(%3,%b)),strfirstof(%3,%b),strfirstof(%4,%b))
@set Function Snippet Machine/ARCHIVE`28=public
&ARCHIVE`28`CC Function Snippet Machine=values:columninfo:columnnames:delim:osep r:columnvalues
&ARCHIVE`28`CREATOR Function Snippet Machine=#11735:1172513110|Mercutio|1374723708
&ARCHIVE`28`DOC Function Snippet Machine=This function allows you to grab the values in a delimited VALUES list, by giving the function a COLUMNINFO for its second attribute that contains the aliases or names of the locations of the values. The COLUMNNAMES list then withdraws the values found at the locations in the VALUES list, corresponding to the names found in COLUMNINFO. The DELIM item is the delimiter, and the OSEP is the outseperator.%r%rExample: u(archive`28,-5 6 88 3,DEX AGI MAG FIRE,MAG DEX) --> 88 -5 %r%r!! This uses the lmatch() function found below in snippet 29 !!
&ARCHIVE`28`TITLE Function Snippet Machine=A_GRAB
&ARCHIVE`29 Function Snippet Machine=iter(%1,match(%0,%i0,strfirstof(%2,%b)),strfirstof(%2,%b),strfirstof(%3,%b))
&ARCHIVE`29`CC Function Snippet Machine=originlist:searchitemlist:delim:osep r:foundlist
&ARCHIVE`29`CREATOR Function Snippet Machine=#11735:1172513110|Mercutio|1374723904
&ARCHIVE`29`DOC Function Snippet Machine=This function compares SEARCHITEMLIST to ORIGINLIST, and returns the locations of the found items from SEARCHITEMLIST in ORIGINLIST as FOUNDLIST. The DELIM and OSEP are delimiter and Out Seperator.
&ARCHIVE`29`TITLE Function Snippet Machine=LMATCH
&ARCHIVE`5 Function Snippet Machine=first(setdiff(lnum(1,inc(lmath(max,%0))),%0))
@set Function Snippet Machine/ARCHIVE`5=public
&ARCHIVE`5`CC Function Snippet Machine=number_list r:integer:next_free func
&ARCHIVE`5`CREATOR Function Snippet Machine=#6388:960071784|Cheetah|1268677743
&ARCHIVE`5`DOC Function Snippet Machine=Given a list of integers in NUMBER_LIST, returns the next free number. This either means the lowest positive number not present in the list, or the number after the highest number in the list, whichever is lowest.
&ARCHIVE`5`TITLE Function Snippet Machine=Next number
&ARCHIVE`6 Function Snippet Machine=sort(setdiff(unique(sort(iter(%0,lnum(max([first(%i0,-)],[last(%i0,-)]),min([first(%i0,-)],[last(%i0,-)]))))),if(%1,THISSNIPPETATTRIBUTE(%1))),n)
@set Function Snippet Machine/ARCHIVE`6=public
&ARCHIVE`6`CC Function Snippet Machine=numberrange-list1:*:numberrange-list2 r:list:numbers
&ARCHIVE`6`CREATOR Function Snippet Machine=#11735:1172513110|Mercutio|1268679896
&ARCHIVE`6`DOC Function Snippet Machine=Takes in two lists in the form of: '4-6 9-10 30 35-38', which creates a number list based on NUMBERRANGE-LIST1, and then removes numbers based on NUMBERRANGE-LIST2. Return value of example: 4 5 6 9 10 30 35 36 37 38
&ARCHIVE`6`TITLE Function Snippet Machine=Number Range Expander
@set Function Snippet Machine=ARCHIVE`7:[ansi(hc,ATTR1)]: trim\(fold\(me/[ansi(hc,ATTR2)]\,unique\(sort\(\%0\,n\)\)\)\)%r%r[ansi(hc,ATTR2)]: if\(eq\(\%1\,inc\(last\(last\(\%0\)\,-\)\)\)\,strcat\(extract\(\%0\,1\,dec\(words\(\%0\)\)\)\,\%b\,first\(last\(\%0\)\,-\)\,-\,\%1\)\,\%0 \%1\)
@set Function Snippet Machine/ARCHIVE`7=public
&ARCHIVE`7`CC Function Snippet Machine=numberlist r:collapsed-numberlist
&ARCHIVE`7`CREATOR Function Snippet Machine=#11735:1172513110|Mercutio|1268931542
&ARCHIVE`7`DOC Function Snippet Machine=Takes in a list of numbers, like '1 2 3 4 5 10 99 100 101 8 9'NUMBERLIST and returns the COLLAPSED-NUMBERLIST '1-5 8-10 99-101'.
&ARCHIVE`7`TITLE Function Snippet Machine=Integer Squish
&CMD Function Snippet Machine=Contains the commands.
&CMD`ADD Function Snippet Machine=$+snippet/add *=*/*:@@ {%0: Title|%1: Snippet DBref|%2: Snippet Base Attribute} ; @break u(fn`is`atmaxattrs)=@pemit %#=u(fn`msg,fulldatabase) ; @assert lt(v(data`titlelen`min),strlen(%0),v(data`titlelen`max))=@pemit %#=u(fn`msg,longtitle) ; @break setr(T,u(fn`is`existingtitle,%0))=@pemit %#=u(fn`msg,titleexists,%qT) ; @assert visible(%!,setr(O,switch(%1,me,%#,%1))/%2)=@pemit %#=u(fn`msg,cannotsee) ; @break setr(E,u(fn`is`exactsamecode,%qD))=@pemit %#=u(fn`msg`exactsamecode,%qE) ; @assert lt(v(data`snippetlen`min),strlen(setr(S,get(%qO/%2))),v(data`snippetlen`max))=@pemit %#=u(fn`msg,badsnippetlen) ; @assert setr(C,get(%qO/%2`cc))=@pemit %#=u(fn`msg,nocallingconvention) ; @assert setr(D,get(%qO/%2`doc))=@pemit %#=u(fn`msg,nodoc) ; @set me=[setr(A,archive`[setr(N,inc(u(fn`get`lastsnippetnum)))])]:%qS ; @set me=%qA`cc:%qC ; @set me=%qA`doc:%qD ; @set me=%qA`creator:%:|%N|[secs()] ; @set me=%qA`title:%0 ; @pemit %#=u(fn`msg,snippetadded,%qN,%0) ; &data`lastnum me=inc(v(data`lastnum))
&CMD`DEL Function Snippet Machine=$+snippet/del *:@@ {%0: Snippet ID} ; @assert setr(I,rest(u(fn`snippetfind,%0),`))=@pemit %#=u(fn`msg,nosuchsnippet) ; @assert u(fn`is`abletomod,%qI,%:)=@pemit %#=u(fn`msg,cannotmod) ; @wipe me/archive`%qI ; @pemit %#=u(fn`msg,snippetdeleted,%qI)
&CMD`HELP Function Snippet Machine=$+snippet/help:@pemit %#=u(fn`display`help)
&CMD`LIST Function Snippet Machine=$^\+snippet(?\:/list)?$:@dolist header [sort(lattr(me/archive`),m)] footer=@pemit %#=u(fn`display`shortsnip,##)
@set Function Snippet Machine/CMD`LIST=regexp
&CMD`OVERWRITE Function Snippet Machine=$+snippet/overwrite *=*/*:@@ {%0: Snippet Number|%1: Snippet DBref|%2: Snippet Base Attribute} ; @assert setr(I,u(fn`snippetfind,%0))=@pemit %#=u(fn`msg,nosuchsnippet) ; @assert eq(words(%qI),1)=@pemit %#=u(fn`msg,ambigsnippet,%qI) ; @assert u(fn`is`owner,last(%qI,`),%#)=@pemit %#=u(fn`msg,youdontown); @assert visible(%!,setr(O,switch(%1,me,%#,%1))/%2)=@pemit %#=u(fn`msg,cannotsee) ; @break setr(E,u(fn`is`exactsamecode,%qD))=@pemit %#=u(fn`msg`exactsamecode,%qE) ; @assert lt(v(data`snippetlen`min),strlen(setr(S,get(%qO/%2))),v(data`snippetlen`max))=@pemit %#=u(fn`msg,badsnippetlen) ; @assert setr(C,get(%qO/%2`cc))=@pemit %#=u(fn`msg,nocallingconvention) ; @assert setr(D,get(%qO/%2`doc))=@pemit %#=u(fn`msg,nodoc) ; @set me=%qi:%qS ; @set me=%qi`cc:%qC ; @set me=%qi`doc:%qD ; @set me=%qi`creator:%:|%N|[secs()] ; @pemit %#=u(fn`msg,snippetoverwritten,last(%qi,`))
&CMD`SEARCH Function Snippet Machine=$+snippet/search *:@@ {%0: Search wildcard} ; @pemit %#=u(fn`display`search,%0)
&CMD`VIEW Function Snippet Machine=$^\+snippet(?\:/view)?\s+(.+)$:@@ {%1: Snippet ID, or wildcard for title.} ;@assert setr(I,u(fn`snippetfind,%1))=@pemit %#=u(fn`msg,nosuchsnippet) ; @assert eq(words(%qI),1)=@pemit %#=u(fn`msg,ambigsnippet,%qI) ; @pemit %#=u(fn`display`snippet,extract(%qI,2,1,`))
@set Function Snippet Machine/CMD`VIEW=regexp
&DATA Function Snippet Machine=Contains static data. Can be seen as the system's "settings".
&DATA`DOCOBJ Function Snippet Machine=#10120
&DATA`LASTNUM Function Snippet Machine=29
&DATA`SNIPPETLEN Function Snippet Machine=Defines the min and max length of a code snippet.
&DATA`SNIPPETLEN`MAX Function Snippet Machine=300
&DATA`SNIPPETLEN`MIN Function Snippet Machine=5
&DATA`TITLELEN Function Snippet Machine=Defines the min and max length of a code title.
&DATA`TITLELEN`MAX Function Snippet Machine=30
&DATA`TITLELEN`MIN Function Snippet Machine=5
&DESCRIBE Function Snippet Machine=A tool for submitting and viewing function-snippets for code - for the 'Snippet Of The Day' project, to potentially replace 'Function Of the Day'.%r%r+snippet/help to start!
@set Function Snippet Machine/DESCRIBE=no_command visual prefixmatch public nearby
&FN Function Snippet Machine=Contains functions.
&FN`DISPLAY Function Snippet Machine=Display functions.
&FN`DISPLAY`HELP Function Snippet Machine=.[center(> Snippet Help <,sub(width(%#),2),-)].%r%b[ansi(hw,Commands)]:%r%r%b[ansi(hc,+snippet/add)] <[ansi(hc,Title)]>=<[ansi(hc,Object)]>/<[ansi(hc,Attribute)]>%r[align(4 [sub(width(%#),5)],,{Will add a snippet with the title indicated, using the attribute you give as the snippet. It is suggested this object is @set to VISUAL. This command will not evaluate your snippet, mind you - and the command also requires you to add a `cc and `doc subattribute, as defined in '[ansi(hc,docf/help)]'!})]%r%b[ansi(hc,+snippet/overwrite)] <[ansi(hc,Snippet-title Or Number)]>=<[ansi(hc,Object)]>/<[ansi(hc,Attribute)]>%r[align(4 [sub(width(%#),5)],,{Overwrites one of your own snippets with an updated version.})]%r%b[ansi(hc,+snippet/del)] <[ansi(hc,Snippet-title or number)]>%r[align(4 [sub(width(%#),5)],,{Will remove the snippet, assuming you are staff or the owner.})]%r%b[ansi(hc,+snippet/search)] <[ansi(hc,wildcard)]>%r[align(4 [sub(width(%#),5)],,{find you snippets which match your wildcard in any of their fields.})]%r%b[ansi(hc,+snippet/view)] <[ansi(hc,Snippet-title or number)]>%r[align(4 [sub(width(%#),5)],,{Will display the snippet to you.})]%r%b[ansi(hc,+snippet/list)]%r[align(4 [sub(width(%#),5)],,{Lists all snippets, with a small description. Can get big!})]%r%b[ansi(hc,+snippet/help)]%r[align(4 [sub(width(%#),5)],,{This file, obviously!})]%r'[repeat(-,sub(width(%#),2))]'
&FN`DISPLAY`SEARCH Function Snippet Machine=setq(S,wildgrepi(me,archive`,%0))[setq(C,wildgrepi(me,archive`*`cc,%0))][setq(P,wildgrepi(me,archive`*`creator,%0))][setq(D,wildgrepi(me,archive`*`doc,%0))][setq(T,wildgrepi(me,archive`*`title,%0))][setq(u,fn`display`search`short)][@@(That was no fun to prep - but makes coding easier :/)][condall(%qS,u(%qU,%qS,Snippet,),%qT,u(%qU,%qT,Title,title),%qC,u(%qU,%qC,Calling Convention,cc),%qD,u(%qU,%qD,Description,doc),%qP,u(%qU,%qP,Creator,creator),No results found!)]
&FN`DISPLAY`SEARCH`SHORT Function Snippet Machine=if(eq(strlen(%0),[strlen(repeat(-,99999))]),%1: Too many found!,%rFound ([words(%0)]) item[switch(words(%0),1,,s)] by [ansi(hw,%1)]:%r--> [iter(%0,first(rest(%i0,`),`),,%r-->%b)]%r)
&FN`DISPLAY`SHORTSNIP Function Snippet Machine=switch(%0,footer,'[repeat(-,sub(width(%#),2))]',header,.[center(< [ansi(hw,List of Snippets)] >,sub(width(%#),2),-)].,[ansi(hg,rjust(rest(%0,`),4,0))]: [setr(T,[ljust(([u(fn`get`snippet`ownername,rest(%0,`))]),26)] [ansi(hw,u(fn`get`snippet`title,rest(%0,`)))])]:%r--> [left(setr(D,u(fn`get`snippet`desc,rest(%0,`))),sub(width(%#),5))][if(gt(strlen(%qD),sub(width(%#),5)),~)])
&FN`DISPLAY`SNIPPET Function Snippet Machine=.[center(< [ansi(hw,Snippet #%0)] >,sub(width(%#),2),-)].%r[center(< [ansi(hw,u(fn`get`snippet`title,%0))] >,width(%#),-)]%r[u(fn`get`snippet,%0)]%r[center(< [ansi(hw,Information)] >,width(%#),-)]%r[u(fn`get`doc,%!,archive`%0,1)]%r'[center(< By [ansi(g,if(isdbref(u(fn`get`snippet`owner,%0)),name(u(fn`get`snippet`owner,%0)) \([u(fn`get`snippet`owner,%0)]\),u(fn`get`snippet`owner,%0)))] on [ansi(g,convsecs(u(fn`get`snippet`time,%0)))] >,sub(width(%#),2),-)]'
&FN`GET Function Snippet Machine=Gets information.
&FN`GET`DOC Function Snippet Machine=u(v(data`docobj)/fun_document_mortal,%0,%1,%2)
&FN`GET`LASTSNIPPETNUM Function Snippet Machine=v(data`lastnum)
&FN`GET`NEXTSNIPPETNUM Function Snippet Machine=first(setdiff(lnum(1,inc(lmath(max,edit(lattr(me/archive`),ARCHIVE`,)))),%0))
&FN`GET`RANDOMSNIPPETID Function Snippet Machine=xattr(me/archive`,rand(nattr(me/archive`)),1)
&FN`GET`SNIPPET Function Snippet Machine=default(me/archive`%0,#-1 NO SUCH SNIPPET ID)
&FN`GET`SNIPPET`CC Function Snippet Machine=default(me/archive`%0`CC,#-1 NO SUCH SNIPPET ID OR CALLING CONVENTION)
&FN`GET`SNIPPET`DESC Function Snippet Machine=default(me/archive`%0`DOC,#-1 NO SUCH SNIPPET ID OR DESCRIPTION)
&FN`GET`SNIPPET`OWNER Function Snippet Machine=firstof(pmatch(extract(get(me/archive`%0`creator),1,1,|)),extract(get(me/archive`%0`creator),2,1,|),#-1 NO SUCH SNIPPET ID OR NO OWNER DEFINED)
&FN`GET`SNIPPET`OWNERNAME Function Snippet Machine=firstof(extract(get(me/archive`%0`creator),2,1,|),#-1 NO SUCH SNIPPET ID OR NO OWNER DEFINED)
&FN`GET`SNIPPET`TIME Function Snippet Machine=last(default(me/archive`%0`creator,#-1 NO SUCH SNIPPET ID OR DESCRIPTION),|)
&FN`GET`SNIPPET`TITLE Function Snippet Machine=default(me/archive`%0`title,#-1 NO SUCH SNIPPET ID OR TITLE)
&FN`IS Function Snippet Machine=Returns boolean values.
&FN`IS`ABLETOMOD Function Snippet Machine=or(u(fn`is`staff,%1),u(fn`is`owner,%0,%1))
&FN`IS`ATMAXATTRS Function Snippet Machine=eq(config(max_attrs_per_obj),add(nattr(me),5))
&FN`IS`EXACTSAMECODE Function Snippet Machine=grepi(me,archive`,%0)
&FN`IS`EXISTINGTITLE Function Snippet Machine=grepi(me,archive`*`title,%0)
&FN`IS`OWNER Function Snippet Machine=strmatch(first(v(archive`%0`creator),|),objid(%1))
&FN`IS`STAFF Function Snippet Machine=or(switch([isstaff(%0)],#-1 FUNCTION*,hasflag(%0,Wr),#$),testlock($%!,%0))
&FN`MSG Function Snippet Machine=[ansi(hw,SNIPPET>)] [udefault(me/msg`%0,%0,%:,%1,%2,%3,%4,%5,%6,%7,%8,%9)]
&FN`SNIPPET Function Snippet Machine=
&FN`SNIPPETFIND Function Snippet Machine=firstof(lattr(me/archive`[val(%0)]),edit(wildgrepi(me,archive`*`title,%0),`TITLE,),#-1 NO SUCH SNIPPET)
&MSG Function Snippet Machine=Contains the messages to be used by fn`msg.
&MSG`AMBIGSNIPPET Function Snippet Machine=Ambiguous snippet match. The following ones matched: [itemize(iter(%1,extract(%i0,2,1,`)))].
&MSG`BADSNIPPETLEN Function Snippet Machine=That is an inappropiate length to your snippet. Try to keep it between [v(data`snippetlen`min)] and [v(data`snippetlen`max)] characters!
&MSG`CANNOTMOD Function Snippet Machine=Sorry. You do not have the permissions required to modify that snippet.
&MSG`CANNOTSEE Function Snippet Machine=Sorry, I cannot see (anything in) that attribute. Are you sure you have set the object, or the attribute (and everything under it) set VISUAL?
&MSG`EXACTSAMECODE Function Snippet Machine=Sorry, but the exact same code was found in code snippet #[last(%1,`)]! If it is yours, use [ansi(hw,+snippet/del)] to remove it, and add then proceeed to add the fixed version anew.
&MSG`FULLDATABASE Function Snippet Machine=We're sorry, the database is full! No more code-snippets can be added.
&MSG`LONGTITLE Function Snippet Machine=That title is too long. Try to keep it between [v(data`titlelen`min)] and [v(data`titlelen`max)] characters!
&MSG`NOCALLINGCONVENTION Function Snippet Machine=No calling convention defined, or it is not VISUAL. Please use &[ansi(hw,<)]yoursnippetattribute[ansi(hw,>)]`cc [ansi(hw,<)]object[ansi(hw,>)]=something - to define your calling convention. See 'docf/help' and 'docf/syntax' for help!
&MSG`NODESC Function Snippet Machine=No function documentation defined, or it is not VISUAL. Please use &[ansi(hw,<)]yoursnippetattribute[ansi(hw,>)]`doc [ansi(hw,<)]object[ansi(hw,>)]=howyourcodeworks - to define your calling convention. See 'docf/help' for help!
&MSG`NOSUCHSNIPPET Function Snippet Machine=That is not a valid Snippet ID, or title. Please check +snippet/list.
&MSG`SNIPPETADDED Function Snippet Machine=A snippet was added with the title '%2' under the ID '%1'.
&MSG`SNIPPETDELETED Function Snippet Machine=Snippet #%1 was deleted.
&MSG`SNIPPETOVERWRITTEN Function Snippet Machine=Your snippet '[u(fn`get`snippet`title,%1)]' (%1) was overwritten.
&MSG`TITLEEXISTS Function Snippet Machine=Sorry, that title already is taken by snippet #[extract(%1,2,1,`)].
&MSG`YOUDONTOWN Function Snippet Machine=You cannot change that, as you do not own that.
look Function Snippet Machine