Re: Lower case?

"[email protected]" <[email protected]>(by way of [email protected]) Wed, 27 Apr 2005 17:32:48 +0200 (MEST)
Newsgroups gmane.comp.games.mud.client.lyntin
Message-ID <[email protected]>
> Anyone know a good way to get a variable to lowercase?
> 
> Say for example:
> 
> #action {^%1 waves at you.} {wave %1}
> 
> But I want %1 to be forced to lowercase before being sent to the mud. Any
> thoughts?

I would write a small python module with a command which does exactly that -
changing a variable to lowercase.

If you are using the CVS checkout, something along the lines of
---8<---
def Lower(words, input, seslist):
  data.currsession.WriteTo(input.split(" ", 1)[1].lower()+"\n")

def init_player():
  #... <cut>
  data.theapp.AddCommand("lower", Lower)
--->8---
(added to player.py)

Only tested without #action though, i don't know whether it works with the
%1 stuff.

If you are using LynTin 4.1.1 (or similar; just tested with this one):
---8<---
def lower_cmd(ses, args, input):
  """
  Sends input straight to the mud, after changing each character to
lowercase.

  category: commands
  """
  if (ses.getName() == "common"):
    exported.write_error("lower: cannot send data to the common session.",
ses)
    return

  ses.writeSocket(args["input"].lower() + "\n")

commands_dict["lower"] = (lower_cmd, "input=")
--->8---

This definitely works for me (tested). Just use ,,#action {^%1 waves at
you.} {#lower {wave %1}}'' then instead.


Btw, what happened to the CVS version? 4.1.1 is very neat, absolutely great
for hacking (i hadn't looked at LynTin for aaaages... way over a year i
think, and i managed to do this little thing in ten minutes, debugging
included, Yay! :D), but the CVS checkout is ... umm. I mean, having specific
stuff like "/usr/local/bin/python" in the #! line (not that that was hard to
change for me, but something like "/usr/bin/env python" might be better),
and then it was awful to find out how to send stuff to sessions, the #help
system didn't work as nice as the 4.1.1 one, i had no idea where to put my
new command into, etc. ...

Regards,
Tiger.

-- 
+++ GMX - die erste Adresse für Mail, Message, More +++

10 GB Mailbox, 100 FreeSMS  http://www.gmx.net/de/go/topmail


-------------------------------------------------------
SF.Net email is sponsored by: Tell us your software development plans!
Take this survey and enter to win a one-year sub to SourceForge.net
Plus IDC's 2005 look-ahead and a copy of this survey
Click here to start!  http://www.idcswdc.com/cgi-bin/survey?id=105hix