superior
|
  |
| Joined: 13 Apr 2008 |
| Total Posts: 1662 |
|
|
| 21 Aug 2011 12:56 AM |
tab = {72, 101, 108, 108, 111, 95, 87, 111, 114, 108, 100} for i = 1, #tab do print(string.char (tab[i])) end
How would I print all of this on one line?
It prints the characters going down... |
|
|
| Report Abuse |
|
|
superior
|
  |
| Joined: 13 Apr 2008 |
| Total Posts: 1662 |
|
| |
|
|
| 21 Aug 2011 01:14 AM |
| Isn't it string.byte for number to string? |
|
|
| Report Abuse |
|
|
superior
|
  |
| Joined: 13 Apr 2008 |
| Total Posts: 1662 |
|
|
| 21 Aug 2011 01:21 AM |
| string.char() changes a number into a string. |
|
|
| Report Abuse |
|
|
superior
|
  |
| Joined: 13 Apr 2008 |
| Total Posts: 1662 |
|
|
| 21 Aug 2011 01:38 AM |
Well this is how I can do it: tab = {72, 101, 108, 108, 111, 95, 87, 111, 114, 108, 100} print(string.char (tab[1],tab[2],tab[3],tab[4],tab[5],tab[6],tab[7],tab[8],tab[9],tab[10],tab[11]))
Is there any other way I could do it in one line without repeating "tab[number]" ? Thanks. |
|
|
| Report Abuse |
|
|
|
| 21 Aug 2011 01:44 AM |
tab = { watever } str = "" for i = 1, #tab do str = str .. string.char(tab[i]) end print(str)
or in normal lua, i think you can use io.write so it doesn't add any newlines
-Like a boss. |
|
|
| Report Abuse |
|
|
superior
|
  |
| Joined: 13 Apr 2008 |
| Total Posts: 1662 |
|
|
| 21 Aug 2011 02:34 AM |
| Thanks a ton! It prints "Hello_World" if you were wondering. :P |
|
|
| Report Abuse |
|
|
| |
|
superior
|
  |
| Joined: 13 Apr 2008 |
| Total Posts: 1662 |
|
|
| 21 Aug 2011 02:35 AM |
| Gee... You don't have to be harsh about it. D: I was just saying... |
|
|
| Report Abuse |
|
|