Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

T-Buttons: small efficiency boost #1006

Merged
merged 9 commits into from
Oct 27, 2023
42 changes: 20 additions & 22 deletions gamemodes/terrortown/entities/entities/ttt_game_text.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,30 +52,28 @@ end
-- @return[default=true] boolean
-- @realm shared
function ENT:AcceptInput(name, activator)
if name == "Display" then
if name ~= "Display" then
return false
end

if IsValid(activator) and activator:IsPlayer() then
local recv = activator

local r = self.Receiver
if r == RECEIVE_ALL then
recv = nil
elseif r == RECEIVE_DETECTIVE then
recv = GetRoleChatFilter(ROLE_DETECTIVE)
elseif r == RECEIVE_TRAITOR then
recv = GetTeamChatFilter(TEAM_TRAITOR)
elseif r == RECEIVE_INNOCENT then
recv = GetTeamChatFilter(TEAM_INNOCENT)
elseif r == RECEIVE_ACTIVATOR then
if not IsValid(activator) or not activator:IsPlayer() then
ErrorNoHalt("ttt_game_text tried to show message to invalid !activator\n")

return true
end
elseif r == RECEIVE_CUSTOMROLE and self.teamReceiver then
recv = GetTeamChatFilter(self.teamReceiver)
end

local receiver_tbl = {
RECEIVE_ALL = nil,
RECEIVE_DETECTIVE = GetRoleChatFilter(ROLE_DETECTIVE),
RECEIVE_TRAITOR = GetRoleChatFilter(TEAM_TRAITOR),
RECEIVE_INNOCENT = GetRoleChatFilter(TEAM_INNOCENT)
}

recv = (self.teamReceiver) ? GetTeamChatFilter(self.teamReceiver) : receiver_tbl[self.Receiver]
Histalek marked this conversation as resolved.
Show resolved Hide resolved
CustomMsg(recv, self.Message, self.Color)


recv = nil
receiver_tbl = nil

return true
end

ErrorNoHalt("ttt_game_text tried to show message to invalid !activator\n")
return false -- either invalid activator or activator was not a player
end