generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Compressing a lot of important data which needs to be saved?

Previous Thread :: Next Thread 
Roy_Mer is not online. Roy_Mer
Joined: 13 Jul 2014
Total Posts: 396
22 Aug 2016 12:01 PM
Is there any way to compress a lot of important data which needs to be saved in a datastore and loaded efficiently?

Can JSON be used for this or are there any techniques to do so, if possible on Roblox?


Report Abuse
Zarkonan_Zenheart is not online. Zarkonan_Zenheart
Joined: 29 May 2012
Total Posts: 610
22 Aug 2016 12:10 PM
what kind of data is a very important part to this puzzle
Report Abuse
Roy_Mer is not online. Roy_Mer
Joined: 13 Jul 2014
Total Posts: 396
22 Aug 2016 12:17 PM
Strings


Report Abuse
ByDefault is not online. ByDefault
Joined: 25 Jul 2014
Total Posts: 3197
22 Aug 2016 12:18 PM
I always save all my data in a table, convert the table to JSON on saving and convert it back to a table on load.

local data = game:GetService("DataStoreService"):GetDataStore("TestData")
local http = game:GetService("HttpService")

game.Players.PlayerAdded:connect(function(player)
local pData = data:GetAsync(player.userId)
if pData then
pData = http:JSONDecode(pData)
print(pData.SomeValue)
end
end)

game.Players.PlayerRemoving:connect(function(player)
local pData = {
SomeValue = 5
}
data:SetAsync(player.userId,http:JSONEncode(pData))
end)
Report Abuse
while_loop is not online. while_loop
Joined: 13 Aug 2016
Total Posts: 55
22 Aug 2016 12:21 PM
@ByDefault No need to do that anymore, datastores automatically convert tables into JSON.
Report Abuse
Roy_Mer is not online. Roy_Mer
Joined: 13 Jul 2014
Total Posts: 396
22 Aug 2016 12:29 PM
@while_loop, are you sure about that?


Report Abuse
while_loop is not online. while_loop
Joined: 13 Aug 2016
Total Posts: 55
22 Aug 2016 01:11 PM
@Roy Yes, I currently do it in a game.

I used to have a module that converts tables into JSON before saving the data and converting them back into tables when getting the data back.
Report Abuse
affectless is not online. affectless
Joined: 28 Dec 2014
Total Posts: 1084
22 Aug 2016 01:17 PM
For some reason a lot of people don't know that DataStores convert to JSON before upload even though it says so on the wiki
Report Abuse
while_loop is not online. while_loop
Joined: 13 Aug 2016
Total Posts: 55
22 Aug 2016 01:18 PM
@Affect The didn't originally, and I think it was only quite recently that they changed it because I remember getting errors when trying to save a table to a datastore.

So, people just aren't informed.
Report Abuse
affectless is not online. affectless
Joined: 28 Dec 2014
Total Posts: 1084
22 Aug 2016 01:21 PM
But I remember learning about DataStores when they first came out and I thought I read that back then... maybe I'm misremembering.
Report Abuse
ByDefault is not online. ByDefault
Joined: 25 Jul 2014
Total Posts: 3197
22 Aug 2016 01:25 PM
Does it really matter if you convert them to JSON manually lol
Report Abuse
affectless is not online. affectless
Joined: 28 Dec 2014
Total Posts: 1084
22 Aug 2016 01:26 PM
not practically, since json encoding is super fast, but it's an unnecessary step.
Report Abuse
while_loop is not online. while_loop
Joined: 13 Aug 2016
Total Posts: 55
22 Aug 2016 01:27 PM
@ByDefault No but its pointless to do and adds useless lines to code.
Report Abuse
ByDefault is not online. ByDefault
Joined: 25 Jul 2014
Total Posts: 3197
22 Aug 2016 01:29 PM
It adds 1 line of code total, not much lol
Report Abuse
while_loop is not online. while_loop
Joined: 13 Aug 2016
Total Posts: 55
22 Aug 2016 01:32 PM
I was accounting for loading the data in as well.

I don't see why you're arguing this. Its pointless code, you can't deny it. If you'd like to do it then you can but I'm just pointing out that there is no point.
Report Abuse
ThatChristianGuy is not online. ThatChristianGuy
Joined: 14 Jun 2014
Total Posts: 1283
22 Aug 2016 01:35 PM
Idk about now, but when DataStore first came out each item in a table counted as one request because they were all saved separately.


Report Abuse
Roy_Mer is not online. Roy_Mer
Joined: 13 Jul 2014
Total Posts: 396
22 Aug 2016 01:35 PM
So I can just save and load a huge table super efficiently now since it automatically converts to JSON?


Report Abuse
ThatChristianGuy is not online. ThatChristianGuy
Joined: 14 Jun 2014
Total Posts: 1283
22 Aug 2016 01:37 PM
How huge is super huge?


Report Abuse
Roy_Mer is not online. Roy_Mer
Joined: 13 Jul 2014
Total Posts: 396
22 Aug 2016 01:38 PM
Idk lets say 300? Lol


Report Abuse
ThatChristianGuy is not online. ThatChristianGuy
Joined: 14 Jun 2014
Total Posts: 1283
22 Aug 2016 01:40 PM
I'd convert it to JSON first or find a way to not need to upload such a big table.


Report Abuse
Roy_Mer is not online. Roy_Mer
Joined: 13 Jul 2014
Total Posts: 396
22 Aug 2016 01:41 PM
Well to be honest I could shorten some stuff to save them in 1 string but I don't need to convert to JSON since it's automatically apparently lol.


Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image