|
| 07 Feb 2017 06:20 PM |
So, I have a table that looks like this:
local Mytable ={ ["Money"] = 500, [Inventory] ={ ["Bread"] = 1, ["Apples"] = 40, }, }
So i'm trying to insert another Dictionary like this: ["Pets"] ={ ["Dogs"] = 1, ["Cats"] = 5, },
But how would I inset that Dictionary into Mytable? I already tried : table.insert(Mytable,["Pets"] ={ ["Dogs"] = 1, ["Cats"] = 5, },)
But that didn't work... Anyone know how to do this? (I already checked the Wiki, it didn't help) |
|
|
| Report Abuse |
|
|
|
| 07 Feb 2017 06:28 PM |
| throw the webster dictionary at it |
|
|
| Report Abuse |
|
|
Inductive
|
  |
| Joined: 28 May 2012 |
| Total Posts: 6480 |
|
|
| 07 Feb 2017 06:38 PM |
table[Whatever] = "Something" should work.
Table.insert won't work unless it's already defined as a dictionary. |
|
|
| Report Abuse |
|
|
|
| 07 Feb 2017 06:50 PM |
| So that inserts the dictionary into the table? |
|
|
| Report Abuse |
|
|
|
| 07 Feb 2017 07:03 PM |
| @Inductive that didn't work... |
|
|
| Report Abuse |
|
|
Inductive
|
  |
| Joined: 28 May 2012 |
| Total Posts: 6480 |
|
|
| 07 Feb 2017 07:30 PM |
It should work. tab["Whatever"] = 2
Worked for me, at least. |
|
|
| Report Abuse |
|
|
|
| 07 Feb 2017 07:31 PM |
| Is that inserting it via Script? |
|
|
| Report Abuse |
|
|
Inductive
|
  |
| Joined: 28 May 2012 |
| Total Posts: 6480 |
|
|
| 07 Feb 2017 07:35 PM |
| Are you trying to insert the entirety of a table, or just the values of a table? |
|
|
| Report Abuse |
|
|
|
| 07 Feb 2017 07:37 PM |
| Okay so, I have a table, And i'm trying to make a script insert a Dictionary into my table. |
|
|
| Report Abuse |
|
|
| |
|
GearMechs
|
  |
| Joined: 01 Dec 2010 |
| Total Posts: 1220 |
|
|
| 07 Feb 2017 08:16 PM |
You could cycle a in pairs loop and add each item to the table
for i,v in pairs(whatevertable) do table.instet(whatevertable2, v
end
Small Developer |
|
|
| Report Abuse |
|
|
|
| 07 Feb 2017 08:29 PM |
| @GearMechs Wouldn't that insert the items at the end of the Table? |
|
|
| Report Abuse |
|
|
|
| 07 Feb 2017 08:40 PM |
| @GearMechs I need to insert a whole Dictionary... |
|
|
| Report Abuse |
|
|
GearMechs
|
  |
| Joined: 01 Dec 2010 |
| Total Posts: 1220 |
|
|
| 07 Feb 2017 08:49 PM |
that will; set whatever table to the dictionary and whatevertable 2 to the one you are putting it in.
Small Developer |
|
|
| Report Abuse |
|
|
|
| 07 Feb 2017 08:57 PM |
| Wait what... Sorry, can you show me a example? |
|
|
| Report Abuse |
|
|
Inductive
|
  |
| Joined: 28 May 2012 |
| Total Posts: 6480 |
|
|
| 07 Feb 2017 11:18 PM |
| Mytable[Whatever] = Othertable |
|
|
| Report Abuse |
|
|
|
| 08 Feb 2017 10:56 AM |
| @Inductive. Oooh that works. I must have been doing it wrong, thank's for all the help. |
|
|
| Report Abuse |
|
|