ID:156837
Jul 15 2010, 12:03 pm
|
|
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?
|
Jul 15 2010, 12:13 pm
|
|
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 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
|