diff --git a/compatibility/Distro.lua b/compatibility/Distro.lua index 22916afe..727eeae4 100644 --- a/compatibility/Distro.lua +++ b/compatibility/Distro.lua @@ -1,4 +1,7 @@ if SMODS.Mods["Distro"] and SMODS.Mods["Distro"].can_load then + Distro = Distro or nil + DiscordIPC = DiscordIPC or nil + if not DiscordIPC or not Distro then return end G.E_MANAGER:add_event(Event({ trigger = "immediate", no_delete = true, diff --git a/compatibility/Handy.lua b/compatibility/Handy.lua index 7b1ac9eb..9c805082 100644 --- a/compatibility/Handy.lua +++ b/compatibility/Handy.lua @@ -1,3 +1,4 @@ +Handy = Handy or nil if Handy then -- In this version all checks included in mod, but since I care about older versions, keep all patches if not (Handy.meta and Handy.meta["1.5.1a_multiplayer_check"]) then diff --git a/compatibility/HotPotato.lua b/compatibility/HotPotato.lua index f5892c9c..4919dd43 100644 --- a/compatibility/HotPotato.lua +++ b/compatibility/HotPotato.lua @@ -7,9 +7,11 @@ if SMODS.Mods["HotPotato"] and SMODS.Mods["HotPotato"].can_load then MP.DECK.ban_card("j_joker") MP.DECK.ban_card("j_hpot_lotus") MP.DECK.ban_card("j_hpot_c_sharp") - MP.DECK.ban_card("j_hpot_goblin_tinkerer") -- too easy to infinite + Wheel = Wheel or nil + if not Wheel then return end + -- essentially we're just hooking a bunch of functions to separate and normalise rng -- i was gonna hook more but it ended up only being 2 so whatever diff --git a/compatibility/JokerDisplay.lua b/compatibility/JokerDisplay.lua index 03575829..1eb99a40 100644 --- a/compatibility/JokerDisplay.lua +++ b/compatibility/JokerDisplay.lua @@ -1,4 +1,5 @@ if SMODS.Mods["JokerDisplay"] and SMODS.Mods["JokerDisplay"].can_load then + JokerDisplay = JokerDisplay or nil if JokerDisplay then local jd_def = JokerDisplay.Definitions jd_def["j_mp_conjoined_joker"] = { diff --git a/compatibility/Preview/CorePreview.lua b/compatibility/Preview/CorePreview.lua index d95e3deb..789a091b 100644 --- a/compatibility/Preview/CorePreview.lua +++ b/compatibility/Preview/CorePreview.lua @@ -3,7 +3,7 @@ function FN.PRE.simulate() -- Guard against simulating in redundant places: - if FN.PRE.five_second_coroutine and coroutine.status(FN.PRE.five_second_coroutine) == "suspended" then + if FN.PRE.five_second_coroutine and (coroutine.status(FN.PRE.five_second_coroutine) == "suspended") then coroutine.resume(FN.PRE.five_second_coroutine) end if @@ -52,7 +52,7 @@ function CardArea:parse_highlighted() orig_hl(self) if not MP.INTEGRATIONS.Preview then return end - if not FN.PRE.lock_updates and FN.PRE.show_preview then FN.PRE.show_preview = false end + if (not FN.PRE.lock_updates) and FN.PRE.show_preview then FN.PRE.show_preview = false end FN.PRE.add_update_event("immediate") end @@ -89,7 +89,7 @@ function FN.PRE.update_on_card_order_change(cardarea) if G.STATE == G.STATES.HAND_PLAYED then return end local prev_order = nil - if cardarea.config.type == "joker" and cardarea.cards[1].ability.set == "Joker" then + if (cardarea.config.type == "joker") and (cardarea.cards[1].ability.set == "Joker") then if cardarea.cards[1].edition and cardarea.cards[1].edition.mp_phantom then return end -- Note that the consumables cardarea also has type 'joker' so must verify by checking first card. prev_order = FN.PRE.joker_order @@ -102,9 +102,9 @@ function FN.PRE.update_on_card_order_change(cardarea) -- Go through stored card IDs and check against current card IDs, in-order. -- If any mismatch occurs, toggle flag and update name for next time. local should_update = false - if #cardarea.cards ~= #prev_order then prev_order = {} end + if (not prev_order) or (#cardarea.cards ~= #prev_order) then prev_order = {} end for i, c in ipairs(cardarea.cards) do - if c.sort_id ~= prev_order[i] then + if c and (c.sort_id ~= prev_order[i]) then prev_order[i] = c.sort_id should_update = true end diff --git a/compatibility/Preview/EngineSimulate.lua b/compatibility/Preview/EngineSimulate.lua index 19db24f3..54eab3b5 100644 --- a/compatibility/Preview/EngineSimulate.lua +++ b/compatibility/Preview/EngineSimulate.lua @@ -291,6 +291,7 @@ if not FN.SIM.run then function FN.SIM.simulate_blind_debuffs() local blind_obj = G.GAME.blind + if not blind_obj then return false end if blind_obj.disabled then return false end -- The following are part of Blind:press_play() diff --git a/compatibility/Preview/InterfacePreview.lua b/compatibility/Preview/InterfacePreview.lua index cba5eb94..a9a955a1 100644 --- a/compatibility/Preview/InterfacePreview.lua +++ b/compatibility/Preview/InterfacePreview.lua @@ -121,7 +121,7 @@ function FN.get_preview_settings_page() FN.PRE.data = FN.PRE.simulate() else -- Preview was just disabled, so remove preview node: - G.HUD:get_UIE_by_ID("fn_pre_score").parent:remove() + G.HUD:get_UIE_by_ID("fn_pre_score").parent:remove() ---@diagnostic disable-line: undefined-field end G.HUD:recalculate() end @@ -135,7 +135,7 @@ function FN.get_preview_settings_page() FN.PRE.data = FN.PRE.simulate() else -- Preview was just disabled, so remove preview node: - G.HUD:get_UIE_by_ID("fn_pre_dollars").parent:remove() + G.HUD:get_UIE_by_ID("fn_pre_dollars").parent:remove() ---@diagnostic disable-line: undefined-field end G.HUD:recalculate() end diff --git a/compatibility/Preview/Jokers/Multiplayer.lua b/compatibility/Preview/Jokers/Multiplayer.lua index 795d4b4e..66d6e06a 100644 --- a/compatibility/Preview/Jokers/Multiplayer.lua +++ b/compatibility/Preview/Jokers/Multiplayer.lua @@ -1,3 +1,7 @@ +FN.SIM = FN.SIM or nil +FNSJ = FNSJ or nil +if not FN.SIM or not FNSJ then return end + FNSJ.simulate_mp_defensive_joker = function(joker_obj, context) if context.cardarea == G.jokers and context.global then FN.SIM.add_chips(joker_obj.ability.t_chips) end end diff --git a/compatibility/Preview/UtilsPreview.lua b/compatibility/Preview/UtilsPreview.lua index 97eaa8b0..2cf1de1b 100644 --- a/compatibility/Preview/UtilsPreview.lua +++ b/compatibility/Preview/UtilsPreview.lua @@ -16,7 +16,7 @@ function FN.PRE.format_number(num) -- Start using e-notation earlier to reduce number length, if showing min and max for preview: if true and num >= 1e7 then local x = string.format("%.4g", num) - local fac = math.floor(math.log(tonumber(x), 10)) + local fac = math.floor(math.log(tonumber(x) or 1, 10)) return string.format("%.2f", x / (10 ^ fac)) .. "e" .. fac end return number_format(num) -- Default Balatro function. diff --git a/compatibility/TheOrder.lua b/compatibility/TheOrder.lua index 6370ce18..5ce128f8 100644 --- a/compatibility/TheOrder.lua +++ b/compatibility/TheOrder.lua @@ -45,12 +45,12 @@ function reset_idol_card() if #valid_idol_cards == 0 then return end local value_order = {} - for i, rank in ipairs(SMODS.Rank.obj_buffer) do + for i, rank in ipairs(SMODS.Rank.obj_buffer) do ---@diagnostic disable-line: param-type-mismatch value_order[rank] = i end local suit_order = {} - for i, suit in ipairs(SMODS.Suit.obj_buffer) do + for i, suit in ipairs(SMODS.Suit.obj_buffer) do ---@diagnostic disable-line: param-type-mismatch suit_order[suit] = i end @@ -111,7 +111,7 @@ function reset_mail_rank() local count_map = {} local total_weight = 0 local value_order = {} - for i, rank in ipairs(SMODS.Rank.obj_buffer) do + for i, rank in ipairs(SMODS.Rank.obj_buffer) do ---@diagnostic disable-line: param-type-mismatch value_order[rank] = i end diff --git a/compatibility/TooManyJokers.lua b/compatibility/TooManyJokers.lua index 28df2f34..c931f7d7 100644 --- a/compatibility/TooManyJokers.lua +++ b/compatibility/TooManyJokers.lua @@ -1,3 +1,4 @@ +TMJ = TMJ or nil if TMJ then TMJ.ALLOW_HIGHLIGHT = false --this is implemented in a hook, can't move it over here G.FUNCS.tmj_spawn = function() diff --git a/compatibility/UpgradeMod.lua b/compatibility/UpgradeMod.lua index 5f111024..bad00b37 100644 --- a/compatibility/UpgradeMod.lua +++ b/compatibility/UpgradeMod.lua @@ -36,7 +36,9 @@ if SMODS.Mods["upgrademod"] and SMODS.Mods["upgrademod"].can_load then level = G.GAME.hands[hand_type].level, }) - level_up_hand(nil, hand_type, false, -((asteroid_factor or 1) * (planet_level or 1))) + asteroid_factor = asteroid_factor or 1 + planet_level = planet_level or 1 + level_up_hand(nil, hand_type, false, -(asteroid_factor * planet_level)) update_hand_text( { sound = "button", volume = 0.7, pitch = 1.1, delay = 0 }, diff --git a/core.lua b/core.lua index 571d9bc9..aece39f3 100644 --- a/core.lua +++ b/core.lua @@ -82,13 +82,13 @@ function MP.load_mp_dir(directory, recursive) local items = NFS.getDirectoryItemsInfo(dir_path) -- sort by prefix like { _file, _dir, file, dir } table.sort(items, function(a, b) - if has_prefix(a.name) ~= has_prefix(b.name) then return has_prefix(a.name) end + if has_prefix(a.name) ~= has_prefix(b.name) then return has_prefix(a.name) end ---@diagnostic disable-line: undefined-field return (a.type == "directory") ~= (b.type == "directory") and a.type ~= "directory" or false end) -- load sorted files/dirs for _, item in ipairs(items) do - local path = directory .. "/" .. item.name + local path = directory .. "/" .. item.name ---@diagnostic disable-line: undefined-field sendDebugMessage("Loading item: " .. path, "MULTIPLAYER") if item.type ~= "directory" then MP.load_mp_file(path) diff --git a/lib/joker_stats.lua b/lib/joker_stats.lua index b3a0f19d..741cc017 100644 --- a/lib/joker_stats.lua +++ b/lib/joker_stats.lua @@ -14,6 +14,7 @@ end function MP.STATS.record_match(won) local config = SMODS.Mods["Multiplayer"].config + if not config then return end config.joker_stats = config.joker_stats or {} config.match_history = config.match_history or {} @@ -40,5 +41,5 @@ end function MP.STATS.get_joker_wins(joker_key) local config = SMODS.Mods["Multiplayer"].config - return config.joker_stats and config.joker_stats[joker_key] or 0 + return config and config.joker_stats[joker_key] or 0 end diff --git a/objects/challenges/polymorph_spam.lua b/objects/challenges/polymorph_spam.lua index 31a90bb3..24b2614e 100644 --- a/objects/challenges/polymorph_spam.lua +++ b/objects/challenges/polymorph_spam.lua @@ -8,7 +8,7 @@ SMODS.Challenge({ }, }, restrictions = { - banned_cards = function() + banned_cards = function() ---@diagnostic disable-line: assign-type-mismatch local ret = {} local add = { j_campfire = true, @@ -39,6 +39,7 @@ end local function get_pos(card) local area = get_area(card) + if not area then return nil end for i, v in ipairs(area.cards) do if card == v then return i end end @@ -59,6 +60,7 @@ local function get_transmutations_loc(card) local done = false local num = 0 local area = get_area(card) + if not area then return nil end local limit = area.config.card_limit local pos = get_pos(card) or nil local ret = {} @@ -104,7 +106,8 @@ local function mass_polymorph(area) break end if v == card.config.center then - swap = get_pos(card) + local pos = get_pos(card) + if pos then swap = pos end else swap = math.max(swap - 1, 0) end @@ -159,8 +162,10 @@ function localize(args, misc_cat) table.remove(loc_target, 2) end local list = get_transmutations_loc(transmute_card) - for i = 1, #list do - loc_target[#loc_target + 1] = { list[i] } + if list then + for i = 1, #list do + loc_target[#loc_target + 1] = { list[i] } + end end end return localize_ref(args, misc_cat) diff --git a/objects/consumables/asteroid.lua b/objects/consumables/asteroid.lua index 5bbb0d86..b9bba4e6 100644 --- a/objects/consumables/asteroid.lua +++ b/objects/consumables/asteroid.lua @@ -1,6 +1,6 @@ SMODS.Atlas({ key = "asteroid", - path = { + path = { ---@diagnostic disable-line: assign-type-mismatch ["default"] = "c_asteroid.png", ["ru"] = "c_asteroid_ru.png", }, diff --git a/objects/decks/02_orange.lua b/objects/decks/02_orange.lua index c0470dba..be74d679 100644 --- a/objects/decks/02_orange.lua +++ b/objects/decks/02_orange.lua @@ -7,7 +7,7 @@ SMODS.Back({ apply = function(self) stop_use() local lock = self.key - G.CONTROLLER.locks[lock] = true + G.CONTROLLER.locks[lock] = true ---@diagnostic disable-line: need-check-nil -- "yeah just triple layer the event surely that works...WHAT THE SHIT" G.E_MANAGER:add_event(Event({ func = function() @@ -30,7 +30,7 @@ SMODS.Back({ delay(0.2) G.FUNCS.use_card({ config = { ref_table = card } }) card:start_materialize() - G.CONTROLLER.locks[lock] = nil + G.CONTROLLER.locks[lock] = nil ---@diagnostic disable-line: need-check-nil return true end, })) diff --git a/objects/decks/ZZ_cocktail.lua b/objects/decks/ZZ_cocktail.lua index ca937b9a..3c256af5 100644 --- a/objects/decks/ZZ_cocktail.lua +++ b/objects/decks/ZZ_cocktail.lua @@ -86,7 +86,7 @@ SMODS.Back({ back:change_to(G.P_CENTERS[G.GAME.modifiers.mp_cocktail[i]]) local ret1, ret2 = back:trigger_effect(context) back:change_to(G.P_CENTERS["b_mp_cocktail"]) - if ret1 or ret2 then return ret1, ret2 end + if ret1 or ret2 then return ret1, ret2 end ---@diagnostic disable-line: return-type-mismatch end end, mp_credits = { art = { "aura!", "shai1n" }, code = { "Toneblock" } }, @@ -426,6 +426,7 @@ end local highlight_ref = Card.highlight function Card:highlight(is_highlighted) + self.mp_cocktail_select = self.mp_cocktail_select or nil if self.mp_cocktail_select then local shift = G.CONTROLLER.held_keys["lshift"] or G.CONTROLLER.held_keys["rshift"] if shift and self.mp_cocktail_forced then @@ -484,6 +485,7 @@ G.E_MANAGER:add_event(Event({ func = function() local decks = MP.get_cocktail_decks() local cfg = SMODS.Mods["Multiplayer"].config + if not cfg then return true end if (not cfg.cocktail) or #decks + 1 ~= #cfg.cocktail then local string = "" for i = 1, #decks do @@ -500,6 +502,7 @@ G.E_MANAGER:add_event(Event({ function MP.cocktail_cfg_edit(bool, deck) -- strings are easier to send, and it's just ones and zeroes local decks = MP.get_cocktail_decks() local cfg = SMODS.Mods["Multiplayer"].config + if not cfg then return end local num = (bool == 2) and "2" or (bool and "1" or "0") if not deck then local string = "" @@ -528,6 +531,7 @@ end function MP.cocktail_cfg_readpos(pos, construct) local decks = MP.get_cocktail_decks() -- copypasted code. unsure how to make this less messy without making it more messy local cfg = SMODS.Mods["Multiplayer"].config + if not cfg then return end if pos == "show" then pos = #cfg.cocktail end if construct then return MP.cocktail_cfg_get():sub(pos, pos) end return cfg.cocktail:sub(pos, pos) diff --git a/objects/decks/_decks.lua b/objects/decks/_decks.lua index 7e9877ac..77a5d9e1 100644 --- a/objects/decks/_decks.lua +++ b/objects/decks/_decks.lua @@ -9,6 +9,7 @@ SMODS.DrawStep({ key = "back_multiplayer", order = 11, func = function(self) + Galdur = Galdur or nil if not Galdur and G.GAME.viewed_back and G.GAME.viewed_back.effect and G.GAME.viewed_back.effect.center.mod then if G.GAME.viewed_back.effect.center.mod.id == "Multiplayer" and G.STAGE == G.STAGES.MAIN_MENU then G.shared_stickers["mp_sticker_balanced"].role.draw_major = self diff --git a/objects/jokers/sandbox/castle.lua b/objects/jokers/sandbox/castle.lua index b74770aa..0e1dd967 100644 --- a/objects/jokers/sandbox/castle.lua +++ b/objects/jokers/sandbox/castle.lua @@ -20,7 +20,7 @@ SMODS.Joker({ local suit = card.ability.extra.suit or G.GAME.current_round.castle_card.suit or "Spades" return { vars = { - string.upper(localize(suit, "suits_plural")), + string.upper(localize(suit, "suits_plural") or ""), colours = { G.C.SUITS[suit] }, card.ability.extra.chips, card.ability.extra.chip_mod, diff --git a/objects/jokers/sandbox/idol.lua b/objects/jokers/sandbox/idol.lua index 67be8efb..e88e00f6 100644 --- a/objects/jokers/sandbox/idol.lua +++ b/objects/jokers/sandbox/idol.lua @@ -122,12 +122,12 @@ local function get_most_common_card() -- Sort by count descending first, then by suit/value for consistency local value_order = {} - for i, rank in ipairs(SMODS.Rank.obj_buffer) do + for i, rank in ipairs(SMODS.Rank.obj_buffer) do ---@diagnostic disable-line: param-type-mismatch value_order[rank] = i end local suit_order = {} - for i, suit in ipairs(SMODS.Suit.obj_buffer) do + for i, suit in ipairs(SMODS.Suit.obj_buffer) do ---@diagnostic disable-line: param-type-mismatch suit_order[suit] = i end diff --git a/objects/jokers/sandbox/vampire.lua b/objects/jokers/sandbox/vampire.lua index 97c698c0..e18b9616 100644 --- a/objects/jokers/sandbox/vampire.lua +++ b/objects/jokers/sandbox/vampire.lua @@ -26,7 +26,7 @@ SMODS.Joker({ local stone_cards = {} for _, scored_card in ipairs(context.scoring_hand) do if - next(SMODS.get_enhancements(scored_card)) + next(SMODS.get_enhancements(scored_card)) ---@diagnostic disable-line: param-type-mismatch and not scored_card.debuff and not scored_card.vampired and not SMODS.has_enhancement(scored_card, "m_stone") -- todo like this - does it even work? diff --git a/overrides/mod_badges.lua b/overrides/mod_badges.lua index 94cf2250..20523bf0 100644 --- a/overrides/mod_badges.lua +++ b/overrides/mod_badges.lua @@ -13,9 +13,9 @@ function SMODS.create_mod_badges(obj, badges) local calced_text_width = 0 -- Math reproduced from DynaText:update_text for _, c in utf8.chars(text) do - local tx = font.FONT:getWidth(c) * (0.33 * size) * G.TILESCALE * font.FONTSCALE - + 2.7 * 1 * G.TILESCALE * font.FONTSCALE - calced_text_width = calced_text_width + tx / (G.TILESIZE * G.TILESCALE) + local scale = G.TILESCALE * font.FONTSCALE ---@diagnostic disable-line: undefined-field + local tx = scale * (font.FONT:getWidth(c) * 0.33 * size + 2.7) ---@diagnostic disable-line: undefined-field + calced_text_width = calced_text_width + (tx / (G.TILESIZE * G.TILESCALE)) end local scale_fac = calced_text_width > max_text_width and max_text_width / calced_text_width or 1 return scale_fac diff --git a/rulesets/_rulesets.lua b/rulesets/_rulesets.lua index 3da73374..673423ac 100644 --- a/rulesets/_rulesets.lua +++ b/rulesets/_rulesets.lua @@ -140,7 +140,7 @@ function MP.ReworkCenter(key, ruleset, loc_key, args) -- Auto-inject generate_ui when adding loc_vars to vanilla centers if needs_generate_ui then - center[prefix .. "generate_ui"] = SMODS.Center.generate_ui + center[prefix .. "generate_ui"] = SMODS.Center.generate_ui ---@diagnostic disable-line: assign-type-mismatch if not center.mp_vanilla_generate_ui then center.mp_vanilla_generate_ui = center.generate_ui or "NULL" end end diff --git a/rulesets/smallworld.lua b/rulesets/smallworld.lua index 0e8ac2d0..66c049c3 100644 --- a/rulesets/smallworld.lua +++ b/rulesets/smallworld.lua @@ -133,7 +133,7 @@ function MP.apply_fake_back_vouchers(back) for i, v in ipairs(fake_back.effect.config.vouchers) do local voucher = v if G.GAME.banned_keys[v] or G.GAME.used_vouchers[v] then voucher = get_next_voucher_key() end - G.GAME.used_vouchers[voucher] = true + G.GAME.used_vouchers[voucher] = true ---@diagnostic disable-line: need-check-nil fake_back.effect.config.vouchers[i] = voucher end G.GAME.current_round.voucher = SMODS.get_next_vouchers() -- the extreme jank doesn't matter as long as it's synced ig diff --git a/ui/game/functions.lua b/ui/game/functions.lua index 7759aacf..47e86ae2 100644 --- a/ui/game/functions.lua +++ b/ui/game/functions.lua @@ -225,7 +225,7 @@ function G.FUNCS.attention_text_realtime(args) args.AT.attention_text = true args.text = args.AT.UIRoot.children[1].config.object - args.text:pulse(0.5) + args.text:pulse(0.5) ---@diagnostic disable-line: undefined-field if args.cover then Particles(args.pos.x, args.pos.y, 0, 0, { @@ -268,7 +268,7 @@ function G.FUNCS.attention_text_realtime(args) func = function() if not args.start_time then args.start_time = G.TIMERS.TOTAL - args.text:pop_out(3) + args.text:pop_out(3) ---@diagnostic disable-line: undefined-field else args.fade = math.max(0, 1 - 3 * (G.TIMERS.TOTAL - args.start_time)) if args.cover_colour then args.cover_colour[4] = math.min(args.cover_colour[4], 2 * args.fade) end @@ -295,16 +295,15 @@ function G.FUNCS.overlay_endgame_menu() delay = 2.5, blocking = false, func = function() - if G.OVERLAY_MENU and G.OVERLAY_MENU:get_UIE_by_ID("jimbo_spot") then - local Jimbo = Card_Character({ x = 0, y = 5 }) - local spot = G.OVERLAY_MENU:get_UIE_by_ID("jimbo_spot") - spot.config.object:remove() - spot.config.object = Jimbo - Jimbo.ui_object_updated = true - local jimbo_words = MP.GAME.won and "wq_" .. math.random(1, 7) or "lq_" .. math.random(1, 10) - Jimbo:add_speech_bubble(jimbo_words, nil, { quip = true }) - Jimbo:say_stuff(5) - end + if not G.OVERLAY_MENU then return true end + local spot = G.OVERLAY_MENU:get_UIE_by_ID("jimbo_spot") ---@diagnostic disable-line: undefined-field + local Jimbo = Card_Character({ x = 0, y = 5 }) + spot.config.object:remove() + spot.config.object = Jimbo + Jimbo.ui_object_updated = true + local jimbo_words = MP.GAME.won and "wq_" .. math.random(1, 7) or "lq_" .. math.random(1, 10) + Jimbo:add_speech_bubble(jimbo_words, nil, { quip = true }) + Jimbo:say_stuff(5) return true end, })) diff --git a/ui/game/game_end.lua b/ui/game/game_end.lua index 8722c01f..6ff12a28 100644 --- a/ui/game/game_end.lua +++ b/ui/game/game_end.lua @@ -421,10 +421,9 @@ function create_UIBox_win() end local exit_overlay_menu_ref = G.FUNCS.exit_overlay_menu ----@diagnostic disable-next-line: duplicate-set-field -function G.FUNCS:exit_overlay_menu() +function G.FUNCS:exit_overlay_menu() ---@diagnostic disable-line: duplicate-set-field -- Saves username if user presses ESC instead of Enter - if G.OVERLAY_MENU and G.OVERLAY_MENU:get_UIE_by_ID("username_input_box") ~= nil then + if G.OVERLAY_MENU and G.OVERLAY_MENU:get_UIE_by_ID("username_input_box") ~= nil then ---@diagnostic disable-line: undefined-field MP.UTILS.save_username(MP.LOBBY.username) end @@ -433,7 +432,7 @@ end local mods_button_ref = G.FUNCS.mods_button function G.FUNCS.mods_button(arg_736_0) - if G.OVERLAY_MENU and G.OVERLAY_MENU:get_UIE_by_ID("username_input_box") ~= nil then + if G.OVERLAY_MENU and G.OVERLAY_MENU:get_UIE_by_ID("username_input_box") ~= nil then ---@diagnostic disable-line: undefined-field MP.UTILS.save_username(MP.LOBBY.username) end @@ -447,5 +446,3 @@ function G.UIDEF.multiplayer_deck() false ) end - - diff --git a/ui/game/game_state.lua b/ui/game/game_state.lua index 574c00fb..ce2e338d 100644 --- a/ui/game/game_state.lua +++ b/ui/game/game_state.lua @@ -91,7 +91,7 @@ end local function eval_hand_and_jokers() for i = 1, #G.hand.cards do --Check for hand doubling - local reps = { 1 } + local reps = { 1 } ---@type (number|table)[] local j = 1 while j <= #reps do local percent = (i - 0.999) / (#G.hand.cards - 0.998) + (j - 1) * 0.1 @@ -179,8 +179,7 @@ local function eval_hand_and_jokers() end local update_hand_played_ref = Game.update_hand_played ----@diagnostic disable-next-line: duplicate-set-field -function Game:update_hand_played(dt) +function Game:update_hand_played(dt) ---@diagnostic disable-line: duplicate-set-field -- Ignore for singleplayer or regular blinds if not MP.LOBBY.connected or not MP.LOBBY.code or not MP.is_pvp_boss() then update_hand_played_ref(self, dt) @@ -317,9 +316,7 @@ function Game:update_shop(dt) updated_location = true MP.ACTIONS.set_location("loc_shop") MP.GAME.spent_before_shop = to_big(MP.GAME.spent_total) + to_big(0) - if MP.UI.show_enemy_location then - MP.UI.show_enemy_location() - end + if MP.UI.show_enemy_location then MP.UI.show_enemy_location() end end if G.STATE_COMPLETE and updated_location then updated_location = false end update_shop_ref(self, dt) @@ -331,9 +328,7 @@ function Game:update_blind_select(dt) if MP.LOBBY.code and not G.STATE_COMPLETE and not updated_location then updated_location = true MP.ACTIONS.set_location("loc_selecting") - if MP.UI.show_enemy_location then - MP.UI.show_enemy_location() - end + if MP.UI.show_enemy_location then MP.UI.show_enemy_location() end end if G.STATE_COMPLETE and updated_location then updated_location = false end update_blind_select_ref(self, dt) @@ -350,8 +345,9 @@ function Game:start_run(args) local scale = 0.4 local hud_ante = G.HUD:get_UIE_by_ID("hud_ante") - hud_ante.children[1].children[1].config.text = localize("k_lives") + if not hud_ante then return end + hud_ante.children[1].children[1].config.text = localize("k_lives") -- Set lives number hud_ante.children[2].children[1].config.object = DynaText({ string = { { ref_table = MP.GAME, ref_value = "lives" } }, @@ -398,4 +394,3 @@ function MP.handle_deck_out() end end end - diff --git a/ui/game/timer.lua b/ui/game/timer.lua index ba3c4d13..ff252d3f 100644 --- a/ui/game/timer.lua +++ b/ui/game/timer.lua @@ -74,7 +74,7 @@ function MP.UI.timer_hud() end function MP.UI.start_pvp_countdown(callback) - local seconds = countdown_seconds + local seconds = 3 local tick_delay = 1 if MP.LOBBY and MP.LOBBY.config and MP.LOBBY.config.pvp_countdown_seconds then seconds = MP.LOBBY.config.pvp_countdown_seconds @@ -175,4 +175,3 @@ MP.timer_event = Event({ MP.timer_event.start_timer = false end, }) - diff --git a/ui/lobby/_lobby_options/main_options.lua b/ui/lobby/_lobby_options/main_options.lua index 0dd4a098..b0b1d195 100644 --- a/ui/lobby/_lobby_options/main_options.lua +++ b/ui/lobby/_lobby_options/main_options.lua @@ -83,15 +83,14 @@ end function MP.UI.Change_Main_Lobby_Options(e, info_area_id, info_area_func, default_button_id, update_lobby_config_func) if not G.OVERLAY_MENU then return end - - local info_area = G.OVERLAY_MENU:get_UIE_by_ID(info_area_id) + local info_area = G.OVERLAY_MENU:get_UIE_by_ID(info_area_id) ---@diagnostic disable-line: undefined-field if not info_area then return end -- Switch 'chosen' status from the previously-chosen button to this one: if info_area.config.prev_chosen then info_area.config.prev_chosen.config.chosen = nil else -- The previously-chosen button should be the default one here: - local default_button = G.OVERLAY_MENU:get_UIE_by_ID(default_button_id) + local default_button = G.OVERLAY_MENU:get_UIE_by_ID(default_button_id) ---@diagnostic disable-line: undefined-field if default_button then default_button.config.chosen = nil end end e.config.chosen = "vert" -- Special setting to show 'chosen' indicator on the side @@ -112,7 +111,7 @@ end function MP.UI.update_lobby_option_toggle(option_key) if G.OVERLAY_MENU then - local config_uie = G.OVERLAY_MENU:get_UIE_by_ID(option_key .. "_toggle") + local config_uie = G.OVERLAY_MENU:get_UIE_by_ID(option_key .. "_toggle") ---@diagnostic disable-line: undefined-field if config_uie then G.FUNCS.toggle(config_uie) end end end diff --git a/ui/lobby/lobby.lua b/ui/lobby/lobby.lua index 3b4fd3ff..1e50fa96 100644 --- a/ui/lobby/lobby.lua +++ b/ui/lobby/lobby.lua @@ -14,12 +14,15 @@ function G.UIDEF.get_connection_status_ui() colour = G.C.UI.TRANSPARENT_DARK, }, nodes = { - MP.UI.UTILS.create_text_node((MP.LOBBY.code and localize("k_in_lobby")) or (MP.LOBBY.connected and localize( - "k_connected" - )) or localize("k_warn_service"), { - scale = 0.3, - colour = G.C.UI.TEXT_LIGHT, - }), + MP.UI.UTILS.create_text_node( + (MP.LOBBY.code and localize("k_in_lobby")) + or (MP.LOBBY.connected and localize("k_connected")) + or localize("k_warn_service"), + { + scale = 0.3, + colour = G.C.UI.TEXT_LIGHT, + } + ), }, }, config = { @@ -186,10 +189,13 @@ function G.UIDEF.create_UIBox_view_hash(type) return ( create_UIBox_generic_options({ contents = { - MP.UI.UTILS.create_column({ padding = 0.07, align = "cm" }, MP.UI.modlist_to_view( - type == "host" and MP.LOBBY.host.config.Mods or MP.LOBBY.guest.config.Mods, - G.C.UI.TEXT_LIGHT - )), + MP.UI.UTILS.create_column( + { padding = 0.07, align = "cm" }, + MP.UI.modlist_to_view( + type == "host" and MP.LOBBY.host.config.Mods or MP.LOBBY.guest.config.Mods, + G.C.UI.TEXT_LIGHT + ) + ), }, }) ) @@ -352,7 +358,7 @@ end function G.FUNCS.lobby_choose_deck(e) G.FUNCS.setup_run(e) - if G.OVERLAY_MENU then G.OVERLAY_MENU:get_UIE_by_ID("run_setup_seed"):remove() end + if G.OVERLAY_MENU then G.OVERLAY_MENU:get_UIE_by_ID("run_setup_seed"):remove() end ---@diagnostic disable-line: undefined-field end local start_run_ref = G.FUNCS.start_run @@ -422,8 +428,7 @@ function G.FUNCS.custom_seed_reset(e) end local set_main_menu_UI_ref = set_main_menu_UI ----@diagnostic disable-next-line: lowercase-global -function set_main_menu_UI() +function set_main_menu_UI() ---@diagnostic disable-line: lowercase-global if MP.LOBBY.code then if G.MAIN_MENU_UI then G.MAIN_MENU_UI:remove() end if G.STAGE == G.STAGES.MAIN_MENU then G.FUNCS.display_lobby_main_menu_UI() end @@ -434,8 +439,7 @@ end local in_lobby = false local gameUpdateRef = Game.update ----@diagnostic disable-next-line: duplicate-set-field -function Game:update(dt) +function Game:update(dt) ---@diagnostic disable-line: duplicate-set-field -- Track lobby state transitions if (MP.LOBBY.code and not in_lobby) or (not MP.LOBBY.code and in_lobby) then in_lobby = not in_lobby @@ -493,8 +497,7 @@ function MP.UI.update_connection_status() end local gameMainMenuRef = Game.main_menu ----@diagnostic disable-next-line: duplicate-set-field -function Game:main_menu(change_context) +function Game:main_menu(change_context) ---@diagnostic disable-line: duplicate-set-field MP.UI.update_connection_status() gameMainMenuRef(self, change_context) end diff --git a/ui/lobby/start_ready_button.lua b/ui/lobby/start_ready_button.lua index 5d3931e1..522dbd8e 100644 --- a/ui/lobby/start_ready_button.lua +++ b/ui/lobby/start_ready_button.lua @@ -10,7 +10,10 @@ local function get_warnings() table.insert(warnings, { localize("k_warning_cheating1"), SMODS.Gradients.warning_text, 0.4 }) table.insert( warnings, - { string.format(localize("k_warning_cheating2"), MP.UTILS.random_message()), SMODS.Gradients.warning_text } + { + string.format(localize("k_warning_cheating2") or "", MP.UTILS.random_message()), + SMODS.Gradients.warning_text, + } ) end diff --git a/ui/main_menu/play_button/play_button_callbacks.lua b/ui/main_menu/play_button/play_button_callbacks.lua index 6e1a7baf..a67c02c8 100644 --- a/ui/main_menu/play_button/play_button_callbacks.lua +++ b/ui/main_menu/play_button/play_button_callbacks.lua @@ -54,7 +54,7 @@ function G.FUNCS.join_lobby(e) G.FUNCS.overlay_menu({ definition = G.UIDEF.create_UIBox_join_lobby_button(), }) - local text_input = G.OVERLAY_MENU:get_UIE_by_ID("text_input") + local text_input = G.OVERLAY_MENU:get_UIE_by_ID("text_input") ---@diagnostic disable-line: undefined-field G.FUNCS.select_text_input(text_input) end diff --git a/ui/main_menu/play_button/ruleset_selection.lua b/ui/main_menu/play_button/ruleset_selection.lua index ba8bd438..3d4ea2ad 100644 --- a/ui/main_menu/play_button/ruleset_selection.lua +++ b/ui/main_menu/play_button/ruleset_selection.lua @@ -47,8 +47,7 @@ function G.UIDEF.ruleset_selection_options(mode) "ruleset_area", default_ruleset_area, "change_ruleset_selection", - ruleset_buttons_data, - default_button + ruleset_buttons_data ) end diff --git a/ui/main_menu/title_card.lua b/ui/main_menu/title_card.lua index 5a94ff7e..258bef8b 100644 --- a/ui/main_menu/title_card.lua +++ b/ui/main_menu/title_card.lua @@ -27,6 +27,8 @@ end function Juice_up(thing, a, b) if SMODS.Mods["Talisman"] and SMODS.Mods["Talisman"].can_load then + Talisman = Talisman or nil + if not Talisman then return end local disable_anims = Talisman.config_file.disable_anims Talisman.config_file.disable_anims = false thing:juice_up(a, b) diff --git a/ui/smods_menu/smods_menu.lua b/ui/smods_menu/smods_menu.lua index 7f8718d7..959edfbb 100644 --- a/ui/smods_menu/smods_menu.lua +++ b/ui/smods_menu/smods_menu.lua @@ -15,7 +15,7 @@ end function G.FUNCS.change_blind_col(args) -- all we're doing is just saving + redefining the ui elements here MP.UTILS.save_blind_col(args.to_val) MP.LOBBY.blind_col = args.to_val - local sprite = G.OVERLAY_MENU:get_UIE_by_ID("blind_col_changer_sprite") + local sprite = G.OVERLAY_MENU:get_UIE_by_ID("blind_col_changer_sprite") ---@diagnostic disable-line: undefined-field sprite.config.object:remove() sprite.config.object = AnimatedSprite( 0, @@ -30,7 +30,7 @@ function G.FUNCS.change_blind_col(args) -- all we're doing is just saving + rede { shader = "dissolve" }, }) sprite.UIBox:recalculate() - local option = G.OVERLAY_MENU:get_UIE_by_ID("blind_col_changer_option") + local option = G.OVERLAY_MENU:get_UIE_by_ID("blind_col_changer_option") ---@diagnostic disable-line: undefined-field option.children[1].children[1].config.text = localize({ type = "name_text", key = MP.UTILS.blind_col_numtokey(MP.LOBBY.blind_col), set = "Blind" }) option.UIBox:recalculate()