So, I tried all that and it didn't do the trick. I ended up just putting up a @readcache cron job every 30 minutes. All you who follow in my footsteps: skip the troubleshooting and just use the cron. @Sponge is wise.
Posts made by Melpomene
-
RE: Shell help request: +weather text file writing
-
RE: Code Request: RP Nexus
@Bobotron Honestly I'm not sure. It's a new game, the buildstaffers are stil working on policy. They might decide that digging your own is fine; they might decide that floating rooms are clutter... I don't even have a clue. I will note that on some games I've played, buildstaff controlled the quota with an iron fist - @digging was verboten unless you had a project in the Build Nexus and nobody but NOBODY could RP there. I doubt this game's buildstaffers would be that bad - they're too nice! - but the gods have decreed that there should be a RP Nexus so the players won't have to resort to @digging their own.
@Thenomain OK, I'm giving this a shot. It took a bit of kicking - I found two bugs - but I believe I have it working. Below is the fixed +temproom function - two of the @asserts returned 0s for valid values, and the @trigger didn't specify what object had the trigger - since no @parent was specified I just went with an explicit call, set up during the install process.
Also: I got 90% of the way through implementing this as a RP Nexus only, and one of the gods told me that they actually want +temprooms available everywhere, to anyone. D'oh! So yes, +temprooms is exactly what I needed. Working on that.
These are the changes I made, in case anyone wants them:
&c.temproom trm= $^\+?temproom (.*)$: @assert [or( isstaff( %# ), u( f.valid-room?, loc( %# )))]= { @pemit %#= You're not in a location that can take a temproom. } ; think >> [setr( s, u( f.scrub_name, %1 ) )] %r >> [setr( n, u( f.format.roomname, %qs ) )] %r >> [setr( e, u( f.format.entrance, %qs ) )] %r >> [setr( x, u( f.format.exit, %qs ) )] ; @assert valid( roomname, %qn )= { @pemit %#= u( .msg, temproom, I can't take that name for a temproom. ) } ; @assert valid( exitname, %qn )= { @pemit %#= u( .msg, temproom, I can't make that name into a good exit name. ) } ; @assert not(t( match( elements( %qe, 2, %; ), v( d.illegal-anagrams ))))= { @pemit %#= u( .msg, temproom, The exit name would be too close to commonly used commands. ) } ; @assert not(cor( t( locate( %#, elements( %qe, 2, %; ), E )), t( locate( %#, elements( %qe, 3, %; ), E ))))= { @pemit %#= u( .msg, temproom, That would create an exit with an identical name as an exit in that room. ) } ; @trigger [v(d.digger)]/tr.dig-room= loc( %# ), %qn, %qe, %qx, %# ; @eval u( f.monitor, temproom: [name( %# )] creates "%qs" off [name( loc( %# ) )] ( [loc( %# )] )) ;
-
RE: Code Request: RP Nexus
@Chime More like what @Thenomain described - a room which creates temporary rooms on command, so that players can have a private place to RP without @digging their homes or popping up floating rooms everywhere.
Reasons: Build projects take longer to get approved, no one wants to @dig the rooms for their trip to Miami, sometimes you just want to use a place that isn't part of the regular grid so nobody can just walk right in, etc. Plus, RP Nexuses are accessible to unapproved players, which can be handy for pre-approval RP.
Temprooms looked like a bit of overkill for what I'm doing but I'll try it out. Looks like it does do what I need it to without putting it on the entire grid.
-
Code Request: RP Nexus
I need a RP Nexus type thing. Nothing I googled looked quite right and the ones I have in my store of old MU*code are pretty dated. (Maybe I'm searching for the wrong thing - "RP Nexus", "Roleplay Nexus", "RP rooms", etc. "Temprooms" is not what I'm looking for - I only want this thing opening rooms in one location.) If anyone has one they'd like to share here, I'd be grateful to the tune of 1,000 internets!
This is hopefully the last major code request I've got. Trying not to reinvent the wheel but if no one comes up with anything I'll write one - it seems fairly straightforward. I have a hope there's a repository somewhere that I've missed with the relevant code in it, though. It would save me time/labor and a coder who is not lazy is not a proper coder.
Thanks!
-
Code offering: +autojobs
Automatically create a job in X days/weeks/months or every X days/weeks/months. Because that could get horribly annoying, only staff can do it. It is managed by @forcing the player to +request something, however, so it does let players at least look at their autojobs (after all, they'll see them when they're +requested). This is based off my earlier Generic Reminders Code. I'll try to keep it up to date as I encounter bugs.
The desc/help:
+autojob <name>=<job title>[ <in|every> [<X>] <days|weeks|months>] (Staff) Examples: +autojob Jamie=Call Mom - will open a new job every day +autojob Jake=Howl at the moooon! every month +autojob John=Feeding Frenzy in 3 days +autojobs - Show all the autojobs you have set. +autojob/view 1 - view autojob #1 on yourself. Staff only: +autojob/view <name>/1 - view autojob #1 on <name>. +autojob/cancel <name>/1 - get rid of autojob #1 on <name>. +autojob/note <name>/1=<stuff> - any notes you want to include in the job Notes: All autojobs are created at 2 AM. This code considers "a month" to be 28 days. Units of time that are not recognized will default to "days". Do not use this code for precision. Most third-party apps work better. Code notes: Required functions: header, footer, isstaff, alert Required objects: Cron object of some kind, Anomaly Jobs Required permissions: WIZARD due to attr reading/setting & @forcing Limitations: Players can run out of space on themselves by setting a million autojobs. Regrets: Did not code the display number to NOT be the ID. Credits: Melpomene@NOLA (melpomine@gmail.com|nola.mechanipus.com 2967)
The code:
@create AutoJob Handler <AJH>=10 @set AJH=SAFE INHERIT @desc AJH=%R[space(3)]+autojob <name>=<job title>[ <in|every> [<X>] <days|weeks|months>] (Staff)%R%R[space(3)]Examples:%R[space(5)]+autojob Jamie=Call Mom - will open a new job every day%R[space(5)]+autojob Jake=Howl at the moooon! every month%R[space(5)]+autojob John=Feeding Frenzy in 3 days%R%R[space(3)]+autojobs - Show all the autojobs you have set.%R[space(3)]+autojob/view 1 - view autojob #1 on yourself.%R%R[space(3)]Staff only:%R%R[space(3)]+autojob/view <name>/1 - view autojob #1 on <name>.%R[space(3)]+autojob/cancel <name>/1 - get rid of autojob #1 on <name>.%R[space(3)]+autojob/note <name>/1=<stuff> - any notes you want to include in the job%R%R[space(3)]Notes:%R[space(5)]All autojobs are created at 2 AM.%R[space(5)]This code considers "a month" to be 28 days.%R[space(5)]Units of time that are not recognized will default to "days".%R[space(5)]Do not use this code for precision. Most third-party apps work better.%R%R[space(3)]Code notes:%R[space(5)]Required functions: header, footer, isstaff, alert%R[space(5)]Required objects: Cron object of some kind, Anomaly Jobs%R[space(5)]Required permissions: WIZARD due to attr reading/setting & @forcing%R[space(5)]Limitations:%R[space(7)]Players can run out of space on themselves by setting a million%R[space(7)]autojobs.%R[space(5)]Regrets: Did not code the display number to NOT be the ID.%R%R[space(3)]Credits: Melpomene@NOLA (melpomine@gmail.com|nola.mechanipus.com 2967)%R &cmd-+autojob AJH=$+autojob *=*:@switch setr(E, if(not(isstaff(%#)), Only staffers may set autojobs., if(not(t(setr(P, pmatch(case(%0, me, %N, %0))), %#)), Could not find player %0., setq(3, extract(%1, sub(words(%1), 2), 3))[null(iter(%q3, if(isnum(%i0), setq(4, 1)))[if(not(t(%q4)), setq(4, switch(%q3, * month, M, * months, M, * day, D, * days, D, * weeks, W, * week, W, 0)))])][if(not(t(%q4)), setq(3, ))][setq(C, switch(%q3, * month, M, * months, M, * day, D, * days, D, * weeks, W, * week, W, 0))][setq(R, switch(%q3, * in *, I, in *, I, * every *, E, every *, E, 0))][setq(N, trim(squish(iter(%q3, if(isnum(%i0), %i0)))))][if(or(not(t(%qN)), not(isnum(%qN))), setq(N, 1))][setq(S, if(or(strmatch(%q3, * in *), strmatch(%q3, in *)), extract(%1, 1, sub(words(%1), match(revwords(%1), in))), if(or(strmatch(%q3, * every *), strmatch(%q3, every *)), extract(%1, 1, sub(words(%1), match(revwords(%1), every))), %1)))][if(not(t(%qS)), Could not figure out what you wanted me to autojob you of!, setq(T, convtime(timefmt($a $b $d 02:00:00 $Y, add(secs(), mul(%qN, case(%qC, W, 604800, M, 2419200, 86400)))))))])))=, {&_autojobCount %qP=setr(I, add(default(%qP/_autojobCount, 0), 1)); &_autojob-%qI-text %qP=%qS; &_autojob-%qI-cycle %qP=[if(t(%qC), %qC, D)]; &_autojob-%qI-next %qP=%qT; &_autojob-%qI-interval %qP=%qN; &_autojob-%qI-setter %qP=%#; &_autojob-%qI-repeat %qP=[case(%qR, I, 0, 1)]; @switch [gt(strlen(get(me/people-[setr(A, v(peopleCount))])), 7500)]=1, {&peopleCount me=setr(A, add(%qA, 1));}; &people-%qA me=[setunion(v(people-%qA), %qP)]; @set me/people-%qA=NO_COMMAND; @pemit %#=alert(autojobs) [name(%qP)] will open a job titled "%qS" [case(%qR, I, in, every)] [if(gt(%qN, 1), %qN%b)][case(%qC, W, week, M, month, day)][if(gt(%qN, 1), s)][case(%qR, I,, . The next autojob is)] on [timefmt($m/$d/$y at 2 AM, %qT)].[case(%qC, M, %bPlease note that a month is considered to be 28 days long.)];}, {@pemit %#=alert(autojobs) %qE;} @set AJH/cmd-+autojob=no_parse &peopleCount AJH=1 @set AJH/peopleCount=NO_COMMAND &trigger_autojobs AJH=@dolist lattr(me/people-*)={@trigger me/trigger_parse-people=##;}; @set AJH/trigger_autojobs=NO_COMMAND &trigger_parse-people AJH=@dolist v(%0)={@trigger/notify me/trigger_autojob-person=##; @wait me={@trigger me/trigger_clean-person=##;};} @set AJH/trigger_parse-people=NO_COMMAND &trigger_clean-person AJH=@switch words(lattr(%0/_autojob-*-text))=0, {@dolist lattr(me/people-*)={&## me=[setdiff(v(##), %0)];};} @set AJH/trigger_clean-person=NO_COMMAND &trigger_autojob-person AJH=@switch t(setr(P, pmatch(%0)))=1, {@dolist lattr(%qP/_autojob-*-text)={@switch setq(0, first(rest(##, -), -))[setq(C, get(%qP/_autojob-%q0-cycle))][setq(I, get(%qP/_autojob-%q0-interval))][setq(R, get(%qP/_autojob-%q0-repeat))][setq(T, get(%qP/_autojob-%q0-next))][setq(S, get(%qP/_autojob-%q0-setter))][lt(%qT, add(secs(), 3600))]=1, {@force %qP=+request [titlestr(setr(V, get(%qP/##)))]=%%R%%RAutojob: %qV[if(hasattr(%qP, _autojob-%q0-note), %%R%%R%%TNote: [get(%qP/_autojob-%q0-note)])]%R%R This is a [case(%qR, 1, repeating, one-time)] +autojob [name(%qS)] set for [name(%qP)]. [case(%qR, 1, The next +autojob will be on [timefmt($m/$d/$y at 2 AM, convtime(timefmt($a $b $d 02:00:00 $Y, add(secs(), mul(%qI, case(%qC, W, 604800, M, 2419200, 86400))))))]. This +autojob will recur every %qI [case(%qC, W, week, M, month, day)][if(gt(%qI, 1), s)].)] To learn more about +autojobs, type +help autojobs.; @switch %qR=1, {&_autojob-%q0-next %qP=[convtime(timefmt($a $b $d 02:00:00 $Y, add(secs(), mul(%qI, case(%qC, W, 604800, M, 2419200, 86400)))))];}, {@wipe %qP/_autojob-%q0-*;}}}} @set AJH/trigger_autojob-person=NO_COMMAND &cmd-+autojobs AJH=$+autojobs:@pemit %#=if(t(setr(R, lattr(%#/_autojob-*-text))), header(Your active autojobs)[space(3)]%cu[ljust(ID, 5)] [ljust(+autojob text, 57)] [ljust(Next, 8)]%cn%R[iter(%qR, space(3)[ljust(setr(0, first(rest(%i0, -), -))., 5)] [ljust(mid(get(%#/%i0), 0, 57), 57)] [ljust(timefmt($m/$d/$y, get(%#/_autojob-%q0-next)), 8)],, %R)][footer(+autojob/view # for more.)], alert(autojobs) You have no active autojobs.); &cmd-+autojobs_person AJH=$+autojobs *:@switch setr(E, if(not(isstaff(%#)), Only staffers may view another player's autojobs., if(not(t(setr(P, pmatch(case(%0, me, %N, %0))), %#)), Could not find player %0.)))=, {@pemit %#=if(t(setr(R, lattr(%qP/_autojob-*-text))), header([name(%qP)]'s active autojobs)[space(3)]%cu[ljust(ID, 5)] [ljust(+autojob text, 57)] [ljust(Next, 8)]%cn%R[iter(%qR, space(3)[ljust(setr(0, first(rest(%i0, -), -))., 5)] [ljust(mid(get(%qP/%i0), 0, 57), 57)] [ljust(timefmt($m/$d/$y, get(%qP/_autojob-%q0-next)), 8)],, %R)][footer(+autojob/view [name(%qP)]/# for more.)], alert(autojobs) [name(%qP)] has no active autojobs.);}, {@pemit %#=alert(autojobs) %qE;}} @set AJH/cmd-+autojobs_person=no_parse &cmd-+autojob_view AJH=$+autojob/view *:@switch strmatch(%0, */*)=1,{},{@switch setr(E, if(not(hasattr(%#, _autojob-%0-text)), You don't have a autojob #%0.))=, {@pemit %#=header(+autojob #%0)%r[wrap(Text: [get(%#/_autojob-%0-text)], 78, Left, space(3))]%R[if(hasattr(%#, _autojob-%0-note), wrap(Note: [get(%#/_autojob-%0-note)], 78, Left, space(3))%R)][columns(Set by: [name(get(%#/_autojob-%0-setter))]|Repeating: [case(setr(R, get(%#/_autojob-%0-repeat)), 1, on, off)]|Next autojob: [timefmt($m/$d/$y at 2 AM, get(%#/_autojob-%0-next))]|Occurs [case(%qR, 1, every, in)]: [setr(I, get(%#/_autojob-%0-interval))] [case(get(%#/_autojob-%0-cycle), W, week, M, month, day)][if(gt(%qI, 1), s)], 36, |, 3)]%R[footer(if(isstaff(%#), +autojob/note %N/%0=<note> to set a note.))];}, {@pemit %#=alert(autojobs) %qE;}} @set AJH/cmd-+autojob_view=no_parse &cmd-+autojob_view_person AJH=$+autojob/view */*:@switch setr(E, if(not(isstaff(%#)), Only staffers may view another player's autojobs., if(not(t(setr(P, pmatch(case(%0, me, %N, %0))), %#)), Could not find player %0., if(not(hasattr(%qP, _autojob-%1-text)), [name(%qP)] doesn't have a +autojob #%1.))))=, {@pemit %#=header([name(%qP)]'s +autojob #%1)%r[wrap(Text: [get(%qP/_autojob-%1-text)], 78, Left, space(3))]%R[if(hasattr(%qP, _autojob-%1-note), wrap(Note: [get(%qP/_autojob-%1-note)], 78, Left, space(3))%R)][columns(Set by: [name(get(%qP/_autojob-%1-setter))]|Repeating: [case(setr(R, get(%qP/_autojob-%1-repeat)), 1, on, off)]|Next +autojob: [timefmt($m/$d/$y at 2 AM, get(%qP/_autojob-%1-next))]|Occurs [case(%qR, 1, every, in)]: [setr(I, get(%qP/_autojob-%1-interval))] [case(get(%qP/_autojob-%1-cycle), W, week, M, month, day)][if(gt(%qI, 1), s)], 36, |, 3)]%R[footer(if(isstaff(%#), +autojob/note [name(%qP)]/%1=<note> to set a note.))];}, {@pemit %#=alert(autojobs) %qE;} @set AJH/cmd-+autojob_view_person=no_parse &cmd-+autojob_note AJH=$+autojob/note */*=*:@switch setr(E, if(not(isstaff(%#)), Only staffers may set autojob notes., if(not(t(setr(P, pmatch(case(%0, me, %N, %0))), %#)), Could not find player %0., if(not(hasattr(%qP, _autojob-%1-text)), [name(%qP)] doesn't have a +autojob #%1.))))=, {&_autojob-%1-note %qP=%2; @pemit %#=alert(autojobs) You set a note for #%1: %2;}, {@pemit %#=alert(autojobs) %qE;} @set AJH/cmd-+autojob_note=no_parse &cmd-+autojob_cancel AJH=$+autojob/cancel */*:@switch setr(E, if(not(isstaff(%#)), Only staffers may set autojobs., if(not(t(setr(P, pmatch(case(%0, me, %N, %0))), %#)), Could not find player %0., if(not(hasattr(%qP, _autojob-%1-text)), [name(%qP)] doesn't have a autojob #%1.))))=, {@pemit %#=alert(autojobs) You have canceled [name(%qP)]'s autojob #%1. If you wish to recreate it, run these commands:%R%R+autojob [name(%qP)]=[get(%qP/_autojob-%1-text)] [case(get(%qP/_autojob-%1-repeat), 1, every, in)] [setr(I, get(%qP/_autojob-%1-interval))] [case(get(%qP/_autojob-%1-cycle), W, week, M, month, day)][if(gt(%qI, 1), s)][if(hasattr(%qP, _autojob-%1-note), %R+autojob/note [add(get(%qP/_autojobCount), 1)]=[get(%qP/_autojob-%1-note)])]; @wipe %qP/_autojob-%1-*;}, {@pemit %#=alert(autojobs) %qE;} @set AJH/cmd-+autojob_note=no_parse @pemit %#=SET A CRON JOB UP. Sample below. For the below code to work, you need to be either holding the cron or in its location. Otherwise, replace the word CRON with your cron's DBref. @force me=&cron_job_AutoJobs CRON=@trigger [num(AJH)]/trigger_autojobs &cron_time_AutoJobs CRON=|||02|00|
-
RE: Shell help request: +weather text file writing
@Thenomain How about... I build that file with built-in same-file-size settings? That'll require a little bit of changing, hmm. So, here:
&FN.GETMOONPHASE Weather Code Framework=[setq(0, trim(extract(textfile(v(I.FILE) ,moon),3,1,;), b, _))][if(t(%q0), %q0%b)][trim(extract(textfile(v(I.FILE),moon) ,2,1,;), b, _)] &FN.GETMOONPERCENT Weather Code Framework=trim(extract(textfile(v(I.FILE),moon), 1,1,;), b, _)
And change the weather.php file at the very end to:
switch ($b) { case 0: $lunar_phase = 'New'; break; case 1: $lunar_phase = 'Crescent'; $waxingwaning = 'Waxing'; break; case 2: $lunar_phase = 'Quarter'; $waxingwaning = 'Waxing'; break; case 3: $lunar_phase = 'Gibbous'; $waxingwaning = 'Waxing'; break; case 4: $lunar_phase = 'Full'; break; case 5: $lunar_phase = 'Gibbous'; $waxingwaning = 'Waning'; break; case 6: $lunar_phase = 'Quarter'; $waxingwaning = 'Waning'; break; case 7: $lunar_phase = 'Crescent'; $waxingwaning = 'Waning'; break; default: $lunar_phase = 'Error'; } fputs( $fr, "\n& moon \n" ); fputs( $fr, str_pad($percentage, 3, "_")); fputs( $fr, ";"); fputs( $fr, str_pad($lunar_phase, 8, "_")); fputs( $fr, ";"); fputs( $fr, str_pad($waxingwaning, 6, "_"));
I'm not sure whether the rest of the PHP file needs to be changed or not - I'm not seeing any padding but the code seems to work okay.
-
RE: Shell help request: +weather text file writing
@Glitch Thanks - updated my instructions. That will be useful in the future!
-
Code request: Jobs archived to SQL, now what?
So, we've got the lovely job archival thing @Thenomain posted installed. Thanks, @Thenomain! Now what, though? How do we read the archived jobs? I mean... I could whip up a quick forum-style thing and stick it on the site, but that'd be kinda ugly (I'm not a visual person) and would be a minor pain in the ass. OR... I could use whatever the big kids are using. What are the big kids using, though?
I assume this is some kind of PHP/website-based thing, or (I guess) a softcoded bit to read the database entries as board posts, which I suppose would work, but would be weird. After all, what's the point of putting it in the database if you aren't willing to make it available on the web?
So, anyone done this? Save me some time and later pain? Thanks in advance!
-
RE: Shell help request: +weather text file writing
@Thenomain Weird, I didn't have that problem. It seems to change automagically since the file is rewritten every time the PHP command is run. (It should always be about the same length save for a slight difference in the number of characters per line.)
-
RE: Shell help request: +weather text file writing
Right after getting that working, I had a request to make it work with moon phases. So, I did the following to the PHP file:
<?php /****************************************************************************** * * User configuration section. Please read included comments. * *****************************************************************************/ // Set the zipecode below to the zipcode you wish to gather weather information for. $zip = "70116"; // Set the $units variable to 'f' for Fahrenheit or 'c' for Celsius. $units = "f"; // If you are following the instructions then this variable should not need changing. $file = 'mux2.10/game/text/weather.txt'; /****************************************************************************** * * No configuration is required beyond this point. * *****************************************************************************/ $feed = 'http://weather.yahooapis.com/forecastrss?p=' . $zip . '&u=' . $units; $content = file_get_contents( $feed ); $rss = simplexml_load_string( $content ); if( !$rss ) die( 'Failed to retrieve RSS Weather feed' ); $copyright = $rss->channel->copyright; $base = $rss->channel->children( "http://xml.weather.yahoo.com/ns/rss/1.0" ); foreach( $base as $x => $base_item ) foreach( $base_item->attributes() as $k => $attr ) $channel[$x][$k] = $attr; $base = $rss->channel->item->children( "http://xml.weather.yahoo.com/ns/rss/1.0" ); foreach( $base as $x => $base_item ) { foreach( $base_item->attributes() as $k => $attr ) { if( $k == 'day' ) $day = $attr; if( $x == 'forecast' ) { $forecast[$x][$day . ''][$k] = $attr; } else { $forecast[$x][$k] = $attr; } } } $fr = fopen( $file, 'w' ); fputs( $fr, "&help\n" ); fputs( $fr, "Raw weather data for weather code.\n" ); $items = array( "units", "wind", "atmosphere", "astronomy" ); foreach( $items as $x ) { @fputs( $fr, "\n& " . $x . "\n" ); foreach( $channel[$x] as $val ) { @fputs( $fr, $val . ';' ); } } fputs( $fr, "\n& condition \n" ); foreach( $forecast['condition'] as $key => $val ) { if ( $key == "date" ) { @fputs( $fr, strtotime( $val ) . ';' ); } else { @fputs( $fr, $val . ';' ); } } $count = 1; foreach( $forecast['forecast'] as $x => $y ) { fputs( $fr, "\n& forecast" . $count . " \n" ); foreach( $forecast['forecast'][$x] as $key => $val ) { if ( $key == "date" ) { @fputs( $fr, strtotime( $val ) . ';' ); } else { @fputs( $fr, $val . ";" ); } } $count++; } $timestamp = time(); $year = date('Y', $timestamp); $month = date('n', $timestamp); $day = date('j', $timestamp); $c = $e = $jd = $b = 0; $lunar_phase =""; $waxingwaning =""; $percentage=""; if ($month < 3) { $year--; $month += 12; } ++$month; $c = 365.25 * $year; $e = 30.6 * $month; $jd = $c + $e + $day - 694039.09; //jd is total days elapsed $jd /= 29.5305882; //divide by the moon cycle $percentage = round($jd / 100); $b = (int) $jd; //int(jd) -> b, take integer part of jd $jd -= $b; //subtract integer part to leave fractional part of original jd $b = round($jd * 8); //scale fraction from 0-8 and round if ($b >= 8 ) { $b = 0;//0 and 8 are the same so turn 8 into 0 } switch ($b) { case 0: $lunar_phase = 'New Moon'; break; case 1: $lunar_phase = 'Crescent Moon'; $waxingwaning = 'Waxing'; break; case 2: $lunar_phase = 'Quarter Moon'; $waxingwaning = 'Waxing'; break; case 3: $lunar_phase = 'Gibbous Moon'; $waxingwaning = 'Waxing'; break; case 4: $lunar_phase = 'Full Moon'; break; case 5: $lunar_phase = 'Gibbous Moon'; $waxingwaning = 'Waning'; break; case 6: $lunar_phase = 'Quarter Moon'; $waxingwaning = 'Waning'; break; case 7: $lunar_phase = 'Crescent Moon'; $waxingwaning = 'Waning'; break; default: $lunar_phase = 'Error'; } fputs( $fr, "\n& moon \n" ); fputs( $fr, $percentage); fputs( $fr, ";"); fputs( $fr, $lunar_phase); fputs( $fr, ";"); fputs( $fr, $waxingwaning ); @fclose( $fr ); ?>
And then, slight changes to the softcode:
&C.+WEATHER Weather Code Framework=$+weather:@pemit %#=[setq(b,v(I.ANSI-HEADER))][setq(a,g)][header(Time %& Weather)]%r%r[center(ansi( %qa, Current Time),78)]%r[center([setq(0, extract(setr(2, convsecs(sub(secs(), 10800))), 4, 1))][setq(1, extract(%q0, 1, 1, :))][if(gt(%q1, 12), [sub(%q1, 12)]:[extract(%q0, 2, 1,:)], %q1:[extract(%q0, 2, 1, :)])] [if(gte(%q1, 12), pm, am)] on [extract(%q2,1,3)]%b[extract(%q2, 5, 1)], 78)]%r%r[center(ansi(%qa,Current Conditions),79)]%r%r[rjust(ansi(%qa, Temp:%b),12)][ljust(ulocal(FN.gettemp),25)][rjust(ansi(%qa,Sunrise:%b),12)][ljust(ulocal(FN.GETSUNRISE),30)]%r[ rjust(ansi(%qa,Wind:%b),12)][ljust(ulocal(FN.GETWIND),25)][rjust(ansi(%qa,Sunset:%b),12)][ljust(ulocal(FN.GETSUNSET),30)]%r[rjust(ansi(%qa,Condition:%b),12)][ljust(ulocal(FN.GETCONDITION),25)][rjust(ansi(%qa,Wind Chill:%b),12)][ljust(ulocal(FN.GETWINDCHILL),30)]%r[rjust(ansi(%qa,Humidity:%b),12)][ljust(ulocal(FN.GETHUMIDITY), 25)][rjust(ansi(%qa,Visibility:%b),12)][ljust(ulocal(FN.GETVIS),30)]%r[rjust(ansi(%qa,Pressure:%b),12)][ljust([ulocal(FN.GETPRES)]%b[switch(ulocal(FN.GETPRESSTATE2),0,Steady,1,Rising,2,Falling)], 24)][rjust(ansi(%qa,Moon:%b),13)][ljust([u(fn.getmoonphase)]%b%([u(fn.getmoonpercent)]%%%),30)]%r%r%r[space(12)][center(ansi(%qa,Today's Forecast),33)][center(ansi(%qa,Tomorrow's Forecast),33)]%r%r[rjust(ansi(%qa,Low:%b),12)][center(ulocal(FN.getforecast,today,low,long),33)][center(ulocal(FN.GETFORECAST,tmw,low,long),33)]%r[rjust(ansi(%qa,High:%b),12)][center(ulocal(FN.GETFORECAST,today,high,long),33)][center(ulocal(FN.GETFORECAST,tmw,high,long),33)]%r[rjust(ansi(%qa,Condition:%b),12)][center(ulocal(FN.GETFORECAST,today,text,long),33)][center(ulocal(FN.GETFORECAST,tmw,text,long),33)]%r%r[footer()] &FN.GETMOONPHASE Weather Code Framework=[setq(0, extract(textfile(v(I.FILE),moon),3,1,;))][if(t(%q0), %q0%b)][extract(textfile(v(I.FILE),moon),2,1,;)] &FN.GETMOONPERCENT Weather Code Framework=extract(textfile(v(I.FILE),moon),1,1,;) &L.CATS Weather Code Framework=units;wind;atmosphere;astronomy;condition;forecast1;forecast2;moon
And thus there is now a moon phase and illumination.
Note: I cannot take credit for any of this code except the most minor of modifications to c.+weather (call the already-existing ufuns! whee!) - the PHP code is slightly modified from http://jivebay.com/calculating-the-moon-phase/, and the softcode came from copying other softcode and changing it slightly.
-
RE: Shell help request: +weather text file writing
Steps I followed, for posterity's sake:
- Stick a <?php at the front of that PHP file. Save it in your shell account's root directory.
- On the game, create the weather softcode object (probably obvious but still important).
- Shell commands:
touch mux2.10/game/text/weather.txt
The purpose of that was to create the weather file - a nice, empty file. There's probably an easier way to do it but that's what I did.
ctrl-X yes, enter nano mux2.10/game/netmux.conf
Under where it says wizhelp text/wizhelp add this line:
helpfile weather text/weather
Then:
ctrl-X yes, enter php5 -f weather.php
- On your game, hit @restart.
Voila, weather!
One more step to undertake, though:
- Make it run every hour. In your shell account, do this:
crontab -e
Before # end, type:
0 * * * * php5 -f weather.php
Warning: if you're on a standard system, you're now in VI. Your server might be configured differently, however. You can tell it's emacs by the "File Edit ..." at the top. Nano is pretty obvious by the highlighted commands with simple text at the bottom. This is a minor pain in the ass if you're not familiar with Linux commands. So, three different quit commands to try - but be aware that they won't work for the wrong editor. Determine the editor FIRST, then try the command.
Vi: ESC-:wq Emacs: Ctrl-X-S, Ctrl-X-C Nano: ctrl-X, Yes, enter
That was an exercise in education right there. Shells aren't my thing, but they're definitely interesting.
Thank you @Cobaltasaurus and @Sponge, I really appreciate the help!
@Misadventure, upvoted for truth.
-
RE: Shell help request: +weather text file writing
@Cobaltasaurus, thank you! At least I know I'm not missing some obvious repository.
-
RE: Code offering: Generic +reminders code
Feel free to extend it! The "remind <player> to <stuff>" command is staff-only, but players who get such reminders can view and cancel them if they like. Some people might not like that.
The other part of this code, which I have not yet scribbled up but which should be pretty simple, is a +autojob object. It automatically opens a job on a player's behalf every X <weeks|months>. Handy for blood bathers and whatnot I'm told. (What's holding me up on making that one: I find the syntax ugly. +autojob <player>=<stuff> in <X> <time period> - it just... reads... bad. I have other stuff to do so I will get around to it.)
-
Shell help request: +weather text file writing
My google-fu is not turning up the shell-side setup for a piece of +weather code. This shell script presumably grabs the real-world weather for a specific place and sticks it in a text file. The +weather softcode then uses tinymux's textfile() function to read it. I have the softcode, I just don't have the shell knowledge necessary to get the back-end of it working, and I'm not great at Linux or shell scripts or any of that.
How does one go about writing that text file on the server, and then automating that process? (The automation I can probably figure out - it's the writing part that's really got me stumped.) Better yet, if there's a repository or site which hosts and includes help data for this code, please let me know. I've checked the sites listed in the Archive post pinned at the top of the forum and had no luck - if such a site exists, it should probably be added.
-
Code offering: Generic +reminders code
A friend asked me for this. I hope someone finds it useful. Ulterior motive: I have server/code questions. It's easier to get those answered when one has provided a suitable offering. I don't have a repository, so here you go.
Description/help file:
+remind <name|me> to <stuff>[ <in|every> [<X>] <days|weeks|months>] Examples: +remind me to Call Mom - will remind you every day +remind me to Howl at the moooon! every month +remind John to send that log in 3 days +reminders - Show all the reminders you have set. +reminder/view 1 - view reminder #1. +reminder/cancel 1 - get rid of reminder #1. +reminder/note 1=<stuff> - any notes you want the reminder to send you Notes: All reminders are sent at 2 AM. This code considers "a month" to be 28 days. Units of time that are not recognized will default to "days". Do not use this code for precision. Most third-party apps work better. Code notes: Required functions: header, footer, isstaff, alert Required objects: Cron object of some kind Required permissions: WIZARD due to attr reading/setting Limitations: Players can run out of space on themselves by setting a million reminders. Regrets: Did not code the display number to NOT be the ID. Credits: Melpomene@NOLA (melpomine@gmail.com|nola.mechanipus.com 2967)
Note: game is still in development. Feel free to log in and whatnot, just don't be surprised it's not up.
Code, unexploded because exploding is even spammier:
@create Generic Reminder Code <GRC>=10 @set GRC=SAFE INHERIT @desc GRC=%R[space(3)]+remind <name|me> to <stuff>[ <in|every> [<X>] <days|weeks|months>]%R%R[space(3)]Examples:%R[space(5)]+remind me to Call Mom - will remind you every day%R[space(5)]+remind me to Howl at the moooon! every month%R[space(5)]+remind John to send that log in 3 days%R%R[space(3)]+reminders - Show all the reminders you have set.%R[space(3)]+reminder/view 1 - view reminder #1.%R[space(3)]+reminder/cancel 1 - get rid of reminder #1.%R[space(3)]+reminder/note 1=<stuff> - any notes you want the reminder to send you%R%R[space(3)]Notes:%R[space(5)]All reminders are sent at 2 AM.%R[space(5)]This code considers "a month" to be 28 days.%R[space(5)]Units of time that are not recognized will default to "days".%R[space(5)]Do not use this code for precision. Most third-party apps work better.%R%R[space(3)]Code notes:%R[space(5)]Required functions: header, footer, isstaff, alert%R[space(5)]Required objects: Cron object of some kind%R[space(5)]Required permissions: WIZARD due to attr reading/setting%R[space(5)]Limitations:%R[space(7)]Players can run out of space on themselves by setting a million%R[space(7)]reminders.%R[space(5)]Regrets: Did not code the display number to NOT be the ID.%R%R[space(3)]Credits: Melpomene@NOLA (melpomine@gmail.com|nola.mechanipus.com 2967)%R &cmd-+remind GRC=$+remind * to *:@switch setr(E, if(and(not(strmatch(setr(P, pmatch(case(%0, me, %N, %0))), %#)), not(isstaff(%#))), Only staffers may set reminders for anyone other than themselves., if(not(t(%qP)), Could not find player %0., setq(3, extract(%1, sub(words(%1), 2), 3))[null(iter(%q3, if(isnum(%i0), setq(4, 1)))[if(not(t(%q4)), setq(4, switch(%q3, * month, M, * months, M, * day, D, * days, D, * weeks, W, * week, W, 0)))])][if(not(t(%q4)), setq(3, ))][setq(C, switch(%q3, * month, M, * months, M, * day, D, * days, D, * weeks, W, * week, W, 0))][setq(R, switch(%q3, * in *, I, in *, I, * every *, E, every *, E, 0))][setq(N, trim(squish(iter(%q3, if(isnum(%i0), %i0)))))][if(or(not(t(%qN)), not(isnum(%qN))), setq(N, 1))][setq(S, if(or(strmatch(%q3, * in *), strmatch(%q3, in *)), extract(%1, 1, sub(words(%1), match(revwords(%1), in))), if(or(strmatch(%q3, * every *), strmatch(%q3, every *)), extract(%1, 1, sub(words(%1), match(revwords(%1), every))), %1)))][if(not(t(%qS)), Could not figure out what you wanted me to remind you of!, setq(T, convtime(timefmt($a $b $d 02:00:00 $Y, add(secs(), mul(%qN, case(%qC, W, 604800, M, 2419200, 86400)))))))])))=, {&_reminderCount %qP=setr(I, add(default(%qP/_reminderCount, 0), 1)); &_reminder-%qI-text %qP=%qS; &_reminder-%qI-cycle %qP=[if(t(%qC), %qC, D)]; &_reminder-%qI-next %qP=%qT; &_reminder-%qI-interval %qP=%qN; &_reminder-%qI-setter %qP=%#; &_reminder-%qI-repeat %qP=[case(%qR, I, 0, 1)]; @switch [gt(strlen(get(me/people-[setr(A, v(peopleCount))])), 7500)]=1, {&peopleCount me=setr(A, add(%qA, 1));}; &people-%qA me=[setunion(v(people-%qA), %qP)]; @set me/people-%qA=NO_COMMAND; @pemit %#=alert(Reminders) [case(%#, %qP, You, name(%qP))] will receive a reminder to "%qS" [case(%qR, I, in, every)] [if(gt(%qN, 1), %qN%b)][case(%qC, W, week, M, month, day)][if(gt(%qN, 1), s)][case(%qR, I,, . Your next reminder is)] on [timefmt($m/$d/$y at 2 AM, %qT)].[case(%qC, M, %bPlease note that a month is considered to be 28 days long.)];}, {@pemit %#=alert(Reminders) %qE;} @set GRC/cmd-+remind=no_parse &peopleCount GRC=1 @set GRC/peopleCount=NO_COMMAND &trigger_reminders GRC=@dolist lattr(me/people-*)={@trigger me/trigger_parse-people=##;}; @set GRC/trigger_reminders=NO_COMMAND &trigger_parse-people GRC=@dolist v(%0)={@trigger/notify me/trigger_remind-person=##; @wait me={@trigger me/trigger_clean-person=##;};} @set GRC/trigger_parse-people=NO_COMMAND &trigger_clean-person GRC=@switch words(lattr(%0/_reminder-*-text))=0, {@dolist lattr(me/people-*)={&## me=[setdiff(v(##), %0)];};} @set GRC/trigger_clean-person=NO_COMMAND &trigger_remind-person GRC=@switch t(setr(P, pmatch(%0)))=1, {@dolist lattr(%qP/_reminder-*-text)={@switch setq(0, first(rest(##, -), -))[setq(C, get(%qP/_reminder-%q0-cycle))][setq(I, get(%qP/_reminder-%q0-interval))][setq(R, get(%qP/_reminder-%q0-repeat))][setq(T, get(%qP/_reminder-%q0-next))][lt(%qT, add(secs(), 3600))]=1, {@mail/quick %qP/Reminder: [titlestr(setr(V, get(%qP/##)))]=%R%TRemember to: %qV[if(hasattr(%qP, _reminder-%q0-note), %R%R%TNote: [get(%qP/_reminder-%q0-note)])]%R%R This is a [case(%qR, 1, repeating, one-time)] reminder [case(setr(S, get(%qP/_reminder-%q0-setter)), %qP, you set for yourself, [name(%qS)] set for you)]. [case(%qR, 1, Your next reminder will be on [timefmt($m/$d/$y at 2 AM, convtime(timefmt($a $b $d 02:00:00 $Y, add(secs(), mul(%qI, case(%qC, W, 604800, M, 2419200, 86400))))))]. This reminder will recur every %qI [case(%qC, W, week, M, month, day)][if(gt(%qI, 1), s)].)] To learn more about +reminders, type +help reminders. Thank you!; @switch %qR=1, {&_reminder-%q0-next %qP=[convtime(timefmt($a $b $d 02:00:00 $Y, add(secs(), mul(%qI, case(%qC, W, 604800, M, 2419200, 86400)))))];}, {@wipe %qP/_reminder-%q0-*;}}}} @set GRC/trigger_remind-person=NO_COMMAND &cmd-+reminders GRC=$+reminders:@pemit %#=if(t(setr(R, lattr(%#/_reminder-*-text))), header(Your active reminders)[space(3)]%cu[ljust(ID, 5)] [ljust(Reminder text, 57)] [ljust(Next, 8)]%cn%R[iter(%qR, space(3)[ljust(setr(0, first(rest(%i0, -), -))., 5)] [ljust(mid(get(%#/%i0), 0, 57), 57)] [ljust(timefmt($m/$d/$y, get(%#/_reminder-%q0-next)), 8)],, %R)][footer(+reminder/view # for more.)], alert(Reminders) You have no active reminders.); &cmd-+reminder_view GRC=$+reminder/view *:@switch setr(E, if(not(hasattr(%#, _reminder-%0-text)), You don't have a reminder #%0.))=, {@pemit %#=header(Reminder #%0)%r[wrap(Text: [get(%#/_reminder-%0-text)], 78, Left, space(3))]%R[if(hasattr(%#, _reminder-%0-note), wrap(Note: [get(%#/_reminder-%0-note)], 78, Left, space(3))%R)][columns(Set by: [name(get(%#/_reminder-%0-setter))]|Repeating: [case(setr(R, get(%#/_reminder-%0-repeat)), 1, on, off)]|Next reminder: [timefmt($m/$d/$y at 2 AM, get(%#/_reminder-%0-next))]|Occurs [case(%qR, 1, every, in)]: [setr(I, get(%#/_reminder-%0-interval))] [case(get(%#/_reminder-%0-cycle), W, week, M, month, day)][if(gt(%qI, 1), s)], 36, |, 3)]%R[footer(+reminder/note %0=<note> to set a note.)];}, {@pemit %#=alert(Reminders) %qE;} @set GRC/cmd-+reminder_view=no_parse &cmd-+reminder_note GRC=$+reminder/note *=*:@switch setr(E, if(not(hasattr(%#, _reminder-%0-text)), You don't have a reminder #%0.))=, {&_reminder-%0-note %#=%1; @pemit %#=alert(Reminders) You set a note for #%0: %1;}, {@pemit %#=alert(Reminders) %qE;} @set GRC/cmd-+reminder_note=no_parse &cmd-+reminder_cancel GRC=$+reminder/cancel *:@switch setr(E, if(not(hasattr(%#, _reminder-%0-text)), You don't have a reminder #%0.))=, {@pemit %#=alert(Reminders) You have canceled reminder #%0. If you wish to recreate it, run these commands:%R%R+remind me to [get(%#/_reminder-%0-text)] [case(get(%#/_reminder-%0-repeat), 1, every, in)] [setr(I, get(%#/_reminder-%0-interval))] [case(get(%#/_reminder-%0-cycle), W, week, M, month, day)][if(gt(%qI, 1), s)][if(hasattr(%#, _reminder-%0-note), %R+reminder/note [add(get(%#/_reminderCount), 1)]=[get(%#/_reminder-%0-note)])]; @wipe %#/_reminder-%0-*;}, {@pemit %#=alert(Reminders) %qE;} @set GRC/cmd-+reminder_note=no_parse @pemit %#=SET A CRON JOB UP. Sample below. For the below code to work, you need to be either holding the cron or in its location. Otherwise, replace the word CRON with your cron's DBref. @force me=&cron_job_GenericReminders CRON=@trigger [num(GRC)]/trigger_reminders &cron_time_GenericReminders CRON=|||02|00|
Usage, modification, and posting/hosting rights granted so long as you leave the credits in and unmodified except to append your own.