balatro-mods/Steamodded/lovely/back.toml
2025-01-19 15:01:49 +08:00

140 lines
3.8 KiB
TOML

[manifest]
version = "1.0.0"
dump_lua = true
priority = 0
### Back API
# Back:init()
[[patches]]
[patches.pattern]
target = 'back.lua'
pattern = "if not selected_back then selected_back = G.P_CENTERS.b_red end"
position = 'after'
match_indent = true
payload = "self.atlas = selected_back.unlocked and selected_back.atlas or nil"
# Back:change_to()
[[patches]]
[patches.pattern]
target = 'back.lua'
pattern = "if not new_back then new_back = G.P_CENTERS.b_red end"
position = 'after'
match_indent = true
payload = "self.atlas = new_back.unlocked and new_back.atlas or nil"
# G.FUNCS.change_viewed_back
[[patches]]
[patches.pattern]
target = 'functions/button_callbacks.lua'
pattern = "G.PROFILES[G.SETTINGS.profile].MEMORY.deck = args.to_val"
position = 'after'
match_indent = true
payload = '''
for key, val in pairs(G.sticker_card.area.cards) do
val.children.back = false
val:set_ability(val.config.center, true)
end'''
# Back:apply_to_run()
[[patches]]
[patches.pattern]
target = 'back.lua'
pattern = "function Back:apply_to_run()"
position = 'after'
match_indent = true
payload = '''
local obj = self.effect.center
if obj.apply and type(obj.apply) == 'function' then
obj:apply()
end'''
# Back:trigger_effect(args)
[[patches]]
[patches.pattern]
target = 'back.lua'
pattern = "if not args then return end"
position = 'after'
match_indent = true
payload = '''
local obj = self.effect.center
if obj.trigger_effect and type(obj.trigger_effect) == 'function' then
local o = {obj:trigger_effect(args)}
if o then return unpack(o) end
end'''
## Back:generate_UI
# Localization with `unlock` field in loc_txt, same as for Jokers
[[patches]]
[patches.pattern]
target = 'back.lua'
pattern = 'if not back_config.unlock_condition then'
position = 'at'
payload = '''
local localized_by_smods
local key_override
if back_config.locked_loc_vars and type(back_config.locked_loc_vars) == 'function' then
local res = back_config:locked_loc_vars() or {}
loc_args = res.vars or {}
key_override = res.key
end
if G.localization.descriptions.Back[key_override or back_config.key].unlock_parsed then
localize{type = 'unlocks', key = key_override or back_config.key, set = 'Back', nodes = loc_nodes, vars = loc_args}
localized_by_smods = true
end
if not back_config.unlock_condition then'''
match_indent = true
[[patches]]
[patches.pattern]
target = 'back.lua'
pattern = '''localize{type = 'descriptions', key = 'demo_locked', set = "Other", nodes = loc_nodes, vars = loc_args}'''
position = 'at'
payload = '''
if not localized_by_smods then
localize{type = 'descriptions', key = 'demo_locked', set = "Other", nodes = loc_nodes, vars = loc_args}
end'''
match_indent = true
[[patches]]
[patches.pattern]
target = 'back.lua'
pattern = 'loc_args = {other_name}'
position = 'at'
payload = 'loc_args = loc_args or {other_name}'
match_indent = true
[[patches]]
[patches.pattern]
target = 'back.lua'
pattern = 'loc_args = {tostring(back_config.unlock_condition.amount)}'
position = 'at'
payload = 'loc_args = loc_args or {tostring(back_config.unlock_condition.amount)}'
match_indent = true
[[patches]]
[patches.pattern]
target = 'back.lua'
pattern = 'loc_args = {other_name, colours = {get_stake_col(back_config.unlock_condition.stake)}}'
position = 'at'
payload = 'loc_args = loc_args or {other_name, colours = {get_stake_col(back_config.unlock_condition.stake)}}'
match_indent = true
[[patches]]
[patches.pattern]
target = 'back.lua'
pattern = "if name_to_check == 'Blue Deck'*"
position = 'at'
match_indent = true
payload = '''
local key_override
if back_config.loc_vars and type(back_config.loc_vars) == 'function' then
local res = back_config:loc_vars() or {}
loc_args = res.vars or {}
key_override = res.key
elseif name_to_check == 'Blue Deck' then loc_args = {effect_config.hands}'''
[[patches]]
[patches.regex]
target = 'back.lua'
pattern = "key = back_config\\.key"
position = 'at'
payload = "key = key_override or back_config.key"