Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Saving Player's Builds most efficiently?

Asked by 9 years ago

Say I wanted to make something like sim-city, where you can place pre-built structures on the ground in your area. How could I go about saving those builds the simplest? Before hand I would convert each building into a brick with a value inside it telling what it was and save the group as an instance to the player, then when the player loads back replace the bricks with the full building. This seems horribly inefficient and rotation is a problem too, but it looks like the only way to get around the data-limit on data persistence. Is there any other way?

1 answer

Log in to vote
0
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

I'm assuming the map is on some sort of grid.

If that's the case, we can enumerate, "What is at position 1? What is at position 2? What is at position 3?" where each answer is a very short string.

For example, if we had a residential building facing south, we could use "rs"; an empty grass tile might be "eg", and so on.

Storing that string (or maybe a list of strings) should be extremely efficient.


If the map isn't bounded or you want to save space, you could also do things like spiraling about the center instead of starting from the top left, so that only things near where you start would be encoded if everything else is empty.


If the map isn't on a grid at all, you can still use a similar solution, just precede each entry with where it's located, e.g., "234,18.9,rs" for a residential building facing south at position (234, 18.9).


The key is to note every detail that you need to distinguish two different layouts. The CFrame of a building probably isn't important, since it's only going to allow rotation -- so just that angle -- and better yet -- just four of those angles need to be disambiguated.

Ad

Answer this question