Skip to content

Commit 27fdb2e

Browse files
committed
some event fixes
move some caching code around and rename one variable related to it this will allow lockpart_grabbing, damage_zone_hit, and damage_zone_kill to work with empty string argument again
1 parent 6eb2bfd commit 27fdb2e

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

lua/pac3/core/client/part_pool.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -648,14 +648,14 @@ end
648648
function pac.LinkSpecialTrackedPartsForEvent(part, ply)
649649
part.erroring_cached_parts = {}
650650
part.found_cached_parts = {}
651-
651+
652652
part.specialtrackedparts = {}
653653
local tracked_classes = {
654654
["damage_zone"] = true,
655655
["lock"] = true
656656
}
657657
for _,part2 in pairs(all_parts) do
658-
if ply == part2:GetPlayerOwner() and tracked_classes[part.ClassName] then
658+
if ply == part2:GetPlayerOwner() and tracked_classes[part2.ClassName] then
659659
table.insert(part.specialtrackedparts,part2)
660660
end
661661
end

lua/pac3/core/client/parts/event.lua

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,13 @@ function PART:SetEvent(event)
159159
(self.Arguments ~= "" and self.Event ~= "" and self.Event ~= event)
160160

161161
local owner = self:GetPlayerOwner()
162+
timer.Simple(1, function()
163+
--caching for some events
164+
pac.RegisterPartToCache(owner, "button_events", self, event ~= "button")
165+
if tracked_events[event] then
166+
pac.LinkSpecialTrackedPartsForEvent(self, owner)
167+
end
168+
end)
162169

163170
if (owner == pac.LocalPlayer) and (not pace.processing) then
164171
if event == "command" then owner.pac_command_events = owner.pac_command_events or {} end
@@ -211,11 +218,6 @@ function PART:SetEvent(event)
211218
if not GetConVar("pac_editor_remember_divider_height"):GetBool() and IsValid(pace.Editor) then pace.Editor.div:SetTopHeight(ScrH() - 520) end
212219

213220
end
214-
--caching for some events
215-
pac.RegisterPartToCache(owner, "button_events", self, event ~= "button")
216-
if tracked_events[event] then
217-
timer.Simple(1, function() pac.LinkSpecialTrackedPartsForEvent(self, owner) end)
218-
end
219221
end
220222

221223
function PART:Initialize()
@@ -2467,7 +2469,6 @@ PART.OldEvents = {
24672469
callback = function(self, ent, uid)
24682470
uid = uid or ""
24692471
uid = string.gsub(uid, "\"", "")
2470-
local valid_uid, err = pcall(pac.GetPartFromUniqueID, pac.Hash(ent), uid)
24712472
if uid == "" then
24722473
--for _,part in pairs(pac.GetLocalParts()) do
24732474
for _,part in ipairs(self.specialtrackedparts) do

0 commit comments

Comments
 (0)