Based around the idea of weekly (or monthly, or whatever) "dbsave themes" that your players can submit their own responses to, which are displayed at random when the database is saved.

Author: Walker@M*U*S*H
Category: Globals
Features: #lambda, regexp commands.
Compatibility: CobraMUSH, PennMUSH.


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

MUSHCode for DBSave

@create DBSave Parent
@lock DBSave Parent==me
@set DBSave Parent = WIZARD
@set DBSave Parent = !NO_COMMAND
&ADVERT DBSave Parent=Set an advert that runs after every set +dbsave runs.
@set DBSave Parent/ADVERT=no_command
&CMD DBSave Parent=Commands
&CMD`ADVERT DBSave Parent=$+dbsave/ad *:@assert orflags(%#,Wr)=@pemit %#=I don't think you can do that. ; @pemit %#=Advert changed from '[v(advert)]' to '%0' ; &advert me=%0
&CMD`CLEAR DBSave Parent=$+dbsave/clear:@assert hasattr(me,s`%#)=@pemit %#=You don't have a dbsave set! ; @pemit %#=Message cleared. ; @wipe me/s`%# ; @wipe me/t`%#
&CMD`CLEAR_VIC DBSave Parent=$+dbsave/clear *:@assert orflags(%#,Wr)=@pemit %#=I don't think you can do that. ; @break strmatch(%0,all)={@pemit %#=+dbsave/clear all has been disabled. Please use +dbsave/new.} ; @assert setr(0,namegrab(edit(lattr(me/s`*),S`,),%0))=@pemit %#=Clear whose message? ; @pemit %#=You clear [name(%q0)]'s message, "[v(s`%q0)]" ; @wipe me/s`%q0 ; @wipe me/t`%q0
&CMD`DBSAVE DBSave Parent=$+dbsave:@pemit/silent %#=%r[u(status)]%r%r[if(hasattr(me,s`%#),Your current db save message is: [v(s`%#)],You have no db save message set.)]
&CMD`LIST DBSave Parent=$^\+dbsave/(show|list)$:@pemit %#=DBSaves:%r%b%b[if(orflags(%#,Wr),+dbsave/ad,DBSave ad)]: [v(advert)]%r%r[map(if(cand(orflags(%#,Wr),strmatch(%1,show)),fun`list_admin,fun`list_mortal),lattr(me/s`*),%b,%r)
@set DBSave Parent/CMD`LIST=regexp
&CMD`NEW DBSave Parent=$+dbsave/new*:@assert orflags(%#,Wr)=@pemit %#=You don't have permission to do that. Sorry! ; &lastscore me=u(fun`scorers) ; @pemit %#=Score table:%r[v(lastscore)] ; @wipe me/s`* ; @wipe me/t`* ; @wipe me/v`* ; @pemit %#=%r ... +dbsaves cleared. ; @assert strlen(%0)=@pemit %#=Please set a +dbsave/ad and +dbsave/theme! ; think strmatch(setr(t,%0),*=*,t a) ; &theme me=%qt ; &advert me=setr(a,if(strlen(%qa),%qa,%qt (+dbsave and +dbsave/vote!))) ; @config/set dump_complete=SAVE: %qa
&CMD`SCORES DBSave Parent=$+dbsave/score:@pemit %#=The scores from the last round of dbsaves:%r[v(lastscore)]
&CMD`SET DBSave Parent=$+dbsave *:@assert lte(strlen(%0),120)=@pemit %#=That's too long by [sub(strlen(%0),120)] characters. ; @break pos(%r,%0)=@pemit %#=No \%rs allowed, sorry! ; &s`%# me=%0 ; @pemit %#=Save message '%0' has been entered into the queue for theme '[v(theme)]'. ; &t`%# me=[secs()] ; think iter(grepi(me,v`*,s`%#:),wipe(me/%i0))
&CMD`THEME DBSave Parent=$+dbsave/theme *:@assert orflags(%#,Wr)=@pemit %#=I don't think you can do that. ; @pemit %#=Theme set. ; &theme me=%0
&CMD`VOTE DBSave Parent=$+dbsave/vote*:@assert strlen(%0)=@pemit %#=Vote for your favorite +dbsave for the current theme by using +dbsave/vote <text from the dbsave>! For a full list, use +dbsave/list.[if(hasattrval(me,v`%#),%r%rYou have voted for: [v(before(v(v`%#),:))])] ; @assert words(setr(0,firstof(filterbool(#lambda/strmatch(stripansi(v(\%0)),decompose(squish(%0))),lattr(me/s`*)),filterbool(#lambda/strmatch(stripansi(v(\%0)),*[decompose(squish(%0))]*),lattr(me/s`*)))))=@pemit %#=I can't find any dbsave message matching '[squish(%0)]'. ; @assert eq(words(%q0),1)=@pemit %#=I found [words(%q0)] different matches, can you please be more specific? ; @assert comp(%#,after(%q0,`))=@pemit %#=You can't vote for yourself! ; @pemit %#=You [if(hasattrval(me,v`%#),re)]cast your vote for '[v(%q0)]' ; &v`%# me=%q0:
&CRON_HOURLY DBSave Parent=@break [switch(nattr(me/t`*),<6,cor(eq(mod(add(timefmt($d),timefmt($H)),5),1),eq(nattr(me/s`*),0)),cand(eq(match(lattr(me/s`*),%va),nattr(me/s`*)),not(v(shownad))[attrib_set(me/shownad,1)]))]=@config/set dump_complete=SAVE: [u(advert)] ; &shownad me=0 ; @config/set dump_complete=SAVE: [u(getmsg)] ; @break 1 ; @@ Stop clearing them for a while so we can use votes? ; think iter(lattr(me/t`*),if(gte(sub(secs(),v(%i0)),604800),[wipe(me/s`[after(%i0,`)])][wipe(me/%i0)][wipe(me/v`[after(%i0,`)])]))
&DESCRIBE DBSave Parent=DBSave Object. How to use:%r%rThis based around the idea of weekly (or monthly, or whatever) "dbsave themes" that your players can submit their own dbsaves for.%r%rCommands:%r%r[ansi(h,+dbsave)] - See the current dbsave theme.%r[ansi(h,+dbsave/list)] - View the current submissions and their vote count.%r[ansi(h,+dbsave/vote <message>)] - Vote for a submitted dbsave.%r[ansi(h,+dbsave <message>)] - Submit your dbsave.%r[ansi(h,+dbsave/clear)] - Clear your submission to +dbsave.%r[ansi(h,+dbsave/score)] - View the submitters of last round's winning dbsave messages.%r%rAdmin commands:%r%r[ansi(h,+dbsave/show)] - A +dbsave/list but with player names shown.%r[ansi(h,+dbsave/clear <playername>)] - Clear a player's dbsave.%r[ansi(h,+dbsave/new <theme>)] - New dbsave theme. Also sets the ad, clears, scores, etc.%r[ansi(h,+dbsave/theme <theme>)] - Changes the theme. Best used to fix typos in current dbsave theme.%r[ansi(h,+dbsave/ad <ad>)] - Changes the ad.
@set DBSave Parent/DESCRIBE=no_command visual prefixmatch public nearby
&FUN DBSave Parent=Functions
&FUN`LIST_ADMIN DBSave Parent=align(2 >14 >4 <[sub(width(%#),24)],if(strmatch(%0,%va),*),left(name(after(%0,`)),12):,([words(grep(me,v`*,%0:))]),v(%0))
&FUN`LIST_MORTAL DBSave Parent=align(2 >4 <[sub(width(%#),10)],if(strmatch(%0,%va),*),([words(grep(me,v`*,%0:))]),v(%0))
&FUN`LIST_SCORES DBSave Parent=align(>14 >4 <52,left(name(after(%0,`)),12):,([words(grep(me,v`*,%0:))]),v(%0))
&FUN`SCORERS DBSave Parent=[v(theme)]%r%r[map(fun`list_scores,filterbool(#lambda/grep(me,v`*,\%0:),lattr(me/s`*)),%b,%r)]
&GETMSG DBSave Parent=set(me,va:[extract(setr(0,lattr(me/s`*)) %q0,inc(match(%q0,%va)),1)])[v(%va)]
&S DBSave Parent=Save messages
@set DBSave Parent/S=no_command
&SHOWNAD DBSave Parent=0
@set DBSave Parent/SHOWNAD=no_command
&STARTUP DBSave Parent=@trigger me/cron_hourly ; @assert v(use_cycle) ; @wait 3600=@trigger me/startup
@set DBSave Parent/STARTUP=no_command prefixmatch
&STATUS DBSave Parent=Database Save Messages:%r%b%bThe current theme of +dbsaves is "[v(theme)]". To submit your own db save message, use "[ansi(h,+dbsave <message>)]".%r%r%b%bFor more information, "+help dbsave"
&T DBSave Parent=Timestamps for database save messages.
&THEME DBSave Parent=Set a theme.
@set DBSave Parent/THEME=no_command
&USE_CYCLE DBSave Parent=0
&V DBSave Parent=Votes
@set DBSave Parent/V=no_command
&WEEKOLD DBSave Parent=gte(sub(secs(),convtime(ctime(%#))),86400)

look DBSave Parent
think CRON_HOURLY is the attribute that should be triggered in regular intervals to change the save message.