|
| 01 Aug 2016 10:45 PM |
Since when roblocks
since wen |
|
|
| Report Abuse |
|
|
|
| 01 Aug 2016 10:48 PM |
As for a question, I'm trying to save player inventories with 60 slots. They go something like this:
{ {"Boots", "Boots of Undying", 3} {"Hat", "Hat of Undying", 3} (58 more things like that) }
Why can't I save that? |
|
|
| Report Abuse |
|
|
|
| 01 Aug 2016 10:49 PM |
because that's a 'mixed' array. http://wiki.roblox.com/index.php?title=Data_store "Tables with mixed list / record style will be cut off Lua tables which have a mixed style will not be saved correctly. This is a known issue."
mom wheres the spaghetti | R$19,427 |
|
|
| Report Abuse |
|
|
|
| 01 Aug 2016 10:55 PM |
| So should I use tostring on all the numbers and then tonumber() when reading them back? |
|
|
| Report Abuse |
|
|
|
| 01 Aug 2016 11:08 PM |
OK, so now I'm *trying* to save it like this:
{ {"Boots", "Boots of Undying", "3", "1"} }
The final "1" is for true and false. I got the error:
"Arrays cannot be stored in DataStores" |
|
|
| Report Abuse |
|
|
|
| 01 Aug 2016 11:11 PM |
00:07:07.331 - Cannot store Array in DataStore
|
|
|
| Report Abuse |
|
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
|
| 01 Aug 2016 11:11 PM |
That has nothing to do with the values.
The problem is mixing arrays with dictionaries. Tables are stored as JSON, JSON cannot represent it.
@OP
Post the code. Datastores can save arrays just fine. |
|
|
| Report Abuse |
|
|
|
| 01 Aug 2016 11:14 PM |
function CompileInventory(PLAYER) local INVENTORY = InventoryData:FindFirstChild(PLAYER.UserId) local INV_COMPILED = {} for i = 1, 60 do local ITEM = INVENTORY[i] local ITEM_COMPILED = {} if (#ITEM:GetChildren() > 0) then --for _,ITEM in pairs(ITEM:GetChildren()) do local TYPE, NAME, LEVEL, ASSET, SELL_PRICE, EQUIPPED = ITEM.Type.Value, ITEM.ItemName.Value, ITEM.Level.Value, ITEM.AssetID.Value, ITEM.SellPrice.Value, ITEM.Equipped.Value table.insert(ITEM_COMPILED, TYPE) table.insert(ITEM_COMPILED, NAME) table.insert(ITEM_COMPILED, tostring(LEVEL)) table.insert(ITEM_COMPILED, tostring(ASSET)) table.insert(ITEM_COMPILED, tostring(SELL_PRICE)) if (EQUIPPED == true) then table.insert(ITEM_COMPILED, "1") else table.insert(ITEM_COMPILED, "0") end --end end table.insert(INV_COMPILED, ITEM) end return INV_COMPILED end
The table returned from that function is what I'm saving. |
|
|
| Report Abuse |
|
|
| |
|