1
0
mirror of https://github.com/pandorabox-io/banners.git synced 2025-01-06 16:10:32 +01:00

add transform_string_to_table

allows us to add more features such as:
- clean existing banners to slim down data
- read transforms from items in inventory -> allow players
  to change existing patterns without having to start from
  scratch.
This commit is contained in:
Luke aka SwissalpS 2024-11-29 10:07:32 +01:00
parent 1c5b11609b
commit e3c216eba7

View File

@ -47,6 +47,25 @@ banners.colors = {
"brown", "darkbrown"
}
local valid_masks = {}
local valid_colors = {}
do
local i, s
i = #banners.masks
repeat
s = banners.masks[i]
valid_masks[s .. ".png"] = true
i = i - 1
until i == 0
i = #banners.colors
repeat
s = banners.colors[i]
valid_colors["bg_" .. s .. ".png"] = true
i = i - 1
until i == 0
end
banners.base_transform = {
texture = "bg_white.png",
mask = "mask_background.png"
@ -144,7 +163,23 @@ end
banners.creation_form = smartfs.create("banners:banner_creation",
banners.creation_form_func)
function banners.transform_string_to_table(transform_string)
p('transform_string_to_table')
local transforms = {}
for part in transform_string:gmatch("%(([^%)]+)%)") do
parts = part:split("^[")
if 3 == #parts then
texture = parts[1]
mask = parts[2]:sub(6)
if valid_masks[mask] and valid_colors[texture] then
table.insert(transforms, {
texture = texture,
mask = mask
})
end
end
end
return transforms
end
function banners.transform_table_to_string(transforms)