From fd2f5a95893fdfb9438c477927b5856f7bc223e0 Mon Sep 17 00:00:00 2001 From: bbassie <17990055+bbassie@users.noreply.github.com> Date: Thu, 6 Aug 2026 21:36:59 +0000 Subject: [PATCH] Type the player bonus element data and config `data` on an element is the GuiData store keyed by element, not the value being stored. Co-Authored-By: Claude Opus 5 (1M context) --- exp_scenario/module/gui/player_bonus.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/exp_scenario/module/gui/player_bonus.lua b/exp_scenario/module/gui/player_bonus.lua index e5c9ff8a..0af5b4aa 100644 --- a/exp_scenario/module/gui/player_bonus.lua +++ b/exp_scenario/module/gui/player_bonus.lua @@ -22,13 +22,16 @@ local Elements = {} --- @field _cost_scale number --- For perf calculate the division of scale against cost ahead of time -for _, bonus_data in pairs(config.player_bonus) do +--- @type table +local player_bonus = config.player_bonus + +for _, bonus_data in pairs(player_bonus) do bonus_data._cost_scale = bonus_data.cost / bonus_data.scale end --- Progress bar which displays how much of a bonus has been used --- @class ExpGui_PlayerBonus.elements.bonus_used: ExpElement ---- @field data number +--- @field data table --- @overload fun(parent: LuaGuiElement): LuaGuiElement Elements.bonus_used = Gui.define("player_bonus/bonus_used") :track_all_elements() @@ -441,7 +444,7 @@ end function Elements.container.calculate_cost(player) local cost = 0 local player_data = Elements.container.data[player] - for _, bonus_data in pairs(config.player_bonus) do + for _, bonus_data in pairs(player_bonus) do cost = cost + (player_data[bonus_data.name] or 0) * bonus_data._cost_scale end return cost