@@ -38,6 +38,7 @@ local F = require("scripts.field-ref")
3838local Filters = require (" scripts.filters" )
3939local Graphics = require (" scripts.graphics" )
4040local InventoryTransfers = require (" scripts.inventory-transfers" )
41+ local InventoryUtils = require (" scripts.inventory-utils" )
4142local ItemDescriptions = require (" scripts.item-descriptions" )
4243local KruiseKontrol = require (" scripts.kruise-kontrol-wrapper" )
4344local Localising = require (" scripts.localising" )
@@ -67,7 +68,7 @@ require("scripts.ui.selectors.upgrade-selector")
6768require (" scripts.ui.selectors.blueprint-selector" )
6869require (" scripts.ui.selectors.copy-paste-selector" )
6970require (" scripts.ui.menus.gun-menu" )
70- require (" scripts.ui.menus.main-menu" )
71+ local MainMenu = require (" scripts.ui.menus.main-menu" )
7172require (" scripts.ui.menus.fast-travel-menu" )
7273require (" scripts.ui.menus.debug-menu" )
7374require (" scripts.ui.tabs.item-chooser" )
@@ -2785,12 +2786,8 @@ local function kb_open_player_inventory(event)
27852786 sounds .play_open_inventory (p .index )
27862787 p .selected = nil
27872788
2788- -- Use the router to open the main menu
2789- local router = UiRouter .get_router (pindex )
2790- router :open_ui (
2791- UiRouter .UI_NAMES .MAIN ,
2792- { player_inventory = { entity = p .character , inventory_index = defines .inventory .character_main } }
2793- )
2789+ -- Open the main menu
2790+ MainMenu .open_main_menu (pindex )
27942791end
27952792
27962793EventManager .on_event (
@@ -4189,16 +4186,6 @@ EventManager.on_event("fa-cas-r", function(event, pindex)
41894186 game .reload_script ()
41904187end )
41914188
4192- EventManager .on_event (
4193- " fa-o" ,
4194- --- @param event EventData.CustomInputEvent
4195- function (event , pindex )
4196- local p = game .get_player (pindex )
4197- if p .character == nil then return end
4198- if p .driving == true then Driving .pda_read_cruise_control_toggled_info (event .player_index ) end
4199- end
4200- )
4201-
42024189EventManager .on_event (" fa-c-o" , function (event )
42034190 Speech .speak (
42044191 event .player_index ,
@@ -4279,3 +4266,47 @@ EventManager.on_event(
42794266 KruiseKontrol .cancel_kk (pindex )
42804267 end
42814268)
4269+
4270+ -- Send hand contents to trash: O key
4271+ EventManager .on_event (" fa-o" , function (event )
4272+ local pindex = event .player_index
4273+ local player = game .get_player (pindex )
4274+ if not player or not player .character then return end
4275+
4276+ local cursor_stack = player .cursor_stack
4277+ if not cursor_stack or not cursor_stack .valid_for_read then
4278+ Speech .speak (pindex , { " fa.trash-nothing-in-hand" })
4279+ return
4280+ end
4281+
4282+ -- Get character's trash inventory
4283+ local trash_inventory = InventoryUtils .find_trash_inventory (player .character )
4284+ if not trash_inventory then
4285+ Speech .speak (pindex , { " fa.trash-not-available" })
4286+ return
4287+ end
4288+
4289+ -- Try to insert into trash
4290+ local item_name = cursor_stack .name
4291+ local item_count = cursor_stack .count
4292+ local item_quality = cursor_stack .quality and cursor_stack .quality .name or nil
4293+
4294+ local inserted = trash_inventory .insert ({ name = item_name , count = item_count , quality = item_quality })
4295+
4296+ if inserted > 0 then
4297+ -- Remove from hand
4298+ cursor_stack .count = cursor_stack .count - inserted
4299+
4300+ -- Announce success
4301+ local item_description = Localising .localise_item ({
4302+ name = item_name ,
4303+ count = inserted ,
4304+ quality = item_quality ,
4305+ })
4306+ Speech .speak (pindex , { " fa.trash-sent-to-trash" , item_description })
4307+
4308+ if inserted < item_count then Speech .speak (pindex , { " fa.trash-full" , tostring (item_count - inserted ) }) end
4309+ else
4310+ Speech .speak (pindex , { " fa.trash-full-none-inserted" })
4311+ end
4312+ end , EventManager .EVENT_KIND .WORLD )
0 commit comments