Skip to content

Commit 98764fe

Browse files
committed
optimize proxy
skip some editor-level checks in the onthink function fix when PreviewOutput functionality stops getting updates when out of editor
1 parent fcccc92 commit 98764fe

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

lua/pac3/core/client/parts/proxy.lua

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1955,6 +1955,7 @@ function PART:OnRemove()
19551955
end
19561956

19571957
function PART:OnThink(to_hide)
1958+
local playerowner = self:GetPlayerOwner() == pac.LocalPlayer
19581959
local part = self:GetTarget()
19591960
if not part:IsValid() then return end
19601961
if part.ClassName == 'woohoo' then --why a part hardcode exclusion??
@@ -1964,14 +1965,19 @@ function PART:OnThink(to_hide)
19641965
end
19651966
end
19661967

1967-
--foolproofing: scream at the user if they didn't set a variable name and there's no extra expressions ready to be used
1968-
if self == pace.current_part then self.touched = true end
1969-
if self ~= pace.current_part and self.VariableName == "" and self.touched and self.Extra1 == "" and self.Extra2 == "" and self.Extra3 == "" and self.Extra4 == "" and self.Extra5 == "" then
1970-
self:AttachEditorPopup("You forgot to set a variable name! The proxy won't work until it knows where to send the math!", true)
1971-
pace.FlashNotification("An edited proxy still has no variable name! The proxy won't work until it knows where to send the math!")
1972-
self:SetWarning("You forgot to set a variable name! The proxy won't work until it knows where to send the math!")
1973-
self.touched = false
1974-
elseif self.VariableName ~= "" and not self.error and not self.errors_override then self:SetWarning() end
1968+
if playerowner then
1969+
if pace and pace.IsActive() then
1970+
--foolproofing: scream at the user if they didn't set a variable name and there's no extra expressions ready to be used
1971+
if self == pace.current_part then self.touched = true end
1972+
if self ~= pace.current_part and self.VariableName == "" and self.touched and self.Extra1 == "" and self.Extra2 == "" and self.Extra3 == "" and self.Extra4 == "" and self.Extra5 == "" then
1973+
self:AttachEditorPopup("You forgot to set a variable name! The proxy won't work until it knows where to send the math!", true)
1974+
pace.FlashNotification("An edited proxy still has no variable name! The proxy won't work until it knows where to send the math!")
1975+
self:SetWarning("You forgot to set a variable name! The proxy won't work until it knows where to send the math!")
1976+
self.touched = false
1977+
elseif self.VariableName ~= "" and not self.error and not self.errors_override then self:SetWarning() end
1978+
end
1979+
end
1980+
19751981

19761982
self:CalcVelocity()
19771983

@@ -1999,7 +2005,7 @@ function PART:OnThink(to_hide)
19992005
local ok, x,y,z = self:RunExpression(ExpressionFunc)
20002006

20012007
if not ok then self.error = true
2002-
if self:GetPlayerOwner() == pac.LocalPlayer and self.Expression ~= self.LastBadExpression then
2008+
if playerowner and self.Expression ~= self.LastBadExpression then
20032009
--don't spam the chat every time we type a single character in the luapad
20042010
if not (pace.ActiveSpecialPanel and pace.ActiveSpecialPanel.luapad) then
20052011
chat.AddText(Color(255,180,180),"============\n[ERR] PAC Proxy error on "..tostring(self)..":\n"..x.."\n============\n")
@@ -2063,7 +2069,10 @@ function PART:OnThink(to_hide)
20632069
end
20642070
end
20652071

2066-
if pace and pace.IsActive() then
2072+
if not self.PreviewOutput then
2073+
if not self.pace_tree_node then return end
2074+
if not self.pace_tree_node:IsValid() then return end
2075+
elseif playerowner then
20672076

20682077
local str = ""
20692078

@@ -2153,7 +2162,7 @@ function PART:OnThink(to_hide)
21532162
end
21542163
self:SetError(error_msg) self.error = true
21552164
end
2156-
if self:GetPlayerOwner() == pac.LocalPlayer then
2165+
if playerowner then
21572166
if self.PreviewOutput then
21582167
pac.AddHook("HUDPaint", "proxy" .. self.UniqueID, function() draw_proxy_text(self, str) end)
21592168
else

0 commit comments

Comments
 (0)