So I have this upcoming game, too big to explain in a simple post.
The world is divided into tiles and data is stored into datastores, the biggest challenge was reliably loading all the world data quickly for the user, so I made a method of breaking the data down into simpler steps.
As seen here ^ data is stored into a datastore, theres about 330 entries for each division and around 10000 entries all together.
So what I did was I loaded a table and I broke the table down into four pieces and loaded them all in their own coroutine, making a once 5 minute wait go down, to just 7 seconds with little to no noticable lag.
11 Likes
Awesome! Harnessing the power of async programming
1 Like
Absolutely, right now I’m thinking of algorithims to make it even faster.
My main idea is to have multiple actors loading multiple tables at once and then breaking down those tables and loading it like that.
10,000+ tiles in 7 seconds when it used to take me 5 minutes is a really good improvement though.
2 Likes
For something even more advanced, you can take on the challenge of using compression.
Create a “metatable” (just a separate normal table, not actually a lua metatable) containing a single letter like “x” and refering it to repeating strings or values.
For example, say if you have some tiles that are identically the same, just do
metatable.x = tile contents for the first tile
and then in your actual main tables where you save them, do normalTable.secondTile = x
so when you async load them, and you run into “x” for normalTable.secondTile, you can search for “x” in the metatable and then load the contents.
It’s like text file compression if you want to search that up.
1 Like
Good idea I’ll look into that.
2 Likes
This is great! Nice job on it! How long did it take to make this?
Not too long, maybe a few hours.