Skip to content

Commit

Permalink
some event fixes
Browse files Browse the repository at this point in the history
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
  • Loading branch information
pingu7867 committed Jan 3, 2025
1 parent 6eb2bfd commit 27fdb2e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions lua/pac3/core/client/part_pool.lua
Original file line number Diff line number Diff line change
Expand Up @@ -648,14 +648,14 @@ end
function pac.LinkSpecialTrackedPartsForEvent(part, ply)
part.erroring_cached_parts = {}
part.found_cached_parts = {}

part.specialtrackedparts = {}
local tracked_classes = {
["damage_zone"] = true,
["lock"] = true
}
for _,part2 in pairs(all_parts) do
if ply == part2:GetPlayerOwner() and tracked_classes[part.ClassName] then
if ply == part2:GetPlayerOwner() and tracked_classes[part2.ClassName] then
table.insert(part.specialtrackedparts,part2)
end
end
Expand Down
13 changes: 7 additions & 6 deletions lua/pac3/core/client/parts/event.lua
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,13 @@ function PART:SetEvent(event)
(self.Arguments ~= "" and self.Event ~= "" and self.Event ~= event)

local owner = self:GetPlayerOwner()
timer.Simple(1, function()
--caching for some events
pac.RegisterPartToCache(owner, "button_events", self, event ~= "button")
if tracked_events[event] then
pac.LinkSpecialTrackedPartsForEvent(self, owner)
end
end)

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

end
--caching for some events
pac.RegisterPartToCache(owner, "button_events", self, event ~= "button")
if tracked_events[event] then
timer.Simple(1, function() pac.LinkSpecialTrackedPartsForEvent(self, owner) end)
end
end

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

0 comments on commit 27fdb2e

Please sign in to comment.