table = {"A", "B", "C")
Is there any way I can convert this totString = "ABC"
Without knowing how many variables I have stored?Question was answered here : http://stackoverflow.com/questions/23148716/can-i-connect-the-variables-in-a-table
table = {"A", "B", "C")
Is there any way I can convert this totString = "ABC"
Without knowing how many variables I have stored?I ninja'd you while editing my main post… LOLYou want to use table.concat() for that. for more info about that function see here.
for i = 1,#table do
newString = newString .. table[i]
Yeah, I know. That was an example. My actual code is long and mostly irrelevant (making a virtual keyboard on screen :P/>)EDIT: Ninja'd
Yes. You would use #table to find the number of variables stored. For example:for i = 1,#table do
Then you would use the double dot/period ( .. ) to concatenate each one onto the other like sonewString = newString .. table[i]
If you need a more explicit example let me know. One other thing - it's not a good idea to name your table "table" - especially if you don't localize the variable name 'table'
I assumed it would… How would it know which comes first otherwise? Not a problem in this case.do note however that table.concat only works on indexed tables, ergo any values stored under a key will not appear in the resultant string.
local tbl = {}
tbl[1] = "a"
tbl["a"] = "b"
local str = ""
for _,v in pairs(tbl) do
str = str..v
end
Please note however the order may not be preserved when this method is used.