I wanna be able to serialize my block placing system. So far, I believe I have a pretty good system in place, but I wanna be able to add extra info for the blocks.
Basically, since blocks are a 3x3x3 grid, I store each blocks data based on its relation to your spawn. And so it saves under a grid system, for example, the coordinates {-1, -1, -1} would save like so:
["-1"] = {
["-1"] = {
["-1"] = "2"
}
}
And each coordinate is given a BlockId. To me, this is the best way to minimilize block info to as few characters as possible.
Other things to point out is I have the ability for 2 slab types to be placed inside 1 “3x3x3” grid area, and so need to save accordingly. This may look like:
["-1"] = {
["-1"] = {
["-1"] = "1-1:1/2-19:1"
}
}
So, the 1 at the start symbolises it’s a bottom slab. I divide them up using a “/” and so I can use string functions to seperate this string, and I can know what the id for the top and bottom slabs are. So the example above is broken up like
"1" -- Slab position (bottom)
"-" -- Breaks up the string
"1:1" -- Id for the slab
"/" -- Seperates between the 2 slab positions
"2" -- Slab position (top)
"-" -- Breaks up the string
"19:1" -- Id for the slab
And once again, to my knowledge this is well organised and serialized. However, certain blocks have rotation values that need to be saved. So my question is how could I add those values as well?
Example of stairs, which have rotation values
I have a data module, and that tells me if the certain block has a rotation value that needs to be saved, so only certain blocks need to have their rotation saved. How could I serialize this well?