Krelinos
|
  |
| Joined: 09 Jan 2010 |
| Total Posts: 425 |
|
|
| 25 Nov 2012 10:41 AM |
| How would I copy content from one table to another? |
|
|
| Report Abuse |
|
|
|
| 25 Nov 2012 10:46 AM |
for i,v in pairs(table) do table.insert(othetable,v) --Clones the part into other table table.remove(table,i) --Removes the part you just copied end
>Much love, YaYaBinks3. |
|
|
| Report Abuse |
|
|
eJorge
|
  |
| Joined: 09 Jun 2011 |
| Total Posts: 5966 |
|
|
| 25 Nov 2012 10:47 AM |
You mean indexing?
tab = {thing = 123, thing123 = "thing"} num = tab.thing123 print(num) > "thing" |
|
|
| Report Abuse |
|
|
Krelinos
|
  |
| Joined: 09 Jan 2010 |
| Total Posts: 425 |
|
| |
|
|
| 25 Nov 2012 12:37 PM |
YaYa isn't quite right.
for I, v in pairs(oldtable) do rawset ( othertable, i, v ) end |
|
|
| Report Abuse |
|
|
|
| 25 Nov 2012 01:16 PM |
@Firefox I don't think someone who is asking how to index cares about metatables. |
|
|
| Report Abuse |
|
|
|
| 25 Nov 2012 02:59 PM |
| I didn't do anything with regards to metatables .... |
|
|
| Report Abuse |
|
|
|
| 25 Nov 2012 02:59 PM |
for i, v in pairs(oldtable) do rawset ( othertable, i, v ) end
My phone auto-capitalized the i. Sorry about that. |
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 25 Nov 2012 03:17 PM |
You guys make me sick. Sick I say!
Why not just reference it?
tab1 = {"Hi","dude"}
tab2 = tab1
print(tab2[1]) --Hi |
|
|
| Report Abuse |
|
|
|
| 25 Nov 2012 06:30 PM |
| Because that does not COPY it. ^_^ |
|
|
| Report Abuse |
|
|