From 652a2a8c9412bd2f606308b435cf60bf1a9def76 Mon Sep 17 00:00:00 2001 From: Cheesy-Brik <95463553+Cheesy-Brik@users.noreply.github.com> Date: Mon, 16 Dec 2024 11:16:01 -0600 Subject: [PATCH 01/21] Adds h_chips for hand chips --- lovely/fixes.toml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lovely/fixes.toml b/lovely/fixes.toml index 3f5e3073..4b8b68a4 100644 --- a/lovely/fixes.toml +++ b/lovely/fixes.toml @@ -517,3 +517,21 @@ pattern = """G.GAME.current_round.reroll_cost = math.max(0, G.GAME.current_round position = 'at' match_indent = true payload = """G.GAME.current_round.reroll_cost = math.max(0, G.GAME.current_round.reroll_cost - center_table.extra)""" + + +# Add h_chips as a viable hand effect +[[patches]] +[patches.pattern] +target = 'functions/state_events.lua' +pattern = '''card_eval_status_text(G.hand.cards[i], 'h_mult', effects[ii].h_mult, percent) + end''' +position = 'after' +match_indent = true +payload = ''' +if effects[ii].h_chips then + if effects[ii].card then juice_card(effects[ii].card) end + hand_chips = mod_chips(hand_chips + effects[ii].h_chips) + update_hand_text({delay = 0}, {chips = hand_chips}) + card_eval_status_text(effects[ii].card, 'chips', effects[ii].h_chips, percent) +end +''' \ No newline at end of file From 77bf5e24f3a221244f222ce301abd94c8e8bafef Mon Sep 17 00:00:00 2001 From: Keyslam Date: Wed, 18 Dec 2024 13:40:13 +0100 Subject: [PATCH 02/21] =?UTF-8?q?Correct=20mentions=20of=20L=C3=96VE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- example_mods/Mods/EditionExamples/README.md | 4 ++-- src/crash_handler.lua | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 983056e6..4d2aca80 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ## Introduction -Steamodded is a mod loader and injector for the game Balatro. Much like the [LÖVE2D engine](https://love2d.org/wiki/Main_Page) itself, it is built using [Lua](https://www.lua.org/). It is made with modularity and extensibility in mind, providing a large selection of APIs and other features to facilitate bringing your ideas to life. +Steamodded is a mod loader and injector for the game Balatro. Much like the [LÖVE framework](https://love2d.org/wiki/Main_Page) itself, it is built using [Lua](https://www.lua.org/). It is made with modularity and extensibility in mind, providing a large selection of APIs and other features to facilitate bringing your ideas to life. ## Installation diff --git a/example_mods/Mods/EditionExamples/README.md b/example_mods/Mods/EditionExamples/README.md index 66cde69d..818f5d28 100644 --- a/example_mods/Mods/EditionExamples/README.md +++ b/example_mods/Mods/EditionExamples/README.md @@ -21,7 +21,7 @@ Again, you'd have to write it yourself. ## Working with Shaders [ionized.fs](assets/shaders/ionized.fs) has shader code explanation with comments. -For a general guide, look at [LOVE2D introduction to shaders](https://blogs.love2d.org/content/beginners-guide-shaders). +For a general guide, look at [LÖVE introduction to shaders](https://blogs.love2d.org/content/beginners-guide-shaders). If you want to see vanilla Balatro shaders, unzip the Balatro.exe and go to `resources/shaders` folder. @@ -34,4 +34,4 @@ To see values for default externs, check out `engine/sprite.lua` -> `Sprite:draw - [Inigo Quilez articles](https://iquilezles.org/articles/) - in-depth articles on algorithms and techniques you could use in shaders. A lot of those are for 3D, but there's some 2D stuff as well. - [Shadertoy](https://www.shadertoy.com) - tons of shaders from other people to learn from. A lot of them are pretty complex and 3D, but you can find simple 2D ones. -Note: in all resources the language is slightly different from LOVE2D shaders language, but the logic works the same way. +Note: in all resources the language is slightly different from LÖVE shaders language, but the logic works the same way. diff --git a/src/crash_handler.lua b/src/crash_handler.lua index 4f7ee812..f43825ed 100644 --- a/src/crash_handler.lua +++ b/src/crash_handler.lua @@ -147,7 +147,7 @@ function loadStackTracePlus() end return ParseLine(line) elseif type(info.source) == "string" and info.source:sub(1, 6) == "=[love" then - return "(Love2D Function)" + return "(LÖVE Function)" else local line local lineNumber = 0 @@ -362,7 +362,7 @@ Stack Traceback end local source = table.remove(props, 1) if source == "love" then - dumper:add_f("(%d) main chunk of Love2D file '%s' at line %d\r\n", level_to_show, + dumper:add_f("(%d) main chunk of LÖVE file '%s' at line %d\r\n", level_to_show, table.concat(props, " "):sub(2, -2), info.currentline) elseif source == "SMODS" then local modID = table.remove(props, 1) @@ -427,7 +427,7 @@ Stack Traceback end local source = table.remove(props, 1) if source == "love" then - dumper:add_f("(%d) Love2D %s at file '%s:%d'%s\r\n", level_to_show, function_type, + dumper:add_f("(%d) LÖVE %s at file '%s:%d'%s\r\n", level_to_show, function_type, table.concat(props, " "):sub(2, -2), info.currentline, was_guessed and " (best guess)" or "") elseif source == "SMODS" then local modID = table.remove(props, 1) @@ -515,7 +515,7 @@ function getDebugInfoForCrash() local info = "Additional Context:\nBalatro Version: " .. version .. "\nModded Version: " .. (modded_version) local major, minor, revision, codename = love.getVersion() - info = info .. string.format("\nLove2D Version: %d.%d.%d", major, minor, revision) + info = info .. string.format("\nLÖVE Version: %d.%d.%d", major, minor, revision) local lovely_success, lovely = pcall(require, "lovely") if lovely_success then From 3c476220833de66e3b6ec0b697ec4fec39fa3c28 Mon Sep 17 00:00:00 2001 From: Casimir Eisenach Date: Wed, 18 Dec 2024 23:14:33 +0100 Subject: [PATCH 03/21] Fix line overlap in languages --- TODO | 9 +++++---- src/utils.lua | 2 +- version.lua | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/TODO b/TODO index 463d12ec..177b0c04 100644 --- a/TODO +++ b/TODO @@ -1,9 +1,8 @@ # Documentation ## To do -- Stake +- Sticker - Seal - Challenge -- Sticker - DeckSkin ## In progress @@ -12,14 +11,16 @@ ## Done - Atlas -- Center (Joker, Consumable, Voucher, Back) +- Center (Joker, Consumable, Voucher, Back, Booster) - Blind -- ConsumableType +- ObjectType - UndiscoveredSprite - Edition - Language - Sound +- Stake - PokerHand - Suit - Rank +- Rarity - Tag diff --git a/src/utils.lua b/src/utils.lua index 06daf821..c057c4cd 100644 --- a/src/utils.lua +++ b/src/utils.lua @@ -197,7 +197,7 @@ local function parse_loc_file(file_name, force) -- force mode is on and the value is not a table, -- change/add the thing -- brings back compatibility with language patching mods - if not ref_table[k] or (force and ((type(v) ~= 'table') or type(v[1]) == 'string')) then + if (not ref_table[k] and type(k) ~= 'number') or (force and ((type(v) ~= 'table') or type(v[1]) == 'string')) then ref_table[k] = v else recurse(v, ref_table[k]) diff --git a/version.lua b/version.lua index 43f0e085..05097a41 100644 --- a/version.lua +++ b/version.lua @@ -1 +1 @@ -return "1.0.0~ALPHA-1217c-STEAMODDED" +return "1.0.0~ALPHA-1218a-STEAMODDED" From b5bc14fc86168a22b2b1f8d7c34abb36237e82e2 Mon Sep 17 00:00:00 2001 From: Casimir Eisenach Date: Wed, 18 Dec 2024 23:55:46 +0100 Subject: [PATCH 04/21] Remove white title row from enhancements --- src/game_object.lua | 4 ++-- version.lua | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/game_object.lua b/src/game_object.lua index 3f10b3b2..1447b38e 100644 --- a/src/game_object.lua +++ b/src/game_object.lua @@ -1165,9 +1165,9 @@ Set `prefix_config.key = false` on your object instead.]]):format(obj.key), obj. target.scale = res.scale target.text_colour = res.text_colour end - if desc_nodes == full_UI_table.main and not full_UI_table.name then + if desc_nodes == full_UI_table.main and not full_UI_table.name and self.set ~= 'Enhanced' then full_UI_table.name = localize { type = 'name', set = target.set, key = target.key, nodes = full_UI_table.name } - elseif desc_nodes ~= full_UI_table.main and not desc_nodes.name then + elseif desc_nodes ~= full_UI_table.main and not desc_nodes.name and self.set ~= 'Enhanced' then desc_nodes.name = localize{type = 'name_text', key = target.key, set = target.set } end if specific_vars and specific_vars.debuffed and not res.replace_debuff then diff --git a/version.lua b/version.lua index 05097a41..7d77226e 100644 --- a/version.lua +++ b/version.lua @@ -1 +1 @@ -return "1.0.0~ALPHA-1218a-STEAMODDED" +return "1.0.0~ALPHA-1218b-STEAMODDED" From 2b346e384435181432e157de8b221414a4cb6d45 Mon Sep 17 00:00:00 2001 From: Casimir Eisenach Date: Thu, 19 Dec 2024 00:12:32 +0100 Subject: [PATCH 05/21] feat: suit/rank loc_vars for tooltips --- lovely/playing_card.toml | 23 +++++++++++++++++++++++ version.lua | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/lovely/playing_card.toml b/lovely/playing_card.toml index 655cbdb8..541a6dbc 100644 --- a/lovely/playing_card.toml +++ b/lovely/playing_card.toml @@ -274,3 +274,26 @@ end for j = 1, #suit_map do $mid (0.42 - (num_suits <= 4 and 0 or num_suits >= 8 and 0.28 or 0.07 * (num_suits - 4))) * G.CARD_H,''' + +[[patches]] +[patches.pattern] +target = 'functions/common_events.lua' +pattern = '--Fill all remaining info if this is the main desc' +position = 'before' +match_indent = true +payload = '''if card_type == 'Default' or card_type == 'Enhanced' and not _c.replace_base_card then + if not _c.no_suit then + local suit = SMODS.Suits[card.base.suit] or {} + if suit.loc_vars and type(suit.loc_vars) == 'function' then + suit:loc_vars(info_queue, card) + end + end + if not _c.no_rank then + local rank = SMODS.Ranks[card.base.value] or {} + if rank.loc_vars and type(rank.loc_vars) == 'function' then + rank:loc_vars(info_queue, card) + end + end +end + +''' diff --git a/version.lua b/version.lua index 7d77226e..7b487206 100644 --- a/version.lua +++ b/version.lua @@ -1 +1 @@ -return "1.0.0~ALPHA-1218b-STEAMODDED" +return "1.0.0~ALPHA-1218c-STEAMODDED" From ef301cc549f331bb66517c2552ee17d39a3d5d04 Mon Sep 17 00:00:00 2001 From: Casimir Eisenach Date: Thu, 19 Dec 2024 00:59:07 +0100 Subject: [PATCH 06/21] locked_loc_vars bugfix (oops) --- lovely/center.toml | 1 + version.lua | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lovely/center.toml b/lovely/center.toml index 9bb88cf8..6dbb207c 100644 --- a/lovely/center.toml +++ b/lovely/center.toml @@ -114,6 +114,7 @@ payload = ''' if _c.locked_loc_vars and type(_c.locked_loc_vars) == 'function' then local res = _c:locked_loc_vars(info_queue) or {} loc_vars = res.vars or {} + specific_vars = specific_vars or {} specific_vars.not_hidden = res.not_hidden or specific_vars.not_hidden elseif $rest''' diff --git a/version.lua b/version.lua index 7b487206..d2625c11 100644 --- a/version.lua +++ b/version.lua @@ -1 +1 @@ -return "1.0.0~ALPHA-1218c-STEAMODDED" +return "1.0.0~ALPHA-1219a-STEAMODDED" From 0bf99d1b700161b3e86be91a22bf53e71d8f6f27 Mon Sep 17 00:00:00 2001 From: Casimir Eisenach Date: Thu, 19 Dec 2024 11:20:42 +0100 Subject: [PATCH 07/21] Fix The Wheel's collection text, resolve a patch conflict with keybind for restarting --- lovely/blind.toml | 12 ++++++------ lovely/blind_ui.toml | 10 +++++++++- lovely/keybind.toml | 9 ++++----- src/game_object.lua | 9 +++++++-- version.lua | 2 +- 5 files changed, 27 insertions(+), 15 deletions(-) diff --git a/lovely/blind.toml b/lovely/blind.toml index 676bf024..9464dd24 100644 --- a/lovely/blind.toml +++ b/lovely/blind.toml @@ -186,14 +186,14 @@ end''' [[patches]] [patches.pattern] target = 'blind.lua' -pattern = 'return disp_text' -position = 'before' +pattern = 'function Blind:get_loc_debuff_text()' +position = 'after' match_indent = true payload = ''' -local obj = self.config.blind -if obj.get_loc_debuff_text and type(obj.get_loc_debuff_text) == 'function' then - return obj:get_loc_debuff_text() -end''' + local obj = self.config.blind + if obj.get_loc_debuff_text and type(obj.get_loc_debuff_text) == 'function' then + return obj:get_loc_debuff_text() + end''' # Blind:set_text() [[patches]] diff --git a/lovely/blind_ui.toml b/lovely/blind_ui.toml index d01bf724..a5dac7a4 100644 --- a/lovely/blind_ui.toml +++ b/lovely/blind_ui.toml @@ -139,4 +139,12 @@ pattern = ''' [\t ]*G\.GAME\.blind:juice_up\(\)''' position = 'at' payload = 'SMODS.juice_up_blind()' -line_prepend = '$indent' \ No newline at end of file +line_prepend = '$indent' + +# remove statically added 1 from The Wheel's collection description +[[patches]] +[patches.regex] +target = 'functions/UI_definitions.lua' +pattern = '''\(k ==1 and blind\.name == 'The Wheel' and '1' or ''\)\.\.''' +position = 'at' +payload = '' \ No newline at end of file diff --git a/lovely/keybind.toml b/lovely/keybind.toml index 83bd3ce7..6001bb64 100644 --- a/lovely/keybind.toml +++ b/lovely/keybind.toml @@ -31,11 +31,11 @@ match_indent = true overwrite = false [[patches]] -[patches.pattern] +[patches.regex] target = 'engine/controller.lua' -pattern = 'if key == "r" and not G.SETTINGS.paused then' +pattern = 'if key == "r"' position = 'at' -match_indent = true +line_prepend = '$indent' payload = ''' if key == 'm' then if self.held_key_times[key] > 1.1 then @@ -44,5 +44,4 @@ if key == 'm' then else self.held_key_times[key] = self.held_key_times[key] + dt end -elseif key == "r" and not G.SETTINGS.paused then -''' \ No newline at end of file +elseif key == "r"''' \ No newline at end of file diff --git a/src/game_object.lua b/src/game_object.lua index 1447b38e..07b10462 100644 --- a/src/game_object.lua +++ b/src/game_object.lua @@ -1707,9 +1707,14 @@ Set `prefix_config.key = false` on your object instead.]]):format(obj.key), obj. loc_vars = function(self) return { vars = { G.GAME.probabilities.normal } } end, + collection_loc_vars = function(self) + return { vars = { '1' }} + end, process_loc_text = function(self) - G.localization.descriptions.Blind['bl_wheel'].text[1] = - "#1#"..G.localization.descriptions.Blind['bl_wheel'].text[1] + local text = G.localization.descriptions.Blind[self.key].text[1] + if string.sub(text, 1, 3) ~= '#1#' then + G.localization.descriptions.Blind[self.key].text[1] = "#1#"..text + end SMODS.Blind.process_loc_text(self) end, get_loc_debuff_text = function() return G.GAME.blind.loc_debuff_text end, diff --git a/version.lua b/version.lua index d2625c11..e9117f12 100644 --- a/version.lua +++ b/version.lua @@ -1 +1 @@ -return "1.0.0~ALPHA-1219a-STEAMODDED" +return "1.0.0~ALPHA-1219b-STEAMODDED" From 47691b49692acae540747e00738ca0c71eef08b0 Mon Sep 17 00:00:00 2001 From: Casimir Eisenach Date: Thu, 19 Dec 2024 14:00:51 +0100 Subject: [PATCH 08/21] Util function for card pools, no_collection --- lovely/ui.toml | 123 +++----------------------------------------- src/game_object.lua | 17 +++--- src/overrides.lua | 92 ++++----------------------------- src/ui.lua | 25 +-------- src/utils.lua | 14 +++++ version.lua | 2 +- 6 files changed, 43 insertions(+), 230 deletions(-) diff --git a/lovely/ui.toml b/lovely/ui.toml index cce08235..8c0c527b 100644 --- a/lovely/ui.toml +++ b/lovely/ui.toml @@ -13,14 +13,7 @@ target = "functions/UI_definitions.lua" pattern = '''local joker_options = {}''' position = "before" payload = ''' -local joker_pool = {} -if G.ACTIVE_MOD_UI then - for _, v in ipairs(G.P_CENTER_POOLS.Joker) do - if v.mod and G.ACTIVE_MOD_UI.id == v.mod.id then joker_pool[#joker_pool+1] = v end - end -else - joker_pool = G.P_CENTER_POOLS.Joker -end''' +local joker_pool = SMODS.collection_pool(G.P_CENTER_POOLS.Joker)''' match_indent = true # create_UIBox_your_collection_jokers() @@ -61,14 +54,7 @@ target = "functions/button_callbacks.lua" pattern = '''for i = 1, 5 do''' position = "before" payload = ''' -local joker_pool = {} -if G.ACTIVE_MOD_UI then - for _, v in ipairs(G.P_CENTER_POOLS.Joker) do - if v.mod and G.ACTIVE_MOD_UI.id == v.mod.id then joker_pool[#joker_pool+1] = v end - end -else - joker_pool = G.P_CENTER_POOLS.Joker -end +local joker_pool = SMODS.collection_pool(G.P_CENTER_POOLS.Joker) ''' match_indent = true @@ -89,15 +75,7 @@ target = "functions/UI_definitions.lua" pattern = '''G.GAME.viewed_back = Back(G.P_CENTERS.b_red)''' position = "at" payload = ''' -local deck_pool = {} -if G.ACTIVE_MOD_UI then - for _, v in ipairs(G.P_CENTER_POOLS.Back) do - if v.mod and G.ACTIVE_MOD_UI.id == v.mod.id then deck_pool[#deck_pool+1] = v end - end -else - deck_pool = G.P_CENTER_POOLS.Back -end - +local deck_pool = SMODS.collection_pool(G.P_CENTER_POOLS.Back) G.GAME.viewed_back = Back(G.ACTIVE_MOD_UI and deck_pool[1] or G.P_CENTERS.b_red)''' match_indent = true @@ -130,14 +108,7 @@ target = "functions/button_callbacks.lua" pattern = '''G.GAME.viewed_back:change_to(G.P_CENTER_POOLS.Back[args.to_key])''' position = "at" payload = ''' -local deck_pool = {} -if G.ACTIVE_MOD_UI then - for _, v in ipairs(G.P_CENTER_POOLS.Back) do - if v.mod and G.ACTIVE_MOD_UI.id == v.mod.id then deck_pool[#deck_pool+1] = v end - end -else - deck_pool = G.P_CENTER_POOLS.Back -end +local deck_pool = SMODS.collection_pool(G.P_CENTER_POOLS.Back) G.GAME.viewed_back:change_to(deck_pool[args.to_key])''' match_indent = true @@ -149,14 +120,7 @@ target = "functions/UI_definitions.lua" pattern = '''local booster_options = {}''' position = "before" payload = ''' -local booster_pool = {} -if G.ACTIVE_MOD_UI then - for _, v in ipairs(G.P_CENTER_POOLS.Booster) do - if v.mod and G.ACTIVE_MOD_UI.id == v.mod.id then booster_pool[#booster_pool+1] = v end - end -else - booster_pool = G.P_CENTER_POOLS.Booster -end''' +local booster_pool = SMODS.collection_pool(G.P_CENTER_POOLS.Booster)''' match_indent = true # create_UIBox_your_collection_boosters() @@ -188,14 +152,7 @@ target = "functions/button_callbacks.lua" pattern = '''G.FUNCS.your_collection_booster_page = function(args)''' position = "after" payload = ''' -local booster_pool = {} -if G.ACTIVE_MOD_UI then - for k, v in pairs(G.P_CENTER_POOLS.Booster) do - if v.mod and G.ACTIVE_MOD_UI.id == v.mod.id then booster_pool[#booster_pool+1] = v end - end -else - booster_pool = G.P_CENTER_POOLS.Booster -end''' +local booster_pool = SMODS.collection_pool(G.P_CENTER_POOLS.Booster)''' match_indent = true # G.FUNCS.your_collection_booster_page @@ -215,14 +172,7 @@ target = "functions/UI_definitions.lua" pattern = '''local voucher_options = {}''' position = "before" payload = ''' -local voucher_pool = {} -if G.ACTIVE_MOD_UI then - for _, v in ipairs(G.P_CENTER_POOLS.Voucher) do - if v.mod and G.ACTIVE_MOD_UI.id == v.mod.id then voucher_pool[#voucher_pool+1] = v end - end -else - voucher_pool = G.P_CENTER_POOLS.Voucher -end''' +local voucher_pool = SMODS.collection_pool(G.P_CENTER_POOLS.Voucher)''' match_indent = true # create_UIBox_your_collection_vouchers() @@ -264,14 +214,7 @@ target = "functions/button_callbacks.lua" pattern = '''G.FUNCS.your_collection_voucher_page = function(args)''' position = "after" payload = ''' -local voucher_pool = {} -if G.ACTIVE_MOD_UI then - for _, v in ipairs(G.P_CENTER_POOLS.Voucher) do - if v.mod and G.ACTIVE_MOD_UI.id == v.mod.id then voucher_pool[#voucher_pool+1] = v end - end -else - voucher_pool = G.P_CENTER_POOLS.Voucher -end''' +local voucher_pool = SMODS.collection_pool(G.P_CENTER_POOLS.Voucher)''' match_indent = true # G.FUNCS.your_collection_voucher_page @@ -283,56 +226,6 @@ position = "at" payload = '''local center = voucher_pool[i+(j-1)*4 + (8*(args.cycle_config.current_option - 1))]''' match_indent = true -## Blinds Tab -# create_UIBox_your_collection_blinds() -[[patches]] -[patches.regex] -target = 'functions/UI_definitions.lua' -pattern = '''(?[\t ]*)local blind_matrix = \{(\n.*){6}''' -position = 'at' -payload = ''' -local blind_matrix = { -{},{},{}, {}, {}, {} -} -local blind_tab = {} -if G.ACTIVE_MOD_UI then - for _, v in pairs(G.P_BLINDS) do - if v.mod and G.ACTIVE_MOD_UI.id == v.mod.id then blind_tab[#blind_tab+1] = v end - end -else - for k, v in pairs(G.P_BLINDS) do - blind_tab[#blind_tab+1] = v - end -end''' -line_prepend = '$indent' - -## Seal Tab -# create_UIBox_your_collection_seals() -[[patches]] -[patches.pattern] -target = "functions/UI_definitions.lua" -pattern = '''for k, v in ipairs(G.P_CENTER_POOLS['Seal']) do''' -position = "at" -payload = ''' -local seal_pool = {} -if G.ACTIVE_MOD_UI then - for _, v in pairs(G.P_CENTER_POOLS.Seal) do - if v.mod and G.ACTIVE_MOD_UI.id == v.mod.id then seal_pool[#seal_pool+1] = v end - end -else - seal_pool = G.P_CENTER_POOLS.Seal -end -for k, v in ipairs(seal_pool) do''' -match_indent = true - -[[patches]] -[patches.pattern] -target = "functions/UI_definitions.lua" -pattern = '''local t = create_UIBox_generic_options({ infotip = localize('ml_edition_seal_enhancement_explanation'), back_func = exit or 'your_collection', snap_back = true, contents = {''' -position = "at" -payload = '''local t = create_UIBox_generic_options({ infotip = localize('ml_edition_seal_enhancement_explanation'), back_func = G.ACTIVE_MOD_UI and "openModUI_"..G.ACTIVE_MOD_UI.id or exit or 'your_collection', snap_back = true, contents = {''' -match_indent = true - # create_UIBox_your_collection() [[patches]] [patches.regex] diff --git a/src/game_object.lua b/src/game_object.lua index 07b10462..3fe86d8e 100644 --- a/src/game_object.lua +++ b/src/game_object.lua @@ -931,14 +931,7 @@ Set `prefix_config.key = false` on your object instead.]]):format(obj.key), obj. ) end - local consumable_pool = {} - if G.ACTIVE_MOD_UI then - for _, v in ipairs(G.P_CENTER_POOLS[self.key]) do - if v.mod and G.ACTIVE_MOD_UI.id == v.mod.id then consumable_pool[#consumable_pool+1] = v end - end - else - consumable_pool = G.P_CENTER_POOLS[self.key] - end + local consumable_pool = SMODS.collection_pool(G.P_CENTER_POOLS[self.key]) local sum = 0 for j = 1, #G.your_collection do @@ -2666,6 +2659,14 @@ Set `prefix_config.key = false` on your object instead.]]):format(obj.key), obj. SMODS.process_loc_text(G.localization.descriptions.Other, self.key, self.loc_txt) SMODS.process_loc_text(G.localization.misc.labels, self.key, self.loc_txt, 'label') end, + register = function(self) + if self.registered then + sendWarnMessage(('Detected duplicate register call on object %s'):format(self.key), self.set) + return + end + SMODS.Sticker.super.register(self) + self.order = #self.obj_buffer + end, inject = function(self) self.sticker_sprite = Sprite(0, 0, G.CARD_W, G.CARD_H, G.ASSET_ATLAS[self.atlas], self.pos) G.shared_stickers[self.key] = self.sticker_sprite diff --git a/src/overrides.lua b/src/overrides.lua index 98930d6e..a7ab755d 100644 --- a/src/overrides.lua +++ b/src/overrides.lua @@ -103,18 +103,9 @@ function create_UIBox_your_collection_blinds(exit) ) end - local blind_tab = {} - for k, v in pairs(G.P_BLINDS) do - if not G.ACTIVE_MOD_UI or v.mod == G.ACTIVE_MOD_UI then - blind_tab[#blind_tab + 1] = v - end - end + local blind_tab = SMODS.collection_pool(G.P_BLINDS) local blinds_amt = #blind_tab - table.sort(blind_tab, function(a, b) - return a.order < b.order - end) - local this_page = {} for i, v in ipairs(blind_tab) do if i > rows*cols*(page-1) and i <= rows*cols*page then @@ -297,16 +288,7 @@ function G.FUNCS.your_collection_blinds_page(args) local cols = 5 local rows = 6 local page = args.cycle_config.current_option - local blind_tab = {} - for k, v in pairs(G.P_BLINDS) do - if not G.ACTIVE_MOD_UI or v.mod == G.ACTIVE_MOD_UI then - blind_tab[#blind_tab + 1] = v - end - end - - table.sort(blind_tab, function(a, b) - return a.order < b.order - end) + local blind_tab = SMODS.collection_pool(G.P_BLINDS) local this_page = {} for i, v in ipairs(blind_tab) do @@ -413,24 +395,11 @@ function create_UIBox_your_collection_tags_content(page) local tag_matrix = {} local rows = 4 local cols = 6 - local tag_tab = {} - local tag_pool = {} - if G.ACTIVE_MOD_UI then - for k, v in pairs(G.P_TAGS) do - if v.mod and G.ACTIVE_MOD_UI.id == v.mod.id then tag_pool[k] = v end - end - else - tag_pool = G.P_TAGS - end - for k, v in pairs(tag_pool) do - tag_tab[#tag_tab + 1] = v - end + local tag_tab = SMODS.collection_pool(G.P_TAGS) for i = 1, math.ceil(rows) do table.insert(tag_matrix, {}) end - table.sort(tag_tab, function(a, b) return a.order < b.order end) - local tags_to_be_alerted = {} local row, col = 1, 1 for k, v in ipairs(tag_tab) do @@ -1217,14 +1186,7 @@ end --#region editions function create_UIBox_your_collection_editions(exit) local deck_tables = {} - local edition_pool = {} - if G.ACTIVE_MOD_UI then - for _, v in pairs(G.P_CENTER_POOLS.Edition) do - if v.mod and G.ACTIVE_MOD_UI.id == v.mod.id then edition_pool[#edition_pool+1] = v end - end - else - edition_pool = G.P_CENTER_POOLS.Edition - end + local edition_pool = SMODS.collection_pool(G.P_CENTER_POOLS.Edition) local rows, cols = (#edition_pool > 5 and 2 or 1), 5 local page = 0 @@ -1312,14 +1274,7 @@ G.FUNCS.your_collection_editions_page = function(args) if not args or not args.cycle_config then return end - local edition_pool = {} - if G.ACTIVE_MOD_UI then - for _, v in ipairs(G.P_CENTER_POOLS.Edition) do - if v.mod and G.ACTIVE_MOD_UI.id == v.mod.id then edition_pool[#edition_pool+1] = v end - end - else - edition_pool = G.P_CENTER_POOLS.Edition - end + local edition_pool = SMODS.collection_pool(G.P_CENTER_POOLS.Edition) local rows = (#edition_pool > 5 and 2 or 1) local cols = 5 local page = args.cycle_config.current_option @@ -1638,15 +1593,7 @@ function create_UIBox_your_collection_enhancements(exit) local deck_tables = {} local rows, cols = 2, 4 local page = 0 - local enhancement_pool = {} - if G.ACTIVE_MOD_UI then - for _, v in ipairs(G.P_CENTER_POOLS.Enhanced) do - if v.mod and G.ACTIVE_MOD_UI.id == v.mod.id then enhancement_pool[#enhancement_pool+1] = v end - end - else - enhancement_pool = G.P_CENTER_POOLS.Enhanced - end - + local enhancement_pool = SMODS.collection_pool(G.P_CENTER_POOLS.Enhanced) G.your_collection = {} for j = 1, rows do G.your_collection[j] = CardArea(G.ROOM.T.x + 0.2 * G.ROOM.T.w / 2, G.ROOM.T.h, 4.25 * G.CARD_W, 1.03 * G.CARD_H, @@ -1733,14 +1680,7 @@ G.FUNCS.your_collection_enhancements_page = function(args) local rows = 2 local cols = 4 local page = args.cycle_config.current_option - local enhancement_pool = {} - if G.ACTIVE_MOD_UI then - for _, v in ipairs(G.P_CENTER_POOLS.Enhanced) do - if v.mod and G.ACTIVE_MOD_UI.id == v.mod.id then enhancement_pool[#enhancement_pool+1] = v end - end - else - enhancement_pool = G.P_CENTER_POOLS.Enhanced - end + local enhancement_pool = SMODS.collection_pool(G.P_CENTER_POOLS.Enhanced) if page > math.ceil(#enhancement_pool / (rows * cols)) then page = page - math.ceil(#enhancement_pool / (rows * cols)) end @@ -1778,14 +1718,7 @@ end --#region seals ui function create_UIBox_your_collection_seals(exit) local deck_tables = {} - local seal_pool = {} - if G.ACTIVE_MOD_UI then - for _, v in pairs(G.P_CENTER_POOLS.Seal) do - if v.mod and G.ACTIVE_MOD_UI.id == v.mod.id then seal_pool[#seal_pool + 1] = v end - end - else - seal_pool = G.P_CENTER_POOLS.Seal - end + local seal_pool = SMODS.collection_pool(G.P_CENTER_POOLS.Seal) local rows, cols = (#seal_pool > 5 and 2 or 1), 5 local page = 0 @@ -1872,14 +1805,7 @@ G.FUNCS.your_collection_seals_page = function(args) if not args or not args.cycle_config then return end - local seal_pool = {} - if G.ACTIVE_MOD_UI then - for _, v in pairs(G.P_CENTER_POOLS.Seal) do - if v.mod and G.ACTIVE_MOD_UI.id == v.mod.id then seal_pool[#seal_pool + 1] = v end - end - else - seal_pool = G.P_CENTER_POOLS.Seal - end + local seal_pool = SMODS.collection_pool(G.P_CENTER_POOLS.Seal) local rows, cols = (#seal_pool > 5 and 2 or 1), 5 local page = args.cycle_config.current_option if page > math.ceil(#seal_pool / (rows * cols)) then diff --git a/src/ui.lua b/src/ui.lua index f61c4054..8fc6d820 100644 --- a/src/ui.lua +++ b/src/ui.lua @@ -548,20 +548,10 @@ end function create_UIBox_your_collection_stickers(exit) local deck_tables = {} - local sticker_pool = {} - if G.ACTIVE_MOD_UI then - for _, v in pairs(SMODS.Stickers) do - if v.mod and G.ACTIVE_MOD_UI.id == v.mod.id then sticker_pool[#sticker_pool+1] = v end - end - else - for _, v in pairs(SMODS.Stickers) do - sticker_pool[#sticker_pool+1] = v - end - end + local sticker_pool = SMODS.collection_pool(SMODS.Stickers) local rows, cols = (#sticker_pool > 5 and 2 or 1), 5 local page = 0 - sendInfoMessage("Creating collections", "CollectionUI") G.your_collection = {} for j = 1, rows do G.your_collection[j] = CardArea(G.ROOM.T.x + 0.2 * G.ROOM.T.w / 2, G.ROOM.T.h, 5.3 * G.CARD_W, 1.03 * G.CARD_H, @@ -577,8 +567,6 @@ function create_UIBox_your_collection_stickers(exit) ) end - table.sort(sticker_pool, function(a, b) return (a.order or 100) < (b.order or 100) end) - local count = math.min(cols * rows, #sticker_pool) local index = 1 + (rows * cols * page) for j = 1, rows do @@ -644,16 +632,7 @@ G.FUNCS.your_collection_stickers_page = function(args) if not args or not args.cycle_config then return end - local sticker_pool = {} - if G.ACTIVE_MOD_UI then - for _, v in pairs(SMODS.Stickers) do - if v.mod and G.ACTIVE_MOD_UI.id == v.mod.id then sticker_pool[#sticker_pool+1] = v end - end - else - for _, v in pairs(SMODS.Stickers) do - sticker_pool[#sticker_pool+1] = v - end - end + local sticker_pool = SMODS.collection_pool(SMODS.Stickers) local rows = (#sticker_pool > 5 and 2 or 1) local cols = 5 local page = args.cycle_config.current_option diff --git a/src/utils.lua b/src/utils.lua index c057c4cd..5b9ead48 100644 --- a/src/utils.lua +++ b/src/utils.lua @@ -797,3 +797,17 @@ function time(func, ...) local end_time = love.timer.getTime() return 1000*(end_time-start_time) end + +SMODS.collection_pool = function(_base_pool) + local pool = {} + if type(_base_pool) ~= 'table' then return pool end + local is_array = _base_pool[1] + local ipairs = is_array and ipairs or pairs + for _, v in ipairs(_base_pool) do + if (not G.ACTIVE_MOD_UI or v.mod == G.ACTIVE_MOD_UI) and not v.no_collection then + pool[#pool+1] = v + end + end + if not is_array then table.sort(pool, function(a,b) return a.order < b.order end) end + return pool +end \ No newline at end of file diff --git a/version.lua b/version.lua index e9117f12..a7641834 100644 --- a/version.lua +++ b/version.lua @@ -1 +1 @@ -return "1.0.0~ALPHA-1219b-STEAMODDED" +return "1.0.0~ALPHA-1219c-STEAMODDED" From 514c835fbe470b5dbeccbe9e0a8e87dc83bb1e5e Mon Sep 17 00:00:00 2001 From: Casimir Eisenach Date: Thu, 19 Dec 2024 16:48:14 +0100 Subject: [PATCH 09/21] Consistency: Seal.get_p_dollars args --- TODO | 4 +++- lovely/seal.toml | 2 +- version.lua | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/TODO b/TODO index 177b0c04..dc6b0e45 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,6 @@ # Documentation ## To do -- Sticker + - Seal - Challenge - DeckSkin @@ -10,6 +10,7 @@ ## Done +- Achievement - Atlas - Center (Joker, Consumable, Voucher, Back, Booster) - Blind @@ -22,5 +23,6 @@ - PokerHand - Suit - Rank +- Sticker - Rarity - Tag diff --git a/lovely/seal.toml b/lovely/seal.toml index f0ea85f1..ad922d3f 100644 --- a/lovely/seal.toml +++ b/lovely/seal.toml @@ -138,7 +138,7 @@ line_prepend = '$indent' payload = ''' local obj = G.P_SEALS[self.seal] or {} if obj.get_p_dollars and type(obj.get_p_dollars) == 'function' then - ret = ret + obj.get_p_dollars(self) + ret = ret + obj:get_p_dollars(self) elseif $cond''' # generate_card_ui() diff --git a/version.lua b/version.lua index a7641834..67a50694 100644 --- a/version.lua +++ b/version.lua @@ -1 +1 @@ -return "1.0.0~ALPHA-1219c-STEAMODDED" +return "1.0.0~ALPHA-1219d-STEAMODDED" From 9a65e81da7faa6d4f3e718b2915f5f77944a2727 Mon Sep 17 00:00:00 2001 From: Casimir Eisenach Date: Thu, 19 Dec 2024 17:25:16 +0100 Subject: [PATCH 10/21] card.draw funcs for applicable objects --- lovely/center.toml | 41 +++++++++++++++++++++++++++++++++++++++++ lovely/edition.toml | 10 +++++++--- version.lua | 2 +- 3 files changed, 49 insertions(+), 4 deletions(-) diff --git a/lovely/center.toml b/lovely/center.toml index 6dbb207c..5c1eca8e 100644 --- a/lovely/center.toml +++ b/lovely/center.toml @@ -444,3 +444,44 @@ local obj = self.config.center if obj.calc_dollar_bonus and type(obj.calc_dollar_bonus) == 'function' then return obj:calc_dollar_bonus(self) end''' + +# Card:draw() +[[patches]] +[patches.pattern] +target = 'card.lua' +pattern = '--If the card has any edition/seal, add that here' +position = 'before' +match_indent = true +payload = ''' +local center = self.config.center +if center.draw and type(center.draw) == 'function' then + center:draw(self, layer) +end +if center.set == 'Default' or center.set == 'Enhanced' and not center.replace_base_card then + if not center.no_suit then + local suit = SMODS.Suits[self.base.suit] or {} + if suit.draw and type(suit.draw) == 'function' then + suit:draw(self, layer) + end + end + if not center.no_rank then + local rank = SMODS.Ranks[self.base.value] or {} + if rank.draw and type(rank.draw) == 'function' then + rank:draw(self, layer) + end + end +end +''' + +[[patches]] +[patches.pattern] +target = 'card.lua' +pattern = 'if self.seal then' +position = 'at' +match_indent = true +payload = ''' +local seal = G.P_SEALS[self.seal or {}] or {} +if type(seal.draw) == 'function' then + seal:draw(self, layer) +elseif self.seal then +''' \ No newline at end of file diff --git a/lovely/edition.toml b/lovely/edition.toml index 9f86d5ce..9ef00814 100644 --- a/lovely/edition.toml +++ b/lovely/edition.toml @@ -155,9 +155,13 @@ payload = ''' if self.edition then for k, v in pairs(G.P_CENTER_POOLS.Edition) do if self.edition[v.key:sub(3)] and v.shader then - self.children.center:draw_shader(v.shader, nil, self.ARGS.send_to_shader) - if self.children.front and self.ability.effect ~= 'Stone Card' and not self.config.center.replace_base_card then - self.children.front:draw_shader(v.shader, nil, self.ARGS.send_to_shader) + if type(v.draw) == 'function' then + v:draw(self, layer) + else + self.children.center:draw_shader(v.shader, nil, self.ARGS.send_to_shader) + if self.children.front and self.ability.effect ~= 'Stone Card' and not self.config.center.replace_base_card then + self.children.front:draw_shader(v.shader, nil, self.ARGS.send_to_shader) + end end end end diff --git a/version.lua b/version.lua index 67a50694..219ec6d2 100644 --- a/version.lua +++ b/version.lua @@ -1 +1 @@ -return "1.0.0~ALPHA-1219d-STEAMODDED" +return "1.0.0~ALPHA-1219e-STEAMODDED" From 4a38bb020fcce9592f21e3788f2bec30c63cd62c Mon Sep 17 00:00:00 2001 From: Casimir Eisenach Date: Thu, 19 Dec 2024 17:27:49 +0100 Subject: [PATCH 11/21] add missing layer arg --- lovely/sticker.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lovely/sticker.toml b/lovely/sticker.toml index ed04e3c4..d077e471 100644 --- a/lovely/sticker.toml +++ b/lovely/sticker.toml @@ -98,7 +98,7 @@ payload = ''' for k, v in pairs(SMODS.Stickers) do if self.ability[v.key] then if v and v.draw and type(v.draw) == 'function' then - v:draw(self) + v:draw(self, layer) else G.shared_stickers[v.key].role.draw_major = self G.shared_stickers[v.key]:draw_shader('dissolve', nil, nil, nil, self.children.center) From 2f633bf036784e79ba096c9bbd001d1038220ad8 Mon Sep 17 00:00:00 2001 From: Casimir Eisenach Date: Fri, 20 Dec 2024 13:51:38 +0100 Subject: [PATCH 12/21] Fix crash with enhancement tooltips on deck select --- TODO | 3 ++- lovely/playing_card.toml | 2 +- version.lua | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/TODO b/TODO index dc6b0e45..455b484e 100644 --- a/TODO +++ b/TODO @@ -1,7 +1,7 @@ # Documentation ## To do -- Seal + - Challenge - DeckSkin @@ -23,6 +23,7 @@ - PokerHand - Suit - Rank +- Seal - Sticker - Rarity - Tag diff --git a/lovely/playing_card.toml b/lovely/playing_card.toml index 541a6dbc..bd43d277 100644 --- a/lovely/playing_card.toml +++ b/lovely/playing_card.toml @@ -281,7 +281,7 @@ target = 'functions/common_events.lua' pattern = '--Fill all remaining info if this is the main desc' position = 'before' match_indent = true -payload = '''if card_type == 'Default' or card_type == 'Enhanced' and not _c.replace_base_card then +payload = '''if card_type == 'Default' or card_type == 'Enhanced' and not _c.replace_base_card and card and card.base then if not _c.no_suit then local suit = SMODS.Suits[card.base.suit] or {} if suit.loc_vars and type(suit.loc_vars) == 'function' then diff --git a/version.lua b/version.lua index 219ec6d2..7d05e2fc 100644 --- a/version.lua +++ b/version.lua @@ -1 +1 @@ -return "1.0.0~ALPHA-1219e-STEAMODDED" +return "1.0.0~ALPHA-1220a-STEAMODDED" From 3b4edab356fd065f99393cf48fc0c325e25de988 Mon Sep 17 00:00:00 2001 From: Casimir Eisenach Date: Sat, 21 Dec 2024 21:25:37 +0100 Subject: [PATCH 13/21] no_collection bugfixes (collection count, alerts) --- lovely/ui.toml | 33 ++++++++++++++++++++++++++++++++- src/ui.lua | 2 +- version.lua | 2 +- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/lovely/ui.toml b/lovely/ui.toml index 8c0c527b..00eaddd0 100644 --- a/lovely/ui.toml +++ b/lovely/ui.toml @@ -356,4 +356,35 @@ payload = 'not part.control.C and args.text_colour or loc_colour(part.control.C target = 'functions/misc_functions.lua' position = 'after' pattern = 'part\.control\.s and tonumber\(part\.control\.s\)' -payload = ' or args.scale ' \ No newline at end of file +payload = ' or args.scale ' + +# set_discover_tallies() +# exclude no_collection objects +[[patches]] +[patches.pattern] +target = 'functions/misc_functions.lua' +match_indent = true +position = 'at' +pattern = "if not v.omit then" +payload = "if not v.omit and not v.no_collection then" + +[[patches]] +[patches.regex] +target = 'functions/misc_functions.lua' +line_prepend = '$indent' +position = 'at' +pattern = '(?[\t ]*)(?for _, v in pairs\(G\.P_[BT].*)(?(\n.*){7})' +payload = '''$start + if not v.no_collection then + $rest +end +''' + +#set_alerts() +[[patches]] +[patches.pattern] +target = 'functions/common_events.lua' +match_indent = true +position = 'at' +pattern = "if v.discovered and not v.alerted then" +payload = "if v.discovered and not v.alerted and not v.no_collection then" \ No newline at end of file diff --git a/src/ui.lua b/src/ui.lua index 8fc6d820..11c7ff24 100644 --- a/src/ui.lua +++ b/src/ui.lua @@ -843,7 +843,7 @@ function modsCollectionTally(pool, set) local obj_tally = {tally = 0, of = 0} for _, v in pairs(pool) do - if v.mod and G.ACTIVE_MOD_UI.id == v.mod.id then + if v.mod and G.ACTIVE_MOD_UI.id == v.mod.id and not v.no_collection then if set then if v.set and v.set == set then obj_tally.of = obj_tally.of+1 diff --git a/version.lua b/version.lua index 7d05e2fc..83af37bb 100644 --- a/version.lua +++ b/version.lua @@ -1 +1 @@ -return "1.0.0~ALPHA-1220a-STEAMODDED" +return "1.0.0~ALPHA-1221a-STEAMODDED" From 524c6c26e7c56649981e4b97330f0754c4419f3c Mon Sep 17 00:00:00 2001 From: Casimir Eisenach Date: Sat, 21 Dec 2024 22:28:15 +0100 Subject: [PATCH 14/21] loc_key arg for languages --- lovely/language.toml | 19 +++++++++++++++++++ src/game_object.lua | 2 +- version.lua | 2 +- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/lovely/language.toml b/lovely/language.toml index 2d218d1d..c8e3a616 100644 --- a/lovely/language.toml +++ b/lovely/language.toml @@ -30,6 +30,25 @@ position = 'at' payload = "self.localization = assert(loadstring(love.filesystem.read('localization/'..G.SETTINGS.language..'.lua') or love.filesystem.read('localization/en-us.lua')))()" match_indent = true +[[patches]] +[patches.pattern] +target = 'game.lua' +pattern = "self.LANG = self.LANGUAGES[self.SETTINGS.language] or self.LANGUAGES['en-us']" +position = 'at' +payload = "self.LANG = self.LANGUAGES[self.SETTINGS.real_language or self.SETTINGS.language] or self.LANGUAGES['en-us']" +match_indent = true + +# G.FUNCS.change_lang + +[[patches]] +[patches.pattern] +target = 'functions/button_callbacks.lua' +pattern = "G.SETTINGS.language = lang.key" +position = 'at' +payload = """G.SETTINGS.language = lang.loc_key or lang.key +G.SETTINGS.real_language = lang.key""" +match_indent = true + # G.FUNCS.warn_lang (wtf) [[patches]] [patches.pattern] diff --git a/src/game_object.lua b/src/game_object.lua index 3fe86d8e..6d4d43ca 100644 --- a/src/game_object.lua +++ b/src/game_object.lua @@ -292,7 +292,7 @@ Set `prefix_config.key = false` on your object instead.]]):format(obj.key), obj. self.font = G.FONTS[type(self.font) == 'number' and self.font or 1] or G.FONTS[1] end G.LANGUAGES[self.key] = self - if self.key == G.SETTINGS.language then G.LANG = self end + if self.key == (G.SETTINGS.real_language or G.SETTINGS.language) then G.LANG = self end end, } diff --git a/version.lua b/version.lua index 83af37bb..8a745157 100644 --- a/version.lua +++ b/version.lua @@ -1 +1 @@ -return "1.0.0~ALPHA-1221a-STEAMODDED" +return "1.0.0~ALPHA-1221b-STEAMODDED" From 755c918b591e590734b5cf21cb288df1280118db Mon Sep 17 00:00:00 2001 From: Casimir Eisenach Date: Sat, 21 Dec 2024 22:48:29 +0100 Subject: [PATCH 15/21] real_language full functionality --- src/game_object.lua | 19 +++++++++---------- src/utils.lua | 3 ++- version.lua | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/game_object.lua b/src/game_object.lua index 6d4d43ca..b223d779 100644 --- a/src/game_object.lua +++ b/src/game_object.lua @@ -349,11 +349,11 @@ Set `prefix_config.key = false` on your object instead.]]):format(obj.key), obj. end, inject = function(self) local file_path = type(self.path) == 'table' and - (self.path[G.SETTINGS.language] or self.path['default'] or self.path['en-us']) or self.path + ((G.SETTINGS.real_language and self.path[G.SETTINGS.real_language]) or self.path[G.SETTINGS.language] or self.path['default'] or self.path['en-us']) or self.path if file_path == 'DEFAULT' then return end -- language specific sprites override fully defined sprites only if that language is set - if self.language and not (G.SETTINGS.language == self.language) then return end - if not self.language and self.obj_table[('%s_%s'):format(self.key, G.SETTINGS.language)] then return end + if self.language and G.SETTINGS.language ~= self.language and G.SETTINGS.real_language ~= self.language then return end + if not self.language and (self.obj_table[('%s_%s'):format(self.key, G.SETTINGS.language)] or self.obj_table[('%s_%s'):format(self.key, G.SETTINGS.real_language)]) then return end self.full_path = (self.mod and self.mod.path or SMODS.path) .. 'assets/' .. G.SETTINGS.GRAPHICS.texture_scaling .. 'x/' .. file_path local file_data = assert(NFS.newFileData(self.full_path), @@ -425,7 +425,7 @@ Set `prefix_config.key = false` on your object instead.]]):format(obj.key), obj. end, inject = function(self) local file_path = type(self.path) == 'table' and - (self.path[G.SETTINGS.language] or self.path['default'] or self.path['en-us']) or self.path + ((G.SETTINGS.real_language and self.path[G.SETTINGS.real_language]) or self.path[G.SETTINGS.language] or self.path['default'] or self.path['en-us']) or self.path if file_path == 'DEFAULT' then return end self.full_path = (self.mod and self.mod.path or SMODS.path) .. 'assets/sounds/' .. file_path @@ -584,7 +584,7 @@ Set `prefix_config.key = false` on your object instead.]]):format(obj.key), obj. process_loc_text = function(self) -- empty loc_txt indicates there are existing values that shouldn't be changed or it isn't necessary if not self.loc_txt or not next(self.loc_txt) then return end - local target = self.loc_txt[G.SETTINGS.language] or self.loc_txt['default'] or self.loc_txt['en-us'] or + local target = (G.SETTINGS.real_language and self.loc_txt[G.SETTINGS.real_language]) or self.loc_txt[G.SETTINGS.language] or self.loc_txt['default'] or self.loc_txt['en-us'] or self.loc_txt local applied_text = "{s:0.8}" .. localize('b_applies_stakes_1') local any_applied @@ -2315,12 +2315,11 @@ Set `prefix_config.key = false` on your object instead.]]):format(obj.key), obj. if G.localization.misc.collabs[self.suit] == nil then G.localization.misc.collabs[self.suit] = {["1"] = 'Default'} end - - if self.loc_txt and self.loc_txt[G.SETTINGS.language] then - G.localization.misc.collabs[self.suit][self.suit_index .. ''] = self.loc_txt[G.SETTINGS.language] - elseif G.localization.misc.collabs[self.suit][self.suit_index .. ''] == nil then - G.localization.misc.collabs[self.suit][self.suit_index .. ''] = self.key + if not self.loc_txt then + G.localization.misc.collabs[self.suit][self.suit_index .. ''] = G.localization.misc.collabs[self.suit][self.suit_index .. ''] or self.key + return end + SMODS.process_loc_text(G.localization.misc.collabs[self.suit], self.suit_index..'', self.loc_txt) end, register = function (self) if self.registered then diff --git a/src/utils.lua b/src/utils.lua index 5b9ead48..e33b4946 100644 --- a/src/utils.lua +++ b/src/utils.lua @@ -177,7 +177,7 @@ end function SMODS.process_loc_text(ref_table, ref_value, loc_txt, key) local target = (type(loc_txt) == 'table') and - (loc_txt[G.SETTINGS.language] or loc_txt['default'] or loc_txt['en-us']) or loc_txt + ((G.SETTINGS.real_language and loc_txt[G.SETTINGS.real_language]) or loc_txt[G.SETTINGS.language] or loc_txt['default'] or loc_txt['en-us']) or loc_txt if key and (type(target) == 'table') then target = target[key] end if not (type(target) == 'string' or target and next(target)) then return end ref_table[ref_value] = target @@ -219,6 +219,7 @@ end function SMODS.handle_loc_file(path) local dir = path .. 'localization/' handle_loc_file(dir, G.SETTINGS.language, true) + if G.SETTINGS.real_language then handle_loc_file(dir, G.SETTINGS.real_language, true) end handle_loc_file(dir, 'default') handle_loc_file(dir, 'en-us') end diff --git a/version.lua b/version.lua index 8a745157..e4e3d891 100644 --- a/version.lua +++ b/version.lua @@ -1 +1 @@ -return "1.0.0~ALPHA-1221b-STEAMODDED" +return "1.0.0~ALPHA-1221c-STEAMODDED" From cfbbf246f11e4d8bcaa52ef71f0aacd23bbd467b Mon Sep 17 00:00:00 2001 From: Casimir Eisenach Date: Sat, 21 Dec 2024 23:19:01 +0100 Subject: [PATCH 16/21] SMODS.create_card sticker should_apply bugfix --- src/utils.lua | 5 ++++- version.lua | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/utils.lua b/src/utils.lua index e33b4946..9ffbef76 100644 --- a/src/utils.lua +++ b/src/utils.lua @@ -328,7 +328,10 @@ function SMODS.create_card(t) if t.seal then _card:set_seal(t.seal) end if t.stickers then for i, v in ipairs(t.stickers) do - if SMODS.Stickers[v]:should_apply(_card, t.area, true) then SMODS.Stickers[v]:apply(_card, true) end + local s = SMODS.Stickers[v] + if not s or type(s.should_apply) ~= 'function' or s:should_apply(_card, t.area, true) then + SMODS.Stickers[v]:apply(_card, true) + end end end diff --git a/version.lua b/version.lua index e4e3d891..3296caa8 100644 --- a/version.lua +++ b/version.lua @@ -1 +1 @@ -return "1.0.0~ALPHA-1221c-STEAMODDED" +return "1.0.0~ALPHA-1221d-STEAMODDED" From 3dfd2a30f0cb93447e29a5def5d65eca6a40cb01 Mon Sep 17 00:00:00 2001 From: Eremel Date: Sun, 22 Dec 2024 14:35:37 +0000 Subject: [PATCH 17/21] Fix info_queue on custom enhancements --- src/game_object.lua | 4 ++-- version.lua | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/game_object.lua b/src/game_object.lua index b223d779..a84d7082 100644 --- a/src/game_object.lua +++ b/src/game_object.lua @@ -1158,8 +1158,8 @@ Set `prefix_config.key = false` on your object instead.]]):format(obj.key), obj. target.scale = res.scale target.text_colour = res.text_colour end - if desc_nodes == full_UI_table.main and not full_UI_table.name and self.set ~= 'Enhanced' then - full_UI_table.name = localize { type = 'name', set = target.set, key = target.key, nodes = full_UI_table.name } + if desc_nodes == full_UI_table.main and not full_UI_table.name then + full_UI_table.name = self.set == 'Enhanced' and 'temp_value' or localize { type = 'name', set = target.set, key = target.key, nodes = full_UI_table.name } elseif desc_nodes ~= full_UI_table.main and not desc_nodes.name and self.set ~= 'Enhanced' then desc_nodes.name = localize{type = 'name_text', key = target.key, set = target.set } end diff --git a/version.lua b/version.lua index 3296caa8..168f6bad 100644 --- a/version.lua +++ b/version.lua @@ -1 +1 @@ -return "1.0.0~ALPHA-1221d-STEAMODDED" +return "1.0.0~ALPHA-1222a-STEAMODDED" From be6910e1da36df82c2ea89fcba98d6caf6bc694d Mon Sep 17 00:00:00 2001 From: Casimir Eisenach Date: Mon, 23 Dec 2024 01:15:41 +0100 Subject: [PATCH 18/21] Fix Steam API failing on unix (why?) --- src/core.lua | 10 ++-------- version.lua | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/core.lua b/src/core.lua index 4ebd125d..e7d66760 100644 --- a/src/core.lua +++ b/src/core.lua @@ -19,8 +19,8 @@ NFS = nativefs -- respects symlink/.. combos NFS.setWorkingDirectory(lovely_mod_dir) lovely_mod_dir = NFS.getWorkingDirectory() --- make sure NFS behaves the same as love.filesystem -NFS.setWorkingDirectory(love.filesystem.getSaveDirectory()) +-- ! Changing the CWD here causes the Steam API to fail on some UNIX platforms (#345) +-- NFS.setWorkingDirectory(love.filesystem.getSaveDirectory()) JSON = json @@ -33,12 +33,6 @@ local function set_mods_dir() if lovely_mod_dir:sub(1, #love_dir) == love_dir then -- relative path from love_dir SMODS.MODS_DIR = lovely_mod_dir:sub(#love_dir+2) - if nfs_success then - -- make sure NFS behaves the same as love.filesystem. - -- not perfect: NFS won't read from both getSaveDirectory() - -- and getSourceBaseDirectory() - NFS.setWorkingDirectory(love_dir) - end return end end diff --git a/version.lua b/version.lua index 168f6bad..fcda970c 100644 --- a/version.lua +++ b/version.lua @@ -1 +1 @@ -return "1.0.0~ALPHA-1222a-STEAMODDED" +return "1.0.0~ALPHA-1223a-STEAMODDED" From 2a280d5d524b19aa325d7c433bb7617c4e676a35 Mon Sep 17 00:00:00 2001 From: Casimir Eisenach Date: Mon, 23 Dec 2024 01:42:48 +0100 Subject: [PATCH 19/21] nevermind, this is the real fix --- lovely/fixes.toml | 20 ++++++++++++++++++++ src/core.lua | 5 +++-- version.lua | 2 +- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/lovely/fixes.toml b/lovely/fixes.toml index 4b8b68a4..d8f7df9a 100644 --- a/lovely/fixes.toml +++ b/lovely/fixes.toml @@ -534,4 +534,24 @@ if effects[ii].h_chips then update_hand_text({delay = 0}, {chips = hand_chips}) card_eval_status_text(effects[ii].card, 'chips', effects[ii].h_chips, percent) end +''' + +# Fixes Steam API not loading on unix +[[patches]] +[patches.pattern] +target = 'main.lua' +match_indent = true +position = 'after' +pattern = '--To control when steam communication happens, make sure to send updates to steam as little as possible' +payload = '''local cwd = NFS.getWorkingDirectory() +NFS.setWorkingDirectory(love.filesystem.getSourceBaseDirectory()) +''' + +[[patches]] +[patches.pattern] +target = 'main.lua' +match_indent = true +position = 'before' +pattern = '--Set up the render window and the stage for the splash screen, then enter the gameloop with :update' +payload = '''NFS.setWorkingDirectory(cwd) ''' \ No newline at end of file diff --git a/src/core.lua b/src/core.lua index e7d66760..f9961fae 100644 --- a/src/core.lua +++ b/src/core.lua @@ -19,8 +19,8 @@ NFS = nativefs -- respects symlink/.. combos NFS.setWorkingDirectory(lovely_mod_dir) lovely_mod_dir = NFS.getWorkingDirectory() --- ! Changing the CWD here causes the Steam API to fail on some UNIX platforms (#345) --- NFS.setWorkingDirectory(love.filesystem.getSaveDirectory()) +-- make sure NFS behaves the same as love.filesystem +NFS.setWorkingDirectory(love.filesystem.getSaveDirectory()) JSON = json @@ -33,6 +33,7 @@ local function set_mods_dir() if lovely_mod_dir:sub(1, #love_dir) == love_dir then -- relative path from love_dir SMODS.MODS_DIR = lovely_mod_dir:sub(#love_dir+2) + NFS.setWorkingDirectory(love_dir) return end end diff --git a/version.lua b/version.lua index fcda970c..52bb18be 100644 --- a/version.lua +++ b/version.lua @@ -1 +1 @@ -return "1.0.0~ALPHA-1223a-STEAMODDED" +return "1.0.0~ALPHA-1223b-STEAMODDED" From ec7c5c9337bc9cded055e721ce33351c1977fe1b Mon Sep 17 00:00:00 2001 From: Casimir Eisenach Date: Mon, 23 Dec 2024 01:57:28 +0100 Subject: [PATCH 20/21] Add OS-agnostic patch --- lovely/fixes.toml | 20 +++++++++++++++++++- version.lua | 2 +- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/lovely/fixes.toml b/lovely/fixes.toml index d8f7df9a..45a1984b 100644 --- a/lovely/fixes.toml +++ b/lovely/fixes.toml @@ -554,4 +554,22 @@ match_indent = true position = 'before' pattern = '--Set up the render window and the stage for the splash screen, then enter the gameloop with :update' payload = '''NFS.setWorkingDirectory(cwd) -''' \ No newline at end of file +''' + +[[patches]] +[patches.pattern] +target = "main.lua" +pattern = '''if os == 'OS X' or os == 'Windows' then''' +position = "at" +payload = '''if os == 'OS X' or os == 'Windows' or os == 'Linux' then''' +overwrite = true +match_indent = true + +[[patches]] +[patches.pattern] +target = "main.lua" +pattern = '''if os == 'OS X' then''' +position = "at" +payload = '''if os == 'OS X' or os == 'Linux' then''' +overwrite = true +match_indent = true \ No newline at end of file diff --git a/version.lua b/version.lua index 52bb18be..c3ed3191 100644 --- a/version.lua +++ b/version.lua @@ -1 +1 @@ -return "1.0.0~ALPHA-1223b-STEAMODDED" +return "1.0.0~ALPHA-1223c-STEAMODDED" From a83b5815ec5c298a00cd752f47e5373ed0cdb332 Mon Sep 17 00:00:00 2001 From: Casimir Eisenach Date: Mon, 23 Dec 2024 02:04:29 +0100 Subject: [PATCH 21/21] pcall so it doesn't crash without luasteam --- lovely/fixes.toml | 10 ++++++++++ version.lua | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lovely/fixes.toml b/lovely/fixes.toml index 45a1984b..592b9cdd 100644 --- a/lovely/fixes.toml +++ b/lovely/fixes.toml @@ -572,4 +572,14 @@ pattern = '''if os == 'OS X' then''' position = "at" payload = '''if os == 'OS X' or os == 'Linux' then''' overwrite = true +match_indent = true + +[[patches]] +[patches.pattern] +target = "main.lua" +pattern = "st = require 'luasteam'" +position = "at" +payload = """local success, _st = pcall(require, 'luasteam') +if success then st = _st end""" +overwrite = true match_indent = true \ No newline at end of file diff --git a/version.lua b/version.lua index c3ed3191..57fcf039 100644 --- a/version.lua +++ b/version.lua @@ -1 +1 @@ -return "1.0.0~ALPHA-1223c-STEAMODDED" +return "1.0.0~ALPHA-1223d-STEAMODDED"