diff --git a/.gitignore b/.gitignore index 762a8f6..5392a39 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,5 @@ luneTypes.d.luau # Files generated by runtime or build scripts packages/lib-roblox/scripts/brick_color.rs +packages/lib-roblox/scripts/font_enum_map.rs +packages/lib-roblox/scripts/physical_properties_enum_map.rs diff --git a/.vscode/settings.json b/.vscode/settings.json index 84496cf..74719fa 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -5,8 +5,11 @@ "luau-lsp.types.definitionFiles": ["luneTypes.d.luau"], "luau-lsp.types.documentationFiles": ["luneDocs.json"], "luau-lsp.require.mode": "relativeToFile", - // Luau - ignore type defs file in docs dir - "luau-lsp.ignoreGlobs": ["docs/*.d.luau"], + // Luau - ignore type defs file in docs dir and dev scripts we use + "luau-lsp.ignoreGlobs": [ + "docs/*.d.luau", + "packages/lib-roblox/scripts/*.luau" + ], // Rust "rust-analyzer.check.command": "clippy", // Formatting diff --git a/packages/lib-roblox/scripts/font_enum_map.luau b/packages/lib-roblox/scripts/font_enum_map.luau new file mode 100644 index 0000000..82b7f12 --- /dev/null +++ b/packages/lib-roblox/scripts/font_enum_map.luau @@ -0,0 +1,22 @@ +-- NOTE: This must be ran in Roblox Studio to get up-to-date font values + +local contents = "" + +contents ..= "\nconst FONT_ENUM_MAP: &[(&str, Option<(&str, RbxFontWeight, RbxFontStyle)>)] = &[\n" +for _, enum in Enum.Font:GetEnumItems() do + if enum == Enum.Font.Unknown then + contents ..= ' ("Unknown", None),\n' + else + local font = Font.fromEnum(enum) + contents ..= string.format( + ' ("%s", Some(("%s", RbxFontWeight::%s, RbxFontStyle::%s))),\n', + enum.Name, + font.Family, + font.Weight.Name, + font.Style.Name + ) + end +end +contents ..= "];\n" + +print(contents) diff --git a/packages/lib-roblox/scripts/physical_properties_enum_map.luau b/packages/lib-roblox/scripts/physical_properties_enum_map.luau new file mode 100644 index 0000000..595f61e --- /dev/null +++ b/packages/lib-roblox/scripts/physical_properties_enum_map.luau @@ -0,0 +1,26 @@ +-- 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)