From 2c9dd525a50d092d4644b2d0c52f16ed54a560de Mon Sep 17 00:00:00 2001 From: pingu7867 Date: Wed, 25 Dec 2024 01:00:45 -0500 Subject: [PATCH] proxy property fixes promote ExpressionOnHide to code_proxy panel class if luapad is active, mirror changes from normal property text field to the luapad screen (the link is now bidirectional) convert vectors when pasting so they work out of the box with commas and no unnecessary trailing zeros, this is also to prevent an error where it tried to string trim a vector --- lua/pac3/core/client/parts/proxy.lua | 14 ++++++++------ .../editor/client/panels/extra_properties.lua | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/lua/pac3/core/client/parts/proxy.lua b/lua/pac3/core/client/parts/proxy.lua index 8fbb3f928..eddbef0b6 100644 --- a/lua/pac3/core/client/parts/proxy.lua +++ b/lua/pac3/core/client/parts/proxy.lua @@ -53,7 +53,7 @@ BUILDER:StartStorableVars() BUILDER:GetSet("PreviewOutput", false, {description = "Previews the proxy's output (for yourself) next to the nearest owner entity in the game"}) BUILDER:SetPropertyGroup("extra expressions") - BUILDER:GetSet("ExpressionOnHide", "", {description = "Math to apply once, when the proxy is hidden. It computes once, so it will not move."}) + BUILDER:GetSet("ExpressionOnHide", "", {description = "Math to apply once, when the proxy is hidden. It computes once, so it will not move.", editor_panel = "code_proxy"}) BUILDER:GetSet("Extra1", "", {description = "Write extra math here.\nIt computes before the main expression and can be accessed from the main expression as extra1() or var1() to save space, or by another proxy as extra1(\"uid or name\") or var1(\"uid or name\")", editor_panel = "code_proxy"}) BUILDER:GetSet("Extra2", "", {description = "Write extra math here.\nIt computes before the main expression and can be accessed from the main expression as extra2() or var2() to save space, or by another proxy as extra2(\"uid or name\") or var2(\"uid or name\")", editor_panel = "code_proxy"}) BUILDER:GetSet("Extra3", "", {description = "Write extra math here.\nIt computes before the main expression and can be accessed from the main expression as extra3() or var3() to save space, or by another proxy as extra3(\"uid or name\") or var3(\"uid or name\")", editor_panel = "code_proxy"}) @@ -1596,6 +1596,13 @@ local allowed = { function PART:SetExpression(str, slot) str = string.Trim(str,"\n") + if self == pace.current_part and (pace.ActiveSpecialPanel and pace.ActiveSpecialPanel.luapad) and str ~= "" then + --update luapad text if we update the expression from the properties + if slot == pace.ActiveSpecialPanel.luapad.keynumber then --this check prevents cross-contamination + pace.ActiveSpecialPanel.luapad:SetText(str) + end + end + if not slot then --that's the default expression self.Expression = str self.ExpressionFunc = nil @@ -1660,31 +1667,26 @@ function PART:SetExpression(str, slot) end function PART:SetExpressionOnHide(str) - str = string.Trim(str,"\n") self.ExpressionOnHide = str self:SetExpression(str, 0) end function PART:SetExtra1(str) - str = string.Trim(str,"\n") self.Extra1 = str self:SetExpression(str, 1) end function PART:SetExtra2(str) - str = string.Trim(str,"\n") self.Extra2 = str self:SetExpression(str, 2) end function PART:SetExtra3(str) - str = string.Trim(str,"\n") self.Extra3 = str self:SetExpression(str, 3) end function PART:SetExtra4(str) - str = string.Trim(str,"\n") self.Extra4 = str self:SetExpression(str, 4) end diff --git a/lua/pac3/editor/client/panels/extra_properties.lua b/lua/pac3/editor/client/panels/extra_properties.lua index 1e98faf65..512cf8486 100644 --- a/lua/pac3/editor/client/panels/extra_properties.lua +++ b/lua/pac3/editor/client/panels/extra_properties.lua @@ -1065,6 +1065,15 @@ do -- script proxy if isnumber(value) then -- visually round numbers so 0.6 doesn't show up as 0.600000000001231231 on wear value = math.Round(value, 7) + elseif isvector(var) then + var = math.Round(var.x,3) .. "," .. math.Round(var.y,3) .. "," .. math.Round(var.z,3) + value = var + elseif isangle(var) then + var = math.Round(var.p,3) .. "," .. math.Round(var.y,3) .. "," .. math.Round(var.r,3) + value = var + elseif IsColor(var) then + var = math.Round(var.r,3) .. "," .. math.Round(var.g,3) .. "," .. math.Round(var.b,3) + value = var end local str = tostring(value) local original_str = string.Trim(str,"\n") @@ -1111,6 +1120,15 @@ do -- script proxy frame:SetSizable(true) local editor = vgui.Create("pace_luapad", frame) + local slots = { + ["ExpressionOnHide"] = 0, + ["Extra1"] = 1, + ["Extra2"] = 2, + ["Extra3"] = 3, + ["Extra4"] = 4, + ["Extra5"] = 5, + } + editor.keynumber = slots[self.CurrentKey] frame.luapad = editor install_fontsize_buttons(frame, editor) editor:Dock(FILL)