-- Patch: views/inventoryWindow.lua -- the "this item has no actions" case. -- -- Pressing enter/z on an inventory cell calls window.enableItemMenu(), which -- builds the item's action list via modules/item/getActionsList.lua. That list is -- filtered by per-action `condition`s, and getActionsList returns NIL when none -- of them apply -- a plain reagent, say, which you can neither wield, drink, read -- nor switch on. newItemMenu then returns nil, enableItemMenu returns nil, and -- the game does *literally nothing*: no menu, and not even the sound.select click -- it plays on success. -- -- Sighted players see the absence of a popup. By ear that is indistinguishable -- from a dropped keypress, so this says so out loud. The successful case is NOT -- announced here -- accessibility/states/_itemgrid.lua reads the open menu. -- -- ORDERING: like patches/slider.lua this replaces package.loaded, so it only -- affects requires that happen afterwards. Safe for the same reason: states are -- loaded lazily by states.lua, and applyPatches() runs before the self-test. local speech = require("accessibility.speech") return function() local newInventoryWindow = require("views.inventoryWindow") if type(newInventoryWindow) ~= "function" then error("views.inventoryWindow is not a factory function -- game structure changed") end package.loaded["views.inventoryWindow"] = function(...) local window = newInventoryWindow(...) local realEnable = window.enableItemMenu if type(realEnable) ~= "function" then return window end window.enableItemMenu = function(...) local result = realEnable(...) if not result then pcall(function() local ok, item = pcall(window.getItemOnCursor) if not ok or not item then return end speech.say((item.name or "This item") .. ", no actions", true) end) end return result end return window end end