User:Babbage

From Serenity : The Wiki
Jump to: navigation, search

Babbage's player does a lot of programming as a hobby. He's written a fair amount of softcode to solve various problems he's had with the game. If you have any questions about this stuff, or just wanna chat about code, feel free to page or @mail me in game.

In order for any of these to work, you have to run @set me=!NO_COMMAND. You should only have to do this once.

Contact

There's a few ways to contact Babbage's player outside the MUSH.

MUSHcode

Chanstat

Running chanstat gives you a list of all the channels you're listening to, whether or not you're gagging the channel, how many other online people are listening, the flags you have set, and your chan/title.

&CMD`CHANSTAT ME=$chanstat: THINK [ansi(r,repeat(=,70))]%r[ansi(wh,align(20 7 7 5 27,Channel,Status,Users,Flags,Title))]%r[iter(channels(me,;),align(20 7 7 5 27,##,if(comp(cstatus(##,me),Gag),ansi(gh,On),ansi(yh,Gag)),words(cwho(##)),cflags(##,me),ctitle(##,me))%r,;,)][ansi(r,repeat(=,70))]

Language Pose

Language Pose is a command that will emit one pose in a foreign language of your choice, then switch you back to English. If you don't have the language you're trying to pose in, it will just emit in English (that's not a bug, it's a feature). To use it, type lp <language>=<pose>. For example, I might say lp french=Babbage turns around and mutters, "Everyone on this ship who doesn't speak French is a nutcase.".

&CMD`LP ME=$lp *=*:+speak %0;@wait 1=@emit %1;@wait 2=+speak english

lwhere

Lwhere is like +where <planet> on steroids. To use it, you type lwhere <location>. You'll get the names, exact locations, online times, and idle times of all logged in players who are in a room whose name contains <location>. For example; lwhere perse will show you all players on Persephone, lwhere spaceport will show you anybody in a spaceport on any planet, and lwhere dregs will only show you who's in the Dregs.

&CMD`LWHERE ME=$lwhere *:THINK [ansi(r,repeat(=,78))]%r[ansi(wh,align(10 30 14 14,Name,Location,On,Idle))][iter(iter(lwho(),if(where(##),if(strmatch(name(where(##)),*%0*),##,))),if(comp(##,NULL),%r[align(10 30 14 14,[left(name(##),10)],[left(name(room(##)),30)],[left(timestring(conn(##)),14)],[left(timestring(idle(##)),14)])],[%r]))]%r[ansi(r,repeat(=,78))]

Npooc

Npooc is a command for having your NPCs perform out-of-character actions. It really serves no purpose other than OOC sillyness. If you have a ferret named Juliet, and want it to OOCly claw Babbage's eyes out (and who hasn't, at one point or another), you'd type npooc Juliet claws Babbage's eyes out.

&CMD`NPOOC ME=$npooc *:@remit here=[ansi(yh,<OOC>)] [ansi(c,\(NPC\))] %0

Friendlist 2

Friendlist 2 lists your friends' locations, online times and idle times all in one command. It allows you to split your friends into multiple groups. For example, you could have a default list of friends that contains the entire crew of your ship, which you can look at with the friendlist command. But if you also have a certain group of friends that you like to play with when you're on a different ship, or on Persephone, you'd have a different list that you can call by a specific name (for example, friendlist persephone). This is a little more complicated to use than my original friendlist command, but much more handy:

&CMD`FRIENDLIST me=$friendlist*: THINK [ansi(r,repeat(=,78))]%r[ansi(wh,align(10 30 14 14,Name,Location,On,Idle))][iter(default(me/lists`[trim(%0)],get(me/lists`friends)),if(comp(##,NULL),%r[align(10 30 14 14,[left(name(##),10)],[left(if(room(##),name(room(##)),Unfindable),30)],[left(if(comp(conn(##),-1),timestring(conn(##)),Offline),14)],[left(if(comp(idle(##),-1),timestring(idle(##)),Offline),14)])],[%r]))]%r[ansi(r,repeat(=,78))]

If you have the old version of friendlist on your character, you'll also need to get rid of that by running:

&FRIENDLIST me

Use

To show your default friends list, you'd type friendlist. This uses the &LISTS`FRIENDS attribute on your character. If you wanna create a second list, of friends you play with while on Persephone for example, you'd create an attribute called &LISTS`PERSE and look at those friends with the command friendlist perse.

Masswave

Update 8/14/2009 I changed the masswave code a little. Now it should be a little less work for the server, and I fixed a possible bug where things can get a little wonky if you include an '=' or a '/' in your masswave.

Masswave allows you to send a +wave to more than one person at a time, similar to what you can do with page and @mail. Usage is masswave <list of recipiants, separated by spaces>=<message subject>/<message body>. You'll wanna look out for names that have spaces in them, as those will be treated as two separate names. The way only around this is to +finger the person and find a one-word alias.

&CMD`MASSWAVE ME=$masswave *: @dolist [first(%0,=)] = +wave ##=[rest(%0,=)]

Shipstop

Shipstop helps you figure out when you need to cut your engines to stop your ship. If you type shipstop <speed> <acceleration> it will tell you how close to a planet you need to get before you need to cut your engines.

&CMD`SHIPSTOP me=$shipstop * *:THINK Set speed to zero when distance is between [sub(div(div(power(%0,2),mul(2,%1)),3600),9)] and [add(div(div(power(%0,2),mul(2,%1)),3600),9)].

Realeta

Realeta takes a number of minutes and tells you what time it will be when that many minutes has passed. This is good if you're flying a ship, and wanna set an alarm for when it's time to land. To use it, type realeta <minutes>. Keep in mind that your result will be in the MUSH's local time, which is EST for Serenity.

&CMD`REALETA me=$realeta *: think Your arrival time is: [convsecs(add(secs(),mul(%0,60)))]

Nomweek

This is a nifty command that tells you how many noms per week you've been earning. Just type nomweek and it will tell you.

&CMD`NOMWEEK me=$nomweek: think You've been earning [fdiv(get(me/noms),fdiv(sub(secs(),convtime(ctime(me))),604800))] noms per week.

Closet

Closet is a really simple one. Type closet and it shows you all the outfits you have available from the descer.

&CMD`CLOSET me=$closet: ex me/OUTFIT_*

Other Code

Code that I write in languages other than MUSHcode is mostly designed for Linux. It'll probably run just fine on a Mac. You'd have to wrestle a bit to get any of this to run in Windows.

viewlog.sh

This is a quick and dirty Linux shell script that will clean up your log files for you. Open a terminal and run ./viewlog.sh <logfile> if you only want IC poses, or run ./viewlog.sh <logfile> ooc if you also want OOC stuff and pages. It works by looking for the language tag at the end of poses, so it has problems when people write poses with line breaks (it only grabs the last line of the pose).

if test $2 = "ooc"
then
  egrep "\[3[1/2]m(Arabic|Greek|Latin|Chinese|Hebrew|Romany|English|Hindi|Russian|French|Italian|Sign Language|Gaelic|Japanese|Spanish|German|Korean)|whispers: |You whisper, |You sense: |senses: |33m<OOC>|33mOOC:|You paged | pages:|Long distance to |From afar, " $1
else
  egrep "\[3[1/2]m(Arabic|Greek|Latin|Chinese|Hebrew|Romany|English|Hindi|Russian|French|Italian|Sign Language|Gaelic|Japanese|Spanish|German|Korean)|whispers: |You whisper, |You sense: |senses: " $1
fi

decolor.py

Just as quick and dirty. This Python script strips out all of the ANSI color codes from your log file. You can pass your logfile as a command line argument such as python decolor.py <logfile> or you can pipe the output from another command, such as ./viewlog.sh <logfile> | python decolor.py.

import re,sys

if len(sys.argv) > 1:
  file = open(sys.argv[1],"r")
  text = file.read()
  file.close()
else:
  text = sys.stdin.read()

escape = chr(27)
expression = escape+"\\[.*?m"
text = re.sub(expression,"",text)

print text

ictime.py

This script converts IC time (must be given in Epoch time) into a RL time and date. Seems to be off by a few hours, and I'm not entirely sure why -- but is still works for rough estimates.

 #!/usr/bin/python
 """
 SerenityMUSH IC time to RL time converter
 By Babbage
 Last updated: May 2, 2010
 
 This script takes an IC time, and figures out the RL date.
 It's sometimes off, so double-check with +findictime for accuracy.
 """
 
 import time
 
 while 1:
   magic = 15023759672  #This number derived from the equation IC-Time = 2 * RL-Time + magic
 
   #This must be done in Epoch time, because the function to convert time strings to Epoch
   #doesn't work very far into the future.  You can convert your time to Epoch time with:
   #http://www.onlineconversion.com/unix_time.htm
   target = int(raw_input("Enter an IC date in EPOCH TIME: "))
   
   newtime = (target - magic) / 2
   print time.strftime("%d %b %Y %H:%M", time.localtime(newtime))