From 8e85cc28ae706b807bb5a3ddfe62eb2137a148c2 Mon Sep 17 00:00:00 2001 From: Liu Wenyuan <15816141883@163.com> Date: Sat, 31 Jan 2026 11:51:48 +0800 Subject: [PATCH 1/2] "Fix" crash if somehow nothing is selected in BattleUI --- src/engine/game/battle/ui/battleui.lua | 36 ++++++++++++++------------ 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/engine/game/battle/ui/battleui.lua b/src/engine/game/battle/ui/battleui.lua index c41923d62e..6bba49559a 100644 --- a/src/engine/game/battle/ui/battleui.lua +++ b/src/engine/game/battle/ui/battleui.lua @@ -36,7 +36,7 @@ function BattleUI:init() local size_offset = 0 local box_gap = 0 - + if #Game.battle.party == 3 then size_offset = 0 box_gap = 0 @@ -189,7 +189,7 @@ function BattleUI:update() self.animation_y = 0 end end - + self.y = lower - self.animation_y for _, box in ipairs(self.action_boxes) do @@ -344,22 +344,24 @@ function BattleUI:drawState() end -- Print information about currently selected item - local tp_offset, _ = 0, nil --initialize placeholdder variable so it doenst go in global scope local current_item = Game.battle.menu_items[Game.battle:getItemIndex()] - if current_item.description then - Draw.setColor(COLORS.gray) - love.graphics.print(current_item.description, 260 + 240, 50) - Draw.setColor(1, 1, 1, 1) - _, tp_offset = current_item.description:gsub('\n', '\n') - tp_offset = tp_offset + 1 - end + if current_item then + if current_item.description then + Draw.setColor(COLORS.gray) + love.graphics.print(current_item.description, 260 + 240, 50) + Draw.setColor(1, 1, 1, 1) + local tp_offset, _ = 0, nil --initialize placeholdder variable so it doenst go in global scope + _, tp_offset = current_item.description:gsub('\n', '\n') + tp_offset = tp_offset + 1 + end - if current_item.tp and current_item.tp ~= 0 then - Draw.setColor(PALETTE["tension_desc"]) - love.graphics.print(math.floor((current_item.tp / Game:getMaxTension()) * 100) .. "% "..Game:getConfig("tpName"), 260 + 240, 50 + (tp_offset * 32)) - Game:setTensionPreview(current_item.tp) - else - Game:setTensionPreview(0) + if current_item.tp and current_item.tp ~= 0 then + Draw.setColor(PALETTE["tension_desc"]) + love.graphics.print(math.floor((current_item.tp / Game:getMaxTension()) * 100) .. "% "..Game:getConfig("tpName"), 260 + 240, 50 + (tp_offset * 32)) + Game:setTensionPreview(current_item.tp) + else + Game:setTensionPreview(0) + end end Draw.setColor(1, 1, 1, 1) @@ -486,7 +488,7 @@ function BattleUI:drawState() Draw.setColor(128/255, 128/255, 128/255, 1) - + if ((80 + namewidth + 60 + (font:getWidth(enemy.comment) / 2)) < 415) then love.graphics.print(enemy.comment, 80 + namewidth + 60, 50 + y_off) else From 6dd7766390b7e599cd9e3b8a547afd9452d26c02 Mon Sep 17 00:00:00 2001 From: Liu Wenyuan <15816141883@163.com> Date: Sat, 31 Jan 2026 11:53:29 +0800 Subject: [PATCH 2/2] Prevent player from entering spell menu if there are no spells --- src/engine/game/battle/ui/actionbutton.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/engine/game/battle/ui/actionbutton.lua b/src/engine/game/battle/ui/actionbutton.lua index 255c44d40d..1879fc1712 100644 --- a/src/engine/game/battle/ui/actionbutton.lua +++ b/src/engine/game/battle/ui/actionbutton.lua @@ -129,7 +129,9 @@ function ActionButton:select() }) end - Game.battle:setState("MENUSELECT", "SPELL") + if #Game.battle.menu_items > 0 then + Game.battle:setState("MENUSELECT", "SPELL") + end elseif self.type == "item" then Game.battle:clearMenuItems() for i,item in ipairs(Game.inventory:getStorage("items")) do