DrWaffler
|
  |
| Joined: 16 Sep 2011 |
| Total Posts: 4248 |
|
|
| 10 Jul 2013 05:32 AM |
Haha, was just talking about this, and how Tables are my mortal enemy.
So if I had a large string, structured so names were separated by spaces.
Example:
"player1 drwaffler player2 shedletsky"
How would I insert the values into a table, so it would return.
for k,v in pairs(MyTable) do print(k,v) end
With the output of
1 player1 2 drwaffler 3 player2 4 shedletsky
|
|
|
| Report Abuse |
|
|
blocco
|
  |
| Joined: 14 Aug 2008 |
| Total Posts: 29474 |
|
|
| 10 Jul 2013 05:37 AM |
local t = {}; for name in str:gmatch("(%a+)%s?") do t[#t+1] = name end
I didnt test that, see if it works |
|
|
| Report Abuse |
|
|
|
| 10 Jul 2013 05:41 AM |
local Table = { }
for Word in String:gmatch("%w+") do table.insert(Table, Word) end |
|
|
| Report Abuse |
|
|
DrWaffler
|
  |
| Joined: 16 Sep 2011 |
| Total Posts: 4248 |
|
|
| 10 Jul 2013 05:42 AM |
Care explaining to me the spazzy symbols involved with that?
The wiki just says "Here, put these in, we aren't going to tell you their meaning at all" |
|
|
| Report Abuse |
|
|
blocco
|
  |
| Joined: 14 Aug 2008 |
| Total Posts: 29474 |
|
|
| 10 Jul 2013 05:43 AM |
http://www.lua.org/pil/20.2.html
yeah %w+ is better |
|
|
| Report Abuse |
|
|
DrWaffler
|
  |
| Joined: 16 Sep 2011 |
| Total Posts: 4248 |
|
|
| 10 Jul 2013 05:48 AM |
| Thanks for that link! It did a great job of explaining it. Tables aren't my enemy here, only lack of relevant information. |
|
|
| Report Abuse |
|
|