ImFarleyJoin Date: 2009-08-30 Post Count: 2157 |
I've been working on storing and loading "furniture" for a game I'm doing. Currently, the system offers customization for item, rotation, position, and color. What I've found is that I am VERY quickly exceeding the request limit, and thus stuff is breaking.
So, I was wondering if you guys could share what you've found to be the best way of doing this? Specifically, please. I'm no beginner to data stores considering the many hours I've struggled doing them over the years, so something like "Use a table" isn't helpful, since 1. I already am, and 2. That method doesn't work since I still have to reference the data store every time I call a member of the table (I have to several times)
I've considered copying the data store table over to a different table when it's loaded, but when a player's home is populated fully, this won't work, since there could be anywhere upwards of 30 items in there, each having 5-8 members of their own tables.
Thanks in advance. I really hate data stores since they bug so much, so any help is appreciated.
Much love -GO |
|
|
by request limit, are you talking about calling the datastore api too much? |
|
ImFarleyJoin Date: 2009-08-30 Post Count: 2157 |
Yes. I initialize a table "data" to ds:getasync(asynckey) and then I just call data[whatever] every time I am loading a new "property" of the model such as rot, pos, etc.
The problem is that the obviously still calls getasync every time, and as stated, if I were to try and copy it to a new table, it would just overflow the request limit during the copying.
Much love -GO |
|
ZawieJoin Date: 2010-07-04 Post Count: 6338 |
convert tables to strings so you can basically save the entire house in one table |
|
ImFarleyJoin Date: 2009-08-30 Post Count: 2157 |
The entire house is saved in one table. That table then holds many other tables for each piece of furniture.
That doesn't change the fact that any time I called any member of the table, string or not, it would have to request to the datastore.
Much love -GO |
|
ZawieJoin Date: 2010-07-04 Post Count: 6338 |
turn entire house table into string
save string into datastore
load string
decode the string
store that decoded string in a varible
one call to save and load |
|
ImFarleyJoin Date: 2009-08-30 Post Count: 2157 |
"turn entire house table into string"
"decode the string"
This is beyond me. Can you elaborate on how?
Much love -GO |
|
ZawieJoin Date: 2010-07-04 Post Count: 6338 |
hmmm I think i created a module a while ago
basically you iterate through the table and concat it to a string
there are some free encoding modules
|
|
|
try to pack the properties into one string/binary token to greatly lower the requests |
|
ZawieJoin Date: 2010-07-04 Post Count: 6338 |
^^^ |
|
ImFarleyJoin Date: 2009-08-30 Post Count: 2157 |
What's the max amount of characters in a string that can be stored?
Much love -GO |
|
Hedr0nJoin Date: 2016-01-05 Post Count: 1524 |
String limit caps at like 62k |
|
Hedr0nJoin Date: 2016-01-05 Post Count: 1524 |
This repo has a lot of good stuff for what you're doing. https://github.com/Checkplate/AtomEngine |
|
|
'The problem is that the obviously still calls getasync every time, and as stated, if I were to try and copy it to a new table, it would just overflow the request limit during the copying.'
It doesn't, it only sends one request when you do local data = getAsync(blah)
And then data becomes a copy of whatever you got
Then you just save over the old table with 'data' whenever you need to save. |
|
ImFarleyJoin Date: 2009-08-30 Post Count: 2157 |
@128
There's no logical reason for me to be getting request overflow if that's true.
Much love -GO |
|
|
Well it is true so something else is wrong. |
|
|
It wouldn't make any logical sense for it to work like you describe.
Imagine when you save a number to the dataStore, and load it
local x = getAsync("key")
x is now a variable to what in this example is a number
Its not a special number linked to the data store, its just a number.
Same thing with string
Same thing with tables (Tables are actually saved as a string and then loaded back into a table before being returned by a request for the data.)
The values aren't linked to the datastore in any way. |
|
ImFarleyJoin Date: 2009-08-30 Post Count: 2157 |
Well, I concede.
Just tried the game again after taking about an hour to cool down, and it worked flawlessly the first time without me changing anything.
I don't even know anymore.
Anyways, thanks guys. All around educational stuff.
Much love -GO |
|
Thane_1Join Date: 2009-04-08 Post Count: 3406 |
Actually, they increased the byte limit. It's now 4 times larger.
~ Who's awesome, you're awesome ~ |
|