proc
TextToList(var/t2l)
var/list/text1[length(t2l)]
var/i=1
for(i=1,i<=length(t2l),i++)
usr << i
var/text = copytext(t2l,i,i+1)
text1 += list(i=text)
return text1
Problem description:
I am trying to make a proc that turns an string into a list of individual letters. The code compiles perfectly fine, but when I try to view the list it gives me ONE single item on the list which is "i" instead of the individual numerical numbers. The variable I is changing perfectly fine, but for some reason when adding to the list it will not take the value of 'i' it takes the name of the var and puts it into the list (4 times in the example below.)
What the code should do:
1) Take the string
2) Make a list of each individual letter
3) Return that to the calling proc/verb.
What the list should be (when t2l = "Test")
list(1="T",2="e",3="s",4="t")
OR
list(0="T",1="e",2="s",3="t")
What seems to be the actual result (when t2l = "Test")
list("i"="T","i"="e","i"="s","i"="t")
Any help with my conundrum will be very appreciated (especially if a better way then "copytext" for this.)
(Also please not its been forever since I have programmed in byond, I've been working in java for a while so I'm pretty rusty at this. :P)