How would one save parts within a folder to a datastore? I had two thoughts, one where I would assign the ID and a number correlating to the part position, and the other one where a part would scroll through all the possible positions and the part name (if there was no part in a spot the ID would be “AERO”) However, the studio does not allow collisions if a part is moved by script. Any other ideas?
Are you making a custom map maker in your game? Everytime the player makes a new part, assign an ID to it. Then you can make a table parts with positions, colors, sizes, rotation. To save the parts to a datastore, use httpservice’s jsonencode to turn the table into a string that can be saved.
Myself, I’d save the current respawn point (if it’s like most obbys) as a simple one-number value in the datastore on exit. On reload, check the number, set it as current, and move them to it. Should be pretty straightforward.
Yes, it is a custom map maker game.
Ultimately it depends on the data you store. But fundamentally you just need a way to store the data so you can rebuild it. (The last paragraph is probably the most important btw, and can be skipped to)
Fundamentally you need a way to store every property which matters to you. (Some can be implicitly stored by logical rules like if all parts are at the same Y axis you can skip storing that, but the info still technically exists just at the program level instead of the data store level).
Let’s consider a situation where there are different objects and you wish to store their position and rotations. So we make a list of all possible object types and we first store a number describing what type it represents like 1 for a standard block, or a 2 for a cylinder type thing.
Now we need to store size position and rotation. The most straightforward way is to simply do just that store 9 numbers in a row where the first is size, then pos, then rotation. The order you save and load is known by the program so you can perfectly reconstruct it. Now though if you need to store extra data you’ll need to find a way to compress it. A good example is you probably don’t need so much precision in your rotation so using the 16 bit vector types for that would be better. Youll have to know how to pack and store this information though.
So in this example we would have 10 numbers per object. So the first is the part we use, next 3 are the size, next 3 position, last 3 are the rotation, then the next number would be a partID again since you just put every part next to each other in a list pulling and analyzing 10 parts at a time.
You can always just do the straight json approach though if you don’t have too many parts by just storing it as a list of part tables with named properties as dictionary items. The above is only for when this approach needs to be better as this approach is probably the most straightforward.