Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3835,6 +3835,14 @@ local function read_coords(pindex, start_phrase)
end
Speech.speak(pindex, { "fa.inventory-slot-position", result, tostring(x), tostring(y) })
elseif router:is_ui_open(UiRouter.UI_NAMES.GUNS) then
-- Initialize guns_menu if it doesn't exist
if not storage.players[pindex].guns_menu then
storage.players[pindex].guns_menu = {
ammo_selected = false,
index = 1,
}
end

if storage.players[pindex].guns_menu.ammo_selected then
Speech.speak(pindex, { "fa.ammo-slot", tostring(storage.players[pindex].guns_menu.index) })
else
Expand Down
59 changes: 59 additions & 0 deletions scripts/equipment.lua
Original file line number Diff line number Diff line change
Expand Up @@ -497,12 +497,29 @@ function mod.guns_menu_open(pindex)

local p = game.get_player(pindex)
router:open_ui(UiRouter.UI_NAMES.GUNS)

-- Initialize guns_menu if it doesn't exist
if not storage.players[pindex].guns_menu then
storage.players[pindex].guns_menu = {
ammo_selected = false,
index = 1,
}
end

storage.players[pindex].guns_menu.ammo_selected = false
storage.players[pindex].guns_menu.index = 1
mod.guns_menu_read_slot(pindex, "Guns and ammo, ")
end

function mod.guns_menu_left(pindex)
-- Initialize guns_menu if it doesn't exist
if not storage.players[pindex].guns_menu then
storage.players[pindex].guns_menu = {
ammo_selected = false,
index = 1,
}
end

local index = storage.players[pindex].guns_menu.index
index = index - 1
if index == 0 then
Expand All @@ -517,6 +534,14 @@ function mod.guns_menu_left(pindex)
end

function mod.guns_menu_right(pindex)
-- Initialize guns_menu if it doesn't exist
if not storage.players[pindex].guns_menu then
storage.players[pindex].guns_menu = {
ammo_selected = false,
index = 1,
}
end

local index = storage.players[pindex].guns_menu.index
index = index + 1
if index == 4 then
Expand All @@ -530,12 +555,28 @@ function mod.guns_menu_right(pindex)
end

function mod.guns_menu_up_or_down(pindex)
-- Initialize guns_menu if it doesn't exist
if not storage.players[pindex].guns_menu then
storage.players[pindex].guns_menu = {
ammo_selected = false,
index = 1,
}
end

storage.players[pindex].guns_menu.ammo_selected = not storage.players[pindex].guns_menu.ammo_selected
game.get_player(pindex).play_sound({ path = "Inventory-Move" })
mod.guns_menu_read_slot(pindex)
end

function mod.guns_menu_get_selected_slot(pindex)
-- Initialize guns_menu if it doesn't exist
if not storage.players[pindex].guns_menu then
storage.players[pindex].guns_menu = {
ammo_selected = false,
index = 1,
}
end

local menu = storage.players[pindex].guns_menu
local p = game.get_player(pindex)
local gun_stack = p.get_inventory(defines.inventory.character_guns)[menu.index]
Expand All @@ -549,6 +590,15 @@ end

function mod.guns_menu_read_slot(pindex, start_phrase_in)
local start_phrase = start_phrase_in or ""

-- Initialize guns_menu if it doesn't exist
if not storage.players[pindex].guns_menu then
storage.players[pindex].guns_menu = {
ammo_selected = false,
index = 1,
}
end

local menu = storage.players[pindex].guns_menu
local p = game.get_player(pindex)
local result = { "" }
Expand Down Expand Up @@ -602,6 +652,15 @@ end
function mod.guns_menu_click_slot(pindex)
local p = game.get_player(pindex)
local hand = p.cursor_stack

-- Initialize guns_menu if it doesn't exist
if not storage.players[pindex].guns_menu then
storage.players[pindex].guns_menu = {
ammo_selected = false,
index = 1,
}
end

local menu = storage.players[pindex].guns_menu
local gun_stack = p.get_inventory(defines.inventory.character_guns)[menu.index]
local ammo_stack = p.get_inventory(defines.inventory.character_ammo)[menu.index]
Expand Down
10 changes: 8 additions & 2 deletions scripts/scanner/entrypoint.lua
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,17 @@ local function do_refresh_after_sfx(pindex, direction_filter)
-- scan refresh.
local ps = player_state[pindex]

-- Handle case where player state doesn't exist (e.g., old save)
if not ps then
player_state[pindex] = new_player_state(pindex)
ps = player_state[pindex]
end

do
local cat = ps.scanner_cursor.category
local cat = ps.scanner_cursor and ps.scanner_cursor.category
player_state[pindex] = new_player_state(pindex)
ps = player_state[pindex]
ps.scanner_cursor.category = cat
if cat then ps.scanner_cursor.category = cat end
end

local player_obj = assert(game.get_player(pindex))
Expand Down