ID:156837
 
I'm trying to code a language system for my game in progress and i need help converting letters into other letters...anyone mind helping me?
text2ascii is rather helpful for this type of thing
You want to replace occurrences of string X in string Z with string Y. This can be done by using findtext() and copytext(). In this case since you're only looking for one character, you can indeed use text2ascii() instead of findtext().

Or, you can use one of the tried-ol' utility ReplaceText() (and similar) procs people have written and published in libraries, forum posts, and the snippets database. Here's a quick link to one from the latter: http://www.byond.com/members/jtgibson/forum?id=243
In response to GhostAnime
can you maybe show me an example?
In response to Kaioken
thanks Kaioken your link is really helping (so far)
In response to Kaioken
um....if i wanted to convert a whole sentence, how would i go about doing that?
You'd want to create an associative list, describing the transformations. For example:

var/list/language = list("a"="o", "b"="d")


Then, go through the string, one letter at a time using copytext() and a for(var/i = 1 to length(text)) loop. For each letter X, if X is in the list language, add language[X] to your translated string. Otherwise, just add X (as those would likely be punctuation).
In response to Fevablista
Coincidentally, I made something like this a few months back.
client/verb
xlate(t as text)
for(var/x=1 to languages.len)
translate(t,languages[x])

proc
//translate string, into the language from the language list (case-sensitive)
//the proper is a boolean that determines if the resulting string of letters should be capitalized
translate(string,language,proper)
var/l=length(string)
for(var/x=1 to l)
var/s=copytext(string,x,(x==l ? 0 : x+1))

var/b=((text2ascii(s) < 97) ? TRUE : FALSE)
s= (asciisymbol(s) ? s : ckey(s))
. += "[(("[s]" in languages[language]) ? \
\
(b ? uppertext(languages[language][s]) : \
languages[language][s]) : \
\
"[s]" )]
"

.=(proper ? make_proper(.) : .)
world << .

asciisymbol(n)
switch(text2ascii(n))
// ! & ' , - . : ; ?
if(32,33,38,39,44,45,46,58,59,63)return TRUE
else return FALSE


make_proper(text)
.=text
var/first=uppertext(copytext(.,1,2))
first+=lowertext(copytext(.,2,0))
.=first

// and, say, if we wanted to speak like a hissing animal..
var/list/languages=list(\
"Hissing"=list( "a"="ay",\
"b"="b",\
"c"="cth",\
"d"="th",\
"e"="rr",\
"f"="ef",\
"g"="gy",\
"h"="th",\
"i"="ih",\
"j"="juh",\
"k"="ck",\
"l"="",\
"m"="mm",\
"n"="nn",\
"o"="ah",\
"p"="pth",\
"q"="",\
"r"="aa",\
"s"="sa",\
"t"="gh",\
"u"="euh",\
"v"="b",\
"w"="wh",\
"x"="ck",\
"y"="hy",\
"z"="se"\
))

I can't say it's the best implementation, but it should be sufficient for small amounts of text.
In response to DivineTraveller
thanks for the code....not sure if i'll use it though, i used another proc to make the languages and it took all day, lol...this one looks better though -.- thanks again