Skip to content

Commit b3a43fc

Browse files
committed
Backward compat
uhh...
1 parent e8f9b5a commit b3a43fc

File tree

3 files changed

+136
-67
lines changed

3 files changed

+136
-67
lines changed

lovely.toml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,22 @@ end
343343
'''
344344
match_indent = true
345345

346-
[[patches]] # Backward compat no longer needed - Talisman is now dependent on Chip-Mult Operator API
346+
[[patches]]
347+
[patches.pattern]
348+
target = "engine/text.lua"
349+
pattern = "for k, letter in ipairs(self.strings[self.focused_string].letters) do"
350+
position = "after" # old DynaText backward compat
351+
payload = '''
352+
if Big then
353+
letter.dims.x = to_number(letter.dims.x)
354+
letter.dims.y = to_number(letter.dims.y)
355+
letter.offset.x = to_number(letter.offset.x)
356+
letter.offset.y = to_number(letter.offset.y)
357+
end
358+
'''
359+
match_indent = true
360+
361+
[[patches]]
347362
[patches.pattern]
348363
target = "engine/text.lua"
349364
pattern = "local letter = self.strings[self.focused_string].letters[k]"
@@ -1309,6 +1324,7 @@ target = 'functions/common_events.lua'
13091324
pattern = "if amt > 0 or amt < 0 then"
13101325
position = 'at'
13111326
payload = "if to_big(amt) > to_big(0) or to_big(amt) < to_big(0) then"
1327+
match_indent = true
13121328

13131329
[[patches]]
13141330
[patches.regex]
@@ -1479,6 +1495,18 @@ G.E_MANAGER:add_event(Event({
14791495
}))
14801496
'''
14811497

1498+
[[patches]]
1499+
[patches.pattern]
1500+
target = 'functions/misc_functions.lua'
1501+
position = 'at'
1502+
match_indent = true
1503+
pattern = '''
1504+
G.ARGS.score_intensity.earned_score = G.ARGS.score_intensity.earned_score = G.GAME.current_round.current_hand.chips*G.GAME.current_round.current_hand.mult
1505+
'''
1506+
payload = '''
1507+
G.ARGS.score_intensity.earned_score = math.min(to_number(G.ARGS.score_intensity.earned_score = G.GAME.current_round.current_hand.chips*G.GAME.current_round.current_hand.mult), 1e300)
1508+
'''
1509+
14821510
[[patches]]
14831511
[patches.pattern]
14841512
target = 'functions/misc_functions.lua'

steamodded_metadata.lua

Lines changed: 50 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
--- MOD_ID: Talisman
44
--- MOD_AUTHOR: [MathIsFun_, Mathguy24, jenwalter666, cg-223, lord.ruby]
55
--- MOD_DESCRIPTION: A mod that increases Balatro's score limit and skips scoring animations.
6-
--- DEPENDENCIES: [Steamodded>=1.0.0~BETA-0816a]
76
--- PREFIX: talisman
8-
--- VERSION: 2.4.0
7+
--- VERSION: 2.4
98

109
----------------------------------------------
1110
------------MOD CODE -------------------------
@@ -98,57 +97,59 @@ end
9897
end,
9998
}--]]
10099

101-
local ref = SMODS.set_scoring_calculation
102-
function SMODS.set_scoring_calculation(key, ...)
103-
G.GAME.current_scoring_calculation_key = key
104-
if key == "talisman_hyper" then
105-
G.GAME.hyper_operator = G.GAME.hyper_operator or 2
106-
end
107-
return ref(key, ...)
108-
end
100+
if SMODS and SMODS.Scoring_Calculation then
101+
local ref = SMODS.set_scoring_calculation
102+
function SMODS.set_scoring_calculation(key, ...)
103+
G.GAME.current_scoring_calculation_key = key
104+
if key == "talisman_hyper" then
105+
G.GAME.hyper_operator = G.GAME.hyper_operator or 2
106+
end
107+
return ref(key, ...)
108+
end
109109

110-
SMODS.Scoring_Calculation:take_ownership("add", {order = -1}, true)
111-
SMODS.Scoring_Calculation:take_ownership("multiply", {order = 0}, true)
112-
SMODS.Scoring_Calculation:take_ownership("exponent", {order = 1}, true)
113-
function change_operator(amount)
114-
local order = SMODS.Scoring_Calculations[G.GAME.current_scoring_calculation_key or "multiply"].order + amount
115-
if not order then return end
116-
if G.GAME.current_scoring_calculation_key == "talisman_hyper" then
117-
G.GAME.hyper_operator = (G.GAME.hyper_operator or 2) + amount
118-
order = G.GAME.hyper_operator
119-
end
120-
local next = "add"
121-
local keys = {}
122-
for i, v in pairs(SMODS.Scoring_Calculations) do
123-
if v.order then
124-
keys[#keys+1] = i
110+
SMODS.Scoring_Calculation:take_ownership("add", {order = -1}, true)
111+
SMODS.Scoring_Calculation:take_ownership("multiply", {order = 0}, true)
112+
SMODS.Scoring_Calculation:take_ownership("exponent", {order = 1}, true)
113+
function change_operator(amount)
114+
local order = SMODS.Scoring_Calculations[G.GAME.current_scoring_calculation_key or "multiply"].order + amount
115+
if not order then return end
116+
if G.GAME.current_scoring_calculation_key == "talisman_hyper" then
117+
G.GAME.hyper_operator = (G.GAME.hyper_operator or 2) + amount
118+
order = G.GAME.hyper_operator
125119
end
126-
end
127-
table.sort(keys, function(a, b) return SMODS.Scoring_Calculations[a].order < SMODS.Scoring_Calculations[b].order end)
128-
for i, v in pairs(keys) do
129-
if SMODS.Scoring_Calculations[v].order <= order then
130-
next = v
120+
local next = "add"
121+
local keys = {}
122+
for i, v in pairs(SMODS.Scoring_Calculations) do
123+
if v.order then
124+
keys[#keys+1] = i
131125
end
132-
end
133-
if next then
134-
SMODS.set_scoring_calculation(next)
135-
end
136-
end
126+
end
127+
table.sort(keys, function(a, b) return SMODS.Scoring_Calculations[a].order < SMODS.Scoring_Calculations[b].order end)
128+
for i, v in pairs(keys) do
129+
if SMODS.Scoring_Calculations[v].order <= order then
130+
next = v
131+
end
132+
end
133+
if next then
134+
SMODS.set_scoring_calculation(next)
135+
end
136+
end
137137

138-
SMODS.Scoring_Calculation {
139-
key = "hyper",
140-
func = function(self, chips, mult, flames) return to_big(chips):arrow(G.GAME.hyper_operator or 2, mult) end,
141-
text = function()
142-
if G.GAME.hyper_operator < 6 then
143-
local str = ""
144-
for i = 1, G.GAME.hyper_operator do str = str.."^" end
145-
return str
146-
else
147-
return "{"..G.GAME.hyper_operator.."}"
148-
end
149-
end,
150-
order = 2
151-
}
138+
SMODS.Scoring_Calculation {
139+
key = "hyper",
140+
func = function(self, chips, mult, flames) return to_big(chips):arrow(G.GAME.hyper_operator or 2, mult) end,
141+
text = function()
142+
if G.GAME.hyper_operator < 6 then
143+
local str = ""
144+
for i = 1, G.GAME.hyper_operator do str = str.."^" end
145+
return str
146+
else
147+
return "{"..G.GAME.hyper_operator.."}"
148+
end
149+
end,
150+
order = 2
151+
}
152+
end
152153

153154
----------------------------------------------
154155
------------MOD CODE END----------------------

talisman.lua

Lines changed: 57 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -923,8 +923,13 @@ if SMODS and SMODS.calculate_individual_effect then
923923

924924
if (key == 'e_chips' or key == 'echips' or key == 'Echip_mod') and amount ~= 1 then
925925
if effect.card then juice_card(effect.card) end
926-
local chips = SMODS.Scoring_Parameters["chips"]
927-
chips:modify(chips.current ^ amount - chips.current)
926+
if SMODS.Scoring_Parameters then
927+
local chips = SMODS.Scoring_Parameters["chips"]
928+
chips:modify(chips.current ^ amount - chips.current)
929+
else
930+
hand_chips = mod_chips(hand_chips ^ amount)
931+
update_hand_text({delay = 0}, {chips = hand_chips, mult = mult})
932+
end
928933
if not effect.remove_default_message then
929934
if from_edition then
930935
card_eval_status_text(scored_card, 'jokers', nil, percent, nil, {message = "^"..amount, colour = G.C.EDITION, edition = true})
@@ -941,8 +946,13 @@ if SMODS and SMODS.calculate_individual_effect then
941946

942947
if (key == 'ee_chips' or key == 'eechips' or key == 'EEchip_mod') and amount ~= 1 then
943948
if effect.card then juice_card(effect.card) end
944-
local chips = SMODS.Scoring_Parameters["chips"]
945-
chips:modify(to_big(chips.current):tetrate(amount) - chips.current)
949+
if SMODS.Scoring_Parameters then
950+
local chips = SMODS.Scoring_Parameters["chips"]
951+
chips:modify(to_big(chips.current):tetrate(amount) - chips.current)
952+
else
953+
hand_chips = mod_chips(hand_chips:tetrate(amount))
954+
update_hand_text({delay = 0}, {chips = hand_chips, mult = mult})
955+
end
946956
if not effect.remove_default_message then
947957
if from_edition then
948958
card_eval_status_text(scored_card, 'jokers', nil, percent, nil, {message = "^^"..amount, colour = G.C.EDITION, edition = true})
@@ -959,8 +969,13 @@ if SMODS and SMODS.calculate_individual_effect then
959969

960970
if (key == 'eee_chips' or key == 'eeechips' or key == 'EEEchip_mod') and amount ~= 1 then
961971
if effect.card then juice_card(effect.card) end
962-
local chips = SMODS.Scoring_Parameters["chips"]
963-
chips:modify(to_big(chips.current):arrow(3, amount) - chips.current)
972+
if SMODS.Scoring_Parameters then
973+
local chips = SMODS.Scoring_Parameters["chips"]
974+
chips:modify(to_big(chips.current):arrow(3, amount) - chips.current)
975+
else
976+
hand_chips = mod_chips(hand_chips:arrow(3, amount))
977+
update_hand_text({delay = 0}, {chips = hand_chips, mult = mult})
978+
end
964979
if not effect.remove_default_message then
965980
if from_edition then
966981
card_eval_status_text(scored_card, 'jokers', nil, percent, nil, {message = "^^^"..amount, colour = G.C.EDITION, edition = true})
@@ -977,8 +992,13 @@ if SMODS and SMODS.calculate_individual_effect then
977992

978993
if (key == 'hyper_chips' or key == 'hyperchips' or key == 'hyperchip_mod') and type(amount) == 'table' then
979994
if effect.card then juice_card(effect.card) end
980-
local chips = SMODS.Scoring_Parameters["chips"]
981-
chips:modify(to_big(chips.current):arrow(amount[1], amount[2]) - chips.current)
995+
if SMODS.Scoring_Parameters then
996+
local chips = SMODS.Scoring_Parameters["chips"]
997+
chips:modify(to_big(chips.current):arrow(amount[1], amount[2]) - chips.current)
998+
else
999+
hand_chips = mod_chips(hand_chips:arrow(amount[1], amount[2]))
1000+
update_hand_text({delay = 0}, {chips = hand_chips, mult = mult})
1001+
end
9821002
if not effect.remove_default_message then
9831003
if from_edition then
9841004
card_eval_status_text(scored_card, 'jokers', nil, percent, nil, {message = (amount[1] > 5 and ('{' .. amount[1] .. '}') or string.rep('^', amount[1])) .. amount[2], colour = G.C.EDITION, edition = true})
@@ -995,8 +1015,13 @@ if SMODS and SMODS.calculate_individual_effect then
9951015

9961016
if (key == 'e_mult' or key == 'emult' or key == 'Emult_mod') and amount ~= 1 then
9971017
if effect.card then juice_card(effect.card) end
998-
local mult = SMODS.Scoring_Parameters["mult"]
999-
mult:modify(mult.current ^ amount - mult.current)
1018+
if SMODS.Scoring_Parameters then
1019+
local mult = SMODS.Scoring_Parameters["mult"]
1020+
mult:modify(mult.current ^ amount - mult.current)
1021+
else
1022+
mult = mod_mult(mult ^ amount)
1023+
update_hand_text({delay = 0}, {chips = hand_chips, mult = mult})
1024+
end
10001025
if not effect.remove_default_message then
10011026
if from_edition then
10021027
card_eval_status_text(scored_card, 'jokers', nil, percent, nil, {message = "^"..amount.." "..localize("k_mult"), colour = G.C.EDITION, edition = true})
@@ -1013,8 +1038,13 @@ if SMODS and SMODS.calculate_individual_effect then
10131038

10141039
if (key == 'ee_mult' or key == 'eemult' or key == 'EEmult_mod') and amount ~= 1 then
10151040
if effect.card then juice_card(effect.card) end
1016-
local mult = SMODS.Scoring_Parameters["mult"]
1017-
mult:modify(to_big(mult.current):arrow(2, amount) - mult.current)
1041+
if SMODS.Scoring_Parameters then
1042+
local mult = SMODS.Scoring_Parameters["mult"]
1043+
mult:modify(to_big(mult.current):arrow(2, amount) - mult.current)
1044+
else
1045+
mult = mod_mult(mult:arrow(2, amount))
1046+
update_hand_text({delay = 0}, {chips = hand_chips, mult = mult})
1047+
end
10181048
if not effect.remove_default_message then
10191049
if from_edition then
10201050
card_eval_status_text(scored_card, 'jokers', nil, percent, nil, {message = "^^"..amount.." "..localize("k_mult"), colour = G.C.EDITION, edition = true})
@@ -1031,8 +1061,13 @@ if SMODS and SMODS.calculate_individual_effect then
10311061

10321062
if (key == 'eee_mult' or key == 'eeemult' or key == 'EEEmult_mod') and amount ~= 1 then
10331063
if effect.card then juice_card(effect.card) end
1034-
local mult = SMODS.Scoring_Parameters["mult"]
1035-
mult:modify(to_big(mult.current):arrow(3, amount) - mult.current)
1064+
if SMODS.Scoring_Parameters then
1065+
local mult = SMODS.Scoring_Parameters["mult"]
1066+
mult:modify(to_big(mult.current):arrow(3, amount) - mult.current)
1067+
else
1068+
mult = mod_mult(mult:arrow(3, amount))
1069+
update_hand_text({delay = 0}, {chips = hand_chips, mult = mult})
1070+
end
10361071
if not effect.remove_default_message then
10371072
if from_edition then
10381073
card_eval_status_text(scored_card, 'jokers', nil, percent, nil, {message = "^^^"..amount.." "..localize("k_mult"), colour = G.C.EDITION, edition = true})
@@ -1049,8 +1084,13 @@ if SMODS and SMODS.calculate_individual_effect then
10491084

10501085
if (key == 'hyper_mult' or key == 'hypermult' or key == 'hypermult_mod') and type(amount) == 'table' then
10511086
if effect.card then juice_card(effect.card) end
1052-
local mult = SMODS.Scoring_Parameters["mult"]
1053-
mult:modify(to_big(mult.current):arrow(amount[1], amount[2]) - mult.current)
1087+
if SMODS.Scoring_Parameters then
1088+
local mult = SMODS.Scoring_Parameters["mult"]
1089+
mult:modify(to_big(mult.current):arrow(amount[1], amount[2]) - mult.current)
1090+
else
1091+
mult = mod_mult(mult:arrow(amount[1], amount[2]))
1092+
update_hand_text({delay = 0}, {chips = hand_chips, mult = mult})
1093+
end
10541094
if not effect.remove_default_message then
10551095
if from_edition then
10561096
card_eval_status_text(scored_card, 'jokers', nil, percent, nil, {message = ((amount[1] > 5 and ('{' .. amount[1] .. '}') or string.rep('^', amount[1])) .. amount[2]).." "..localize("k_mult"), colour = G.C.EDITION, edition = true})
@@ -1068,7 +1108,7 @@ if SMODS and SMODS.calculate_individual_effect then
10681108
for _, v in ipairs({'e_mult', 'e_chips', 'ee_mult', 'ee_chips', 'eee_mult', 'eee_chips', 'hyper_mult', 'hyper_chips',
10691109
'emult', 'echips', 'eemult', 'eechips', 'eeemult', 'eeechips', 'hypermult', 'hyperchips',
10701110
'Emult_mod', 'Echip_mod', 'EEmult_mod', 'EEchip_mod', 'EEEmult_mod', 'EEEchip_mod', 'hypermult_mod', 'hyperchip_mod'}) do
1071-
table.insert(SMODS.scoring_parameter_keys, v)
1111+
table.insert(SMODS.scoring_parameter_keys or SMODS.calculation_keys, v)
10721112
end
10731113

10741114
-- prvent juice animations

0 commit comments

Comments
 (0)