From 29113c4f7491c3275f48281a7fa38b9c682c5a3c Mon Sep 17 00:00:00 2001 From: Andrew Vu Date: Wed, 22 Oct 2025 04:56:13 -0400 Subject: [PATCH 1/2] Add formatting for Vector3, Vector2, UDim2, CFrame, and NumberRange in patch visualizer --- .../PatchVisualizer/DisplayValue.lua | 41 +++++++++++++++++-- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/plugin/src/App/Components/PatchVisualizer/DisplayValue.lua b/plugin/src/App/Components/PatchVisualizer/DisplayValue.lua index 94106af6..0e73f75c 100644 --- a/plugin/src/App/Components/PatchVisualizer/DisplayValue.lua +++ b/plugin/src/App/Components/PatchVisualizer/DisplayValue.lua @@ -8,9 +8,46 @@ local Theme = require(Plugin.App.Theme) local e = Roact.createElement +local function fmtNum(n) + if math.abs(n - math.round(n)) < 0.0001 then + return tostring(math.round(n)) + end + return (string.format("%.3f", n):gsub("0+$", ""):gsub("%.$", "")) +end + local function DisplayValue(props) return Theme.with(function(theme) local t = typeof(props.value) + local text + + if t == "Vector3" then + text = string.format("(%s, %s, %s)", fmtNum(props.value.X), fmtNum(props.value.Y), fmtNum(props.value.Z)) + elseif t == "Vector2" then + text = string.format("(%s, %s)", fmtNum(props.value.X), fmtNum(props.value.Y)) + elseif t == "UDim2" then + local x, y = props.value.X, props.value.Y + text = string.format("{%s, %s}, {%s, %s}", fmtNum(x.Scale), fmtNum(x.Offset), fmtNum(y.Scale), fmtNum(y.Offset)) + elseif t == "CFrame" then + local p = props.value.Position + text = string.format("(%s, %s, %s)", fmtNum(p.X), fmtNum(p.Y), fmtNum(p.Z)) + elseif t == "NumberRange" then + text = string.format("[%s, %s]", fmtNum(props.value.Min), fmtNum(props.value.Max)) + end + + if text then + return e("TextLabel", { + Text = text, + BackgroundTransparency = 1, + FontFace = theme.Font.Main, + TextSize = theme.TextSize.Body, + TextColor3 = props.textColor, + TextXAlignment = Enum.TextXAlignment.Left, + TextTransparency = props.transparency, + TextTruncate = Enum.TextTruncate.AtEnd, + Size = UDim2.new(1, 0, 1, 0), + }) + end + if t == "Color3" then -- Colors get a blot that shows the color return Roact.createFragment({ @@ -100,10 +137,6 @@ local function DisplayValue(props) }) end - -- TODO: Maybe add visualizations to other datatypes? - -- Or special text handling tostring for some? - -- Will add as needed, let's see what cases arise. - local textRepresentation = string.gsub(tostring(props.value), "%s", " ") if t == "string" then textRepresentation = '"' .. textRepresentation .. '"' From 8f8c19b845d484f54b617205218467f38a40de20 Mon Sep 17 00:00:00 2001 From: Andrew Vu Date: Sat, 8 Nov 2025 03:40:14 -0500 Subject: [PATCH 2/2] Include orientation in CFrame formatting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CFrames now display both position and rotation components to properly show changes when objects are rotated, not just translated. Format: (X, Y, Z), (rotX°, rotY°, rotZ°) --- plugin/src/App/Components/PatchVisualizer/DisplayValue.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugin/src/App/Components/PatchVisualizer/DisplayValue.lua b/plugin/src/App/Components/PatchVisualizer/DisplayValue.lua index 0e73f75c..5b6b4de0 100644 --- a/plugin/src/App/Components/PatchVisualizer/DisplayValue.lua +++ b/plugin/src/App/Components/PatchVisualizer/DisplayValue.lua @@ -29,7 +29,10 @@ local function DisplayValue(props) text = string.format("{%s, %s}, {%s, %s}", fmtNum(x.Scale), fmtNum(x.Offset), fmtNum(y.Scale), fmtNum(y.Offset)) elseif t == "CFrame" then local p = props.value.Position - text = string.format("(%s, %s, %s)", fmtNum(p.X), fmtNum(p.Y), fmtNum(p.Z)) + local rx, ry, rz = props.value:ToOrientation() + text = string.format("(%s, %s, %s), (%s°, %s°, %s°)", + fmtNum(p.X), fmtNum(p.Y), fmtNum(p.Z), + fmtNum(math.deg(rx)), fmtNum(math.deg(ry)), fmtNum(math.deg(rz))) elseif t == "NumberRange" then text = string.format("[%s, %s]", fmtNum(props.value.Min), fmtNum(props.value.Max)) end