I am wanting to order my block ids in a way that keeps them clean in a grid layout. However, cause my block ids can include : or even letters, it makes laying them out incredbily confusing.
Example of ids
local BlockIds = {
["1"] = 1,
["3"] = 2,
["3:1"] = 3,
["3:1a"] = 4,
["4"] = 5,
["7b"] = 6,
["8:12"] = 7,
["9"] = 8
}
IGNORE the values, just there for sake of how i lay my ids out. Only thing important is the string.
I need that table of BlockIds to be in the order they are arranged. So a blockid or 3:1 should go BEFORE 3:1a, and AFTER 3
local Layout = string.gsub(NewBlock:GetAttribute("Id"), "%D", "")
local Concat = "00"
if string.find(blockId, ":") then
Layout = string.sub(blockId, 1, string.find(blockId, ":") - 1)
local PostNumber = string.sub(blockId, string.find(blockId, ":") + 1)
Concat ..= PostNumber
end
if string.find(blockId, "a") then -- Slab
Concat = Concat .. "1"
elseif string.find(blockId, "b") then -- Stair
Concat = Concat .. "2"
elseif string.find(blockId, "c") then -- Corner Stair
Concat = Concat .. "3"
elseif string.find(blockId, "d") then -- Inner Stair
Concat = Concat .. "4"
end
NewBlock.LayoutOrder = tonumber(Layout .. Concat)
Kind of a mess of what I have, it doesn’t really work. I was thinking of just adding a bunch of 0’s and then changing as necessary.
Basically, visualized it should be
local BlockIds = {
["1"] = 1,
["2"] = 2,
["3:1"] = 3,
["3:1a"] = 4,
["4"] = 5,
["7b"] = 6,
["8:12"] = 7,
["9"] = 8
}
-- what it should look like when converted:
local BlockIds = {
["10000"] = 1,
["20000"] = 2,
["30010"] = 3,
["30011"] = 4,
["40000"] = 5,
["70002"] = 6,
["80120"] = 7,
["90000"] = 8
}
Basically the blocks main id first, a 0 after to pad out. then 2 0’s (to take into account anything that might be after : ) and then another 0 for any lettered ids.