|
ralgith Sorcerer
Joined: 13 Jan 2006 Posts: 715
|
Posted: Tue Jan 31, 2006 9:08 am
Nifty little Text to Morse Code converter v2.0 |
Ok, first off credit for the idea and 99% of the code here goes to Yvves. I simple trashed the status window garbage (no offense Yvves ;)) and went with a trigger/alias system. All messages are coded using instructions below and decoded autmatically. Enjoy!
[edit]
Here is the link to Yvves original version!
http://forums.zuggsoft.com/phpbb/viewtopic.php?t=14665&highlight=morse
[/edit]
To use this simply type:
morse <channel> <message>
NOTES: Because of the inherent length of some morse codes for letters you should keep all morse'ed messages as short as possible to keep them from being truncated by your mud's channel code (automatic to MAX_STRING_LENGTH for circlmuds, dunno about other code bases).
Any questions PM me :)
Oh, and to prevent decoding your own messages (I like to have it decode my messages... but meh) simply add a #WAIT 500 before the #T+ MorseDecode line at the end of the morse alias. ;)
Code: |
#CLASS {MorseTalk}
#ALIAS morse {#t- MorseDecode;morse = %-2;#VAR morse %replace( @morse, " ", "/ ");#VAR morse %replace( @morse, a, ".- ");#VAR morse %replace( @morse, b, "-... ");#VAR morse %replace( @morse, c, "-.-. ");#VAR morse %replace( @morse, d, "-.. ");#VAR morse %replace( @morse, e, ". ");#VAR morse %replace( @morse, f, "..-. ");#VAR morse %replace( @morse, g, "--. ");#VAR morse %replace( @morse, h, ".... ");#VAR morse %replace( @morse, i, ".. ");#VAR morse %replace( @morse, j, ".--- ");#VAR morse %replace( @morse, k, "-.- ");#VAR morse %replace( @morse, l, ".-.. ");#VAR morse %replace( @morse, m, "-- ");#VAR morse %replace( @morse, n, "-. ");#VAR morse %replace( @morse, o, "--- ");#VAR morse %replace( @morse, p, ".--. ");#VAR morse %replace( @morse, q, "--.- ");#VAR morse %replace( @morse, r, ".-. ");#VAR morse %replace( @morse, s, "... ");#VAR morse %replace( @morse, t, "- ");#VAR morse %replace( @morse, u, "..- ");#VAR morse %replace( @morse, v, "...- ");#VAR morse %replace( @morse, w, ".-- ");#VAR morse %replace( @morse, x, "-..- ");#VAR morse %replace( @morse, y, "-.-- ");#VAR morse %replace( @morse, z, "--.. ");#VAR morse %replace( @morse, A, ".- ");#VAR morse %replace( @morse, B, "-... ");#VAR morse %replace( @morse, C, "-.-. ");#VAR morse %replace( @morse, D, "-.. ");#VAR morse %replace( @morse, E, ". ");#VAR morse %replace( @morse, F, "..-. ");#VAR morse %replace( @morse, G, "--. ");#VAR morse %replace( @morse, H, ".... ");#VAR morse %replace( @morse, I, ".. ");#VAR morse %replace( @morse, J, ".--- ");#VAR morse %replace( @morse, K, "-.- ");#VAR morse %replace( @morse, L, ".-.. ");#VAR morse %replace( @morse, M, "-- ");#VAR morse %replace( @morse, N, "-. ");#VAR morse %replace( @morse, O, "--- ");#VAR morse %replace( @morse, P, ".--. ");#VAR morse %replace( @morse, Q, "--.- ");#VAR morse %replace( @morse, R, ".-. ");#VAR morse %replace( @morse, S, "... ");#VAR morse %replace( @morse, T, "- ");#VAR morse %replace( @morse, U, "..- ");#VAR morse %replace( @morse, V, "...- ");#VAR morse %replace( @morse, W, ".-- ");#VAR morse %replace( @morse, X, "-..- ");#VAR morse %replace( @morse, Y, "-.-- ");#VAR morse %replace( @morse, Z, "--.. ");%1 Morse Code: @morse;#T+ MorseDecode}
#VAR morse {-... .-.. .- .... / -... .-.. .- .... } {code}
#CLASS 0
#CLASS {MorseTalk|MorseDecode}
#VAR morse {blah blah'} {}
#TRIGGER {Morse Code: (*)} {morse = %1;#VAR morse %replace( @morse, "-... ", b);#VAR morse %replace( @morse, "-.-. ", c);#VAR morse %replace( @morse, "..-. ", f);#VAR morse %replace( @morse, ".... ", h);#VAR morse %replace( @morse, ".--- ", j);#VAR morse %replace( @morse, ".-.. ", l);#VAR morse %replace( @morse, ".--. ", p);#VAR morse %replace( @morse, "--.- ", q);#VAR morse %replace( @morse, "...- ", v);#VAR morse %replace( @morse, "-..- ", x);#VAR morse %replace( @morse, "-.-- ", y);#VAR morse %replace( @morse, "--.. ", z);#VAR morse %replace( @morse, "-.. ", d);#VAR morse %replace( @morse, "--. ", g);#VAR morse %replace( @morse, "-.- ", k);#VAR morse %replace( @morse, "--- ", o);#VAR morse %replace( @morse, ".-. ", r);#VAR morse %replace( @morse, "... ", s);#VAR morse %replace( @morse, "..- ", u);#VAR morse %replace( @morse, ".-- ", w);#VAR morse %replace( @morse, ".. ", i);#VAR morse %replace( @morse, "-- ", m);#VAR morse %replace( @morse, "-. ", n);#VAR morse %replace( @morse, ".- ", a);#VAR morse %replace( @morse, ". ", e);#VAR morse %replace( @morse, "- ", t);#VAR morse %replace( @morse, "-...", b);#VAR morse %replace( @morse, "-.-.", c);#VAR morse %replace( @morse, "..-.", f);#VAR morse %replace( @morse, "....", h);#VAR morse %replace( @morse, ".---", j);#VAR morse %replace( @morse, ".-..", l);#VAR morse %replace( @morse, ".--.", p);#VAR morse %replace( @morse, "--.-", q);#VAR morse %replace( @morse, "...-", v);#VAR morse %replace( @morse, "-..-", x);#VAR morse %replace( @morse, "-.--", y);#VAR morse %replace( @morse, "--..", z);#VAR morse %replace( @morse, "-..", d);#VAR morse %replace( @morse, "--.", g);#VAR morse %replace( @morse, "-.-", k);#VAR morse %replace( @morse, "---", o);#VAR morse %replace( @morse, ".-.", r);#VAR morse %replace( @morse, "...", s);#VAR morse %replace( @morse, "..-", u);#VAR morse %replace( @morse, ".--", w);#VAR morse %replace( @morse, "..", i);#VAR morse %replace( @morse, "--", m);#VAR morse %replace( @morse, "-.", n);#VAR morse %replace( @morse, ".-", a);#VAR morse %replace( @morse, ".", e);#VAR morse %replace( @morse, "-", t);#VAR morse %replace( @morse, "/ ", " ");#say Morse Message: @morse}
#CLASS 0
|
|
|
|
|
Vitae Enchanter
Joined: 17 Jun 2005 Posts: 673 Location: New York
|
Posted: Thu Feb 02, 2006 4:10 pm |
sweet job.
I made a slight change to it only because while it might be hard to have periods for sentences in there, I figured at least you could have capital letters
So I added a ` mark before the caps
Quote: |
#CLASS {MorseTalk}
#ALIAS morse {
#T- MorseDecode
morse = "%-2"
#VARIABLE morse %replace( @morse, " ", "/ ")
#VARIABLE morse %replace( @morse, ".", "// ")
#VARIABLE morse %replace( @morse, "-", "/// ")
#VARIABLE morse %replace( @morse, a, ".- ")
#VARIABLE morse %replace( @morse, b, "-... ")
#VARIABLE morse %replace( @morse, c, "-.-. ")
#VARIABLE morse %replace( @morse, d, "-.. ")
#VARIABLE morse %replace( @morse, e, ". ")
#VARIABLE morse %replace( @morse, f, "..-. ")
#VARIABLE morse %replace( @morse, g, "--. ")
#VARIABLE morse %replace( @morse, h, ".... ")
#VARIABLE morse %replace( @morse, i, ".. ")
#VARIABLE morse %replace( @morse, j, ".--- ")
#VARIABLE morse %replace( @morse, k, "-.- ")
#VARIABLE morse %replace( @morse, l, ".-.. ")
#VARIABLE morse %replace( @morse, m, "-- ")
#VARIABLE morse %replace( @morse, n, "-. ")
#VARIABLE morse %replace( @morse, o, "--- ")
#VARIABLE morse %replace( @morse, p, ".--. ")
#VARIABLE morse %replace( @morse, q, "--.- ")
#VARIABLE morse %replace( @morse, r, ".-. ")
#VARIABLE morse %replace( @morse, s, "... ")
#VARIABLE morse %replace( @morse, t, "- ")
#VARIABLE morse %replace( @morse, u, "..- ")
#VARIABLE morse %replace( @morse, v, "...- ")
#VARIABLE morse %replace( @morse, w, ".-- ")
#VARIABLE morse %replace( @morse, x, "-..- ")
#VARIABLE morse %replace( @morse, y, "-.-- ")
#VARIABLE morse %replace( @morse, z, "--.. ")
#VARIABLE morse %replace( @morse, A, "`.- ")
#VARIABLE morse %replace( @morse, B, "`-... ")
#VARIABLE morse %replace( @morse, C, "`-.-. ")
#VARIABLE morse %replace( @morse, D, "`-.. ")
#VARIABLE morse %replace( @morse, E, "`. ")
#VARIABLE morse %replace( @morse, F, "`..-. ")
#VARIABLE morse %replace( @morse, G, "`--. ")
#VARIABLE morse %replace( @morse, H, "`.... ")
#VARIABLE morse %replace( @morse, I, "`.. ")
#VARIABLE morse %replace( @morse, J, "`.--- ")
#VARIABLE morse %replace( @morse, K, "`-.- ")
#VARIABLE morse %replace( @morse, L, "`.-.. ")
#VARIABLE morse %replace( @morse, M, "`-- ")
#VARIABLE morse %replace( @morse, N, "`-. ")
#VARIABLE morse %replace( @morse, O, "`--- ")
#VARIABLE morse %replace( @morse, P, "`.--. ")
#VARIABLE morse %replace( @morse, Q, "`--.- ")
#VARIABLE morse %replace( @morse, R, "`.-. ")
#VARIABLE morse %replace( @morse, S, "`... ")
#VARIABLE morse %replace( @morse, T, "`- ")
#VARIABLE morse %replace( @morse, U, "`..- ")
#VARIABLE morse %replace( @morse, V, "`...- ")
#VARIABLE morse %replace( @morse, W, "`.-- ")
#VARIABLE morse %replace( @morse, X, "`-..- ")
#VARIABLE morse %replace( @morse, Y, "`-.-- ")
#VARIABLE morse %replace( @morse, Z, "`--.. ")
%1 Morse Code: @morse
#T+ MorseDecode
}
#VARIABLE morse {Vitae-likes the Sauce.} {}
#CLASS 0
#CLASS {MorseTalk|MorseDecode}
#TRIGGER {Morse Code: (*)} {
morse = "%1"
#VARIABLE morse %replace( @morse, "`-... ", B)
#VARIABLE morse %replace( @morse, "`-.-. ", C)
#VARIABLE morse %replace( @morse, "`..-. ", F)
#VARIABLE morse %replace( @morse, "`.... ", H)
#VARIABLE morse %replace( @morse, "`.--- ", J)
#VARIABLE morse %replace( @morse, "`.-.. ", L)
#VARIABLE morse %replace( @morse, "`.--. ", P)
#VARIABLE morse %replace( @morse, "`--.- ", Q)
#VARIABLE morse %replace( @morse, "`...- ", V)
#VARIABLE morse %replace( @morse, "`-..- ", X)
#VARIABLE morse %replace( @morse, "`-.-- ", Y)
#VARIABLE morse %replace( @morse, "`--.. ", Z)
#VARIABLE morse %replace( @morse, "`-.. ", D)
#VARIABLE morse %replace( @morse, "`--. ", G)
#VARIABLE morse %replace( @morse, "`-.- ", K)
#VARIABLE morse %replace( @morse, "`--- ", O)
#VARIABLE morse %replace( @morse, "`.-. ", R)
#VARIABLE morse %replace( @morse, "`... ", S)
#VARIABLE morse %replace( @morse, "`..- ", U)
#VARIABLE morse %replace( @morse, "`.-- ", W)
#VARIABLE morse %replace( @morse, "`.. ", I)
#VARIABLE morse %replace( @morse, "`-- ", M)
#VARIABLE morse %replace( @morse, "`-. ", N)
#VARIABLE morse %replace( @morse, "`.- ", A)
#VARIABLE morse %replace( @morse, "`. ", E)
#VARIABLE morse %replace( @morse, "`- ", T)
#VARIABLE morse %replace( @morse, "`-...", B)
#VARIABLE morse %replace( @morse, "`-.-.", C)
#VARIABLE morse %replace( @morse, "`..-.", F)
#VARIABLE morse %replace( @morse, "`....", H)
#VARIABLE morse %replace( @morse, "`.---", J)
#VARIABLE morse %replace( @morse, "`.-..", L)
#VARIABLE morse %replace( @morse, "`.--.", P)
#VARIABLE morse %replace( @morse, "`--.-", Q)
#VARIABLE morse %replace( @morse, "`...-", V)
#VARIABLE morse %replace( @morse, "`-..-", X)
#VARIABLE morse %replace( @morse, "`-.--", Y)
#VARIABLE morse %replace( @morse, "`--..", Z)
#VARIABLE morse %replace( @morse, "`-..", D)
#VARIABLE morse %replace( @morse, "`--.", G)
#VARIABLE morse %replace( @morse, "`-.-", K)
#VARIABLE morse %replace( @morse, "`---", O)
#VARIABLE morse %replace( @morse, "`.-.", R)
#VARIABLE morse %replace( @morse, "`...", S)
#VARIABLE morse %replace( @morse, "`..-", U)
#VARIABLE morse %replace( @morse, "`.--", W)
#VARIABLE morse %replace( @morse, "`..", I)
#VARIABLE morse %replace( @morse, "`--", M)
#VARIABLE morse %replace( @morse, "`-.", N)
#VARIABLE morse %replace( @morse, "`.-", A)
#VARIABLE morse %replace( @morse, "`.", E)
#VARIABLE morse %replace( @morse, "`-", T)
#VARIABLE morse %replace( @morse, "-... ", b)
#VARIABLE morse %replace( @morse, "-.-. ", c)
#VARIABLE morse %replace( @morse, "..-. ", f)
#VARIABLE morse %replace( @morse, ".... ", h)
#VARIABLE morse %replace( @morse, ".--- ", j)
#VARIABLE morse %replace( @morse, ".-.. ", l)
#VARIABLE morse %replace( @morse, ".--. ", p)
#VARIABLE morse %replace( @morse, "--.- ", q)
#VARIABLE morse %replace( @morse, "...- ", v)
#VARIABLE morse %replace( @morse, "-..- ", x)
#VARIABLE morse %replace( @morse, "-.-- ", y)
#VARIABLE morse %replace( @morse, "--.. ", z)
#VARIABLE morse %replace( @morse, "-.. ", d)
#VARIABLE morse %replace( @morse, "--. ", g)
#VARIABLE morse %replace( @morse, "-.- ", k)
#VARIABLE morse %replace( @morse, "--- ", o)
#VARIABLE morse %replace( @morse, ".-. ", r)
#VARIABLE morse %replace( @morse, "... ", s)
#VARIABLE morse %replace( @morse, "..- ", u)
#VARIABLE morse %replace( @morse, ".-- ", w)
#VARIABLE morse %replace( @morse, ".. ", i)
#VARIABLE morse %replace( @morse, "-- ", m)
#VARIABLE morse %replace( @morse, "-. ", n)
#VARIABLE morse %replace( @morse, ".- ", a)
#VARIABLE morse %replace( @morse, ". ", e)
#VARIABLE morse %replace( @morse, "- ", t)
#VARIABLE morse %replace( @morse, "-...", b)
#VARIABLE morse %replace( @morse, "-.-.", c)
#VARIABLE morse %replace( @morse, "..-.", f)
#VARIABLE morse %replace( @morse, "....", h)
#VARIABLE morse %replace( @morse, ".---", j)
#VARIABLE morse %replace( @morse, ".-..", l)
#VARIABLE morse %replace( @morse, ".--.", p)
#VARIABLE morse %replace( @morse, "--.-", q)
#VARIABLE morse %replace( @morse, "...-", v)
#VARIABLE morse %replace( @morse, "-..-", x)
#VARIABLE morse %replace( @morse, "-.--", y)
#VARIABLE morse %replace( @morse, "--..", z)
#VARIABLE morse %replace( @morse, "-..", d)
#VARIABLE morse %replace( @morse, "--.", g)
#VARIABLE morse %replace( @morse, "-.-", k)
#VARIABLE morse %replace( @morse, "---", o)
#VARIABLE morse %replace( @morse, ".-.", r)
#VARIABLE morse %replace( @morse, "...", s)
#VARIABLE morse %replace( @morse, "..-", u)
#VARIABLE morse %replace( @morse, ".--", w)
#VARIABLE morse %replace( @morse, "..", i)
#VARIABLE morse %replace( @morse, "--", m)
#VARIABLE morse %replace( @morse, "-.", n)
#VARIABLE morse %replace( @morse, ".-", a)
#VARIABLE morse %replace( @morse, ".", e)
#VARIABLE morse %replace( @morse, "-", t)
#VARIABLE morse %replace( @morse, "/// ", "-")
#VARIABLE morse %replace( @morse, "// ", ".")
#VARIABLE morse %replace( @morse, "/ ", " ")
#SAY Morse Message: @morse
}
#CLASS 0 |
Thing was that you have to have the decoded capital letters 1st otherwise you get it wrong
EX:
morse Spouse Vitae likes the Sauce
Morse Message: `vitae likes the `sauce
rather than
Morse Message: Vitae likes the Sauce
The whole prob is really the periods and dashes if they are part of whats being said.
I'd try adding a double ` mark due to the letter e (``.)
But it just translated it as a `e
Didn't try another char tho like // rather than ` so maybe that will work.
Just annoying to not be able to use something like a period or a dash if ya need it.
EDIT:
Changed code to work with - and .
Ex
morse Spouse Vitae-likes the Sauce.
Spouse Morse Code: `...- .. - .- . /// .-.. .. -.- . ... / - .... . / `... .- ..- -.-. . //
(Spouse): Morse Code: `...- .. - .- . /// .-.. .. -.- . ... / - .... . / `... .- ..- -.-. . //
Morse Message: Vitae-likes the Sauce. |
|
|
|
ralgith Sorcerer
Joined: 13 Jan 2006 Posts: 715
|
Posted: Sat Feb 04, 2006 6:03 am |
I like the update Vitae
I think I'll implement it :)
And add some more punctuation allows :D |
|
_________________ CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate |
|
|
|
Vitae Enchanter
Joined: 17 Jun 2005 Posts: 673 Location: New York
|
Posted: Mon Feb 06, 2006 2:56 pm |
Your welcome. Sometimes it's good to be anal...err...can i say that on this forum?...NOOO DON'T DELETE ME!!!
Anywho, the only punctuation that should need to be addressed is really the / now.
Other than that all should be well i think. |
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|