ID:168598
 
I need a proc to reverse the order of a text string (such as turning "Testums" to "smutesT") and possibly another proc to just rearrange the order randomly
p_utility has a procedure to reverse your text order. Download Here.
proc
ReverseText(T)
var/newT
for(var/i=length(T),i>0,i--)
newT+=copytext(T,i,i+1)
return newT


Pretty simple so I didn't comment it, if you don't understand something, please ask.
I need a proc to reverse the order of a text string (such as turning "Testums" to "smutesT") and possibly another proc to just rearrange the order randomly

proc/RevStr(txt)
var/i = length(txt)+1
. = ""
while(--i)
. += copytext(txt,i,i+1)

proc/ShuffleStr(txt)
var/len = length(txt)
for(var/i = 1; i <= len; ++i)
var/j = rand(1,len)
var/k = i
if(j != k)
if(j > k)
j ^= k; k ^= j; j ^= k
txt = copytext(txt,1,j) + copytext(txt,k,k+1) + copytext(txt, j + 1, k) + copytext(txt, j, j+1) + copytext(txt, k+1)
return txt
In response to Theodis
The Shuffletext wasn't quite what I wanted; I wanted more like it randomizing the whole thing instead of keeping order the same. Is there an easy way to do that?
In response to Cowdude
The Shuffletext wasn't quite what I wanted; I wanted more like it randomizing the whole thing instead of keeping order the same. Is there an easy way to do that?

Uh? Randomizing the whole thing as in building a random string? ShuffleStr randomizes the order of the letters in the string.
In response to Theodis
oh I see =/ just the two times I used it they were so close I didn't notice x_x (too used to seeing typoes that my eyes fix it I guess XD)

I had of course inputted "Testums" and it came out "stusmTe", which looks like it just put the "Te" on the end if you read it fast :P
never mind then it'll work yays