lune/scripts/physical_properties_enum_map.luau

30 lines
745 B
Lua
Raw Normal View History

2023-07-22 13:46:40 +01:00
--!nocheck
2023-09-25 21:48:02 +01:00
--!nolint UnknownGlobal
2023-07-22 13:46:40 +01:00
-- NOTE: This must be ran in Roblox Studio to get up-to-date enum values
local contents = ""
local longestNameLen = 0
for _, enum in Enum.Material:GetEnumItems() do
longestNameLen = math.max(longestNameLen, #enum.Name)
end
contents ..= "\n#[rustfmt::skip]\nconst MATERIAL_ENUM_MAP: &[(&str, f32, f32, f32, f32, f32)] = &[\n"
for _, enum in Enum.Material:GetEnumItems() do
local props = PhysicalProperties.new(enum)
contents ..= string.format(
' ("%s",%s %.2f, %.2f, %.2f, %.2f, %.2f),\n',
enum.Name,
string.rep(" ", longestNameLen - #enum.Name),
props.Density,
props.Friction,
props.Elasticity,
props.FrictionWeight,
props.ElasticityWeight
)
end
contents ..= "];\n"
print(contents)