From 0108196c120f805c7f767d18b1ab8aaf80024848 Mon Sep 17 00:00:00 2001 From: Tim Goll Date: Mon, 16 Sep 2024 08:39:54 +0200 Subject: [PATCH 1/2] added hook --- lua/ttt2/libraries/buttons.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lua/ttt2/libraries/buttons.lua b/lua/ttt2/libraries/buttons.lua index 51dd04691..7d0be6a02 100644 --- a/lua/ttt2/libraries/buttons.lua +++ b/lua/ttt2/libraries/buttons.lua @@ -20,10 +20,14 @@ if SERVER then -- @internal -- @realm server function button.SetUp() + local buttonList = {} + for i = 1, #validButtons do local classButton = validButtons[i] local buttonsTable = ents.FindByClass(classButton) + buttonList[classButton] = buttonsTable + for j = 1, #buttonsTable do local foundButton = buttonsTable[j] @@ -33,7 +37,20 @@ if SERVER then foundButton:SetNWInt("button_class", i) end end + + --- + -- @realm server + -- stylua: ignore + hook.Run("TTT2PostButtonInitialization", buttonList) end + + --- + -- Hook that is called after all buttons were initialized on the map. This happens after + -- a map cleanup when a new round starts or when the list is rebuilt after a hotreload. + -- @param table buttonList A table with all buttons found on the map + -- @hook + -- @realm server + function GM:TTT2PostButtonInitialization(buttonList) end end --- From eff36737c73978d711868cb526ba63c03e2651ec Mon Sep 17 00:00:00 2001 From: Tim Goll Date: Mon, 16 Sep 2024 08:40:39 +0200 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bce5bbec1..6075fea95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,6 +53,7 @@ All notable changes to TTT2 will be documented here. Inspired by [keep a changel - Added force role admin command (by @mexikoedi) - Added `draw.RefreshAvatars(id64)` to refresh avatar icons (by @mexikoedi) - Added `GM:TTT2OnButtonUse(ply, ent, oldState)`: a hook that is triggered when a button is pressed and that is able to prevent that button press (by @TimGoll) +- Added `GM:TTT2PostButtonInitialization(buttonList)`: a hook that is called after all buttons on the map have been initialized (by @TimGoll) ### Changed