Skip to content

Changing pac_onuse_only calls nonexistent typo hook name instead of real hook #1435

@TiberiumFusion

Description

@TiberiumFusion
Image

This is a case of a typo + a footgun.

show_outfit_on_use.lua :: pace.OnUseOnlyUpdates() does this: pace.Call("OnUseOnlyUpdates", ...)

function pace.OnUseOnlyUpdates(cvar, ...)
pace.Call("OnUseOnlyUpdates", ...)
end

and then editor/client/init.lua :: pace.Call() prefixes that "OnUseOnlyUpdates" with "On" and then tries to call nonexistent hook "OnOnUseOnlyUpdates", resulting in the actual hook failing to run and the user getting a scary Lua error popup. This is a pretty bad look for simply toggling the most popular pac user preference.

function pace.Call(str, ...)
if pace["On" .. str] then
if hook.Run("pace_On" .. str, ...) ~= false then
return pace["On" .. str](...)
end
else
ErrorNoHalt("missing function pace.On" .. str .. "!\n")
end
end

In addition to fixing this, I recommend fixing pac's footgun of prefixing of hook names like this and requiring the caller to omit the known prefix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions