Skip to content
1 change: 1 addition & 0 deletions big-num/notations/Balatro.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ local nativefs = require("nativefs")
Notation = nativefs.load(Talisman.mod_path.."/big-num/notations/notation.lua")()
BalaNotation = {}
BalaNotation.__index = BalaNotation
BalaNotation.E_SWITCH_POINT = 100000000000
BalaNotation.__tostring = function ()
return "BalaNotation"
end
Expand Down
6 changes: 6 additions & 0 deletions localization/vi.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ return {
talisman_bignum = 'BigNum (ee308)',
talisman_omeganum = 'OmegaNum',

talisman_notation = 'Ký Hiệu số',

talisman_notations_hypere = 'Hyper-E',
talisman_notations_letter = 'Chữ Cái',
talisman_notations_array = 'Mảng',

talisman_string_A = 'Chọn tính năng để bật:',
talisman_string_B = 'Tắt Hoạt Ảnh Ghi Điểm',
talisman_string_C = 'Giới Hạn Điểm (yêu cầu khởi động lại)',
Expand Down
25 changes: 16 additions & 9 deletions lovely.toml
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,14 @@ position = "at"
payload = "if not is_number(G.GAME.current_round.current_hand.chips) or not is_number(G.GAME.current_round.current_hand.mult) then"
match_indent = true

[[patches]]
[patches.pattern]
target = "functions/misc_functions.lua"
pattern = "if type(G.GAME.current_round.current_hand[name]) ~= 'number' then all_numbers = false end"
position = "at"
payload = "if not is_number(G.GAME.current_round.current_hand[name]) then all_numbers = false end"
match_indent = true

[[patches]]
[patches.pattern]
target = "main.lua"
Expand Down Expand Up @@ -293,7 +301,7 @@ match_indent = true
target = "functions/UI_definitions.lua"
pattern = "{n=G.UIT.O, config={object = DynaText({string = {{ref_table = G.GAME.round_resets, ref_value = 'ante'}}, colours = {G.C.IMPORTANT},shadow = true, font = G.LANGUAGES['en-us'].font, scale = 2*scale}),id = 'ante_UI_count'}},"
position = "at"
payload = "{n=G.UIT.O, config={object = DynaText({string = {{ref_table = G.GAME.round_resets, ref_value = 'ante_disp'}}, colours = {G.C.IMPORTANT},shadow = true, font = G.LANGUAGES['en-us'].font, scale = scale_number(G.GAME.round_resets.ante, 2*scale, 100)}),id = 'ante_UI_count'}},--{n=G.UIT.T, config={text = number_format(G.GAME.round_resets.ante), lang = G.LANGUAGES['en-us'], scale = scale_number(G.GAME.round_resets.ante, 2*scale, 100), colour = G.C.IMPORTANT, shadow = true,id = 'ante_UI_count'}},"
payload = "{n=G.UIT.O, config={object = DynaText({string = {{ref_table = G.GAME.round_resets, ref_value = 'ante_disp'}}, colours = {G.C.IMPORTANT},shadow = true, font = G.LANGUAGES['en-us'].font, scale = scale_number(G.GAME.round_resets.ante, 2*scale, 100, 1000000)}),id = 'ante_UI_count'}},--{n=G.UIT.T, config={text = number_format(G.GAME.round_resets.ante, 1000000), lang = G.LANGUAGES['en-us'], scale = scale_number(G.GAME.round_resets.ante, 2*scale, 100, 1000000), colour = G.C.IMPORTANT, shadow = true,id = 'ante_UI_count'}},"
match_indent = true

[[patches]]
Expand All @@ -309,7 +317,10 @@ match_indent = true
target = "functions/common_events.lua"
pattern = "G.GAME.round_resets.ante = G.GAME.round_resets.ante + mod"
position = "after"
payload = "G.GAME.round_resets.ante_disp = number_format(G.GAME.round_resets.ante)"
payload = '''
G.GAME.round_resets.ante_disp = number_format(G.GAME.round_resets.ante, 1000000)
ante_UI.config.object.scale = scale_number(G.GAME.round_resets.ante, 0.8, 100, 1000000)
'''
match_indent = true

[[patches]]
Expand Down Expand Up @@ -1530,16 +1541,12 @@ G.ARGS.score_intensity.earned_score = math.min(to_number(G.GAME.current_round.cu
'''

[[patches]]
[patches.pattern]
[patches.regex]
target = 'functions/misc_functions.lua'
position = 'at'
match_indent = true
pattern = '''
G.ARGS.score_intensity.earned_score = SMODS.calculate_round_score(true)
'''
payload = '''
G.ARGS.score_intensity.earned_score = math.min(to_number(SMODS.calculate_round_score(true)), 1e300)
'''
pattern = '''SMODS\.calculate_round_score\(true\)'''
payload = '''math.min(to_number(SMODS.calculate_round_score(true)), 1e300)'''

# evaluate_play_final_scoring comparison
[[patches]]
Expand Down
57 changes: 38 additions & 19 deletions talisman.lua
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,10 @@ if Talisman.config_file.break_infinity then
return obj
end

local override_non_bigs = true

local nf = number_format
function number_format(num, e_switch_point)
if type(num) == 'table' or override_non_bigs then
--num = to_big(num)
if override_non_bigs then
num = to_big(num)
end
if is_number(num) then
num = to_big(num)
if num.str then return num.str end
if num:arraySize() > 2 then
local str = Notations[Talisman.config_file.notation_key or Talisman.default_notation]:format(num, 3)
Expand All @@ -221,23 +216,47 @@ if Talisman.config_file.break_infinity then
return mc(x)
end

function lenient_bignum(x)
function lenient_bignum(x)
if type(x) == "number" then return x end
if to_big(x) < to_big(1e300) and to_big(x) > to_big(-1e300) then
return x:to_number()
end
return x
end

--prevent some log-related crashes
local sns = score_number_scale
--despite the name, it only works best with m6x11plus\
--and only support the following characters: `0-9`, `e`, `{`, `}`, `,`,\
--`#` and `.` for the sake of number format simplicity
function tal_get_string_pixel_length(num)
if is_number(num) then
local num_text, length = number_format(num, G.E_SWITCH_POINT), 0
for i = 1, #num_text do
if string.sub(num_text, i, i) == "," or string.sub(num_text, i, i) == "." then
length = length + 3/6
elseif string.sub(num_text, i, i) == "{" or string.sub(num_text, i, i) == "}" then
length = length + 1
elseif string.sub(num_text, i, i) == "#" then
length = length + 8/6
else
length = length + 7/6
end
end
return length
end
end

-- I'm completely overriding this since I don't think any other mods
-- would alter a text scale adjustment function (HuyTheKiller)
function score_number_scale(scale, amt)
local ret = sns(scale, amt)
if type(ret) == "table" then
if ret > to_big(1e300) then return 1e300 end
return ret:to_number()
G.E_SWITCH_POINT = Notations[Talisman.config_file.notation_key or Talisman.default_notation].E_SWITCH_POINT or G.E_SWITCH_POINT or 100000000000
if not is_number(amt) then return 0.7*(scale or 1) end
if to_big(amt) >= to_big(G.E_SWITCH_POINT) or Talisman.config_file.notation_key ~= "Balatro" then
return math.min(6/math.floor(tal_get_string_pixel_length(amt)+1), 0.7)*(scale or 1)
elseif to_big(amt) >= to_big(1000000) then
return 14*0.75/(math.floor(math.log(amt))+4)*(scale or 1)
else
return 0.75*(scale or 1)
end
return ret
end

local gftsj = G.FUNCS.text_super_juice
Expand Down Expand Up @@ -421,14 +440,14 @@ function lenient_bignum(x)
else
scale = scale*math.floor(math.log(max*10, 10))/math.floor(math.max(7,string.len(number.str or number_format(number))-1))
end
elseif to_big(number) >= to_big(e_switch_point or G.E_SWITCH_POINT) then
elseif math.abs(to_big(number)) >= to_big(e_switch_point or G.E_SWITCH_POINT) then
if number:arraySize() <= 2 and (number.array[1] or 0) <= 999 then --gross hack
scale = scale*math.floor(math.log(max*10, 10))/7 --this divisor is a constant so im precalcualting it
else
scale = scale*math.floor(math.log(max*10, 10))/math.floor(math.max(7,string.len(number_format(number))-1))
end
elseif to_big(number) >= to_big(max) then
scale = scale*math.floor(math.log(max*10, 10))/math.floor(math.log(number*10, 10))
elseif math.abs(to_big(number)) >= to_big(max) then
scale = scale*math.floor(math.log(max*10, 10))/math.floor(math.log(math.abs(number)*10, 10))
end
local scale = math.min(3, scale:to_number())
number.scale = scale
Expand Down Expand Up @@ -955,7 +974,7 @@ end
local g_start_run = Game.start_run
function Game:start_run(args)
local ret = g_start_run(self, args)
self.GAME.round_resets.ante_disp = self.GAME.round_resets.ante_disp or number_format(self.GAME.round_resets.ante)
self.GAME.round_resets.ante_disp = self.GAME.round_resets.ante_disp or number_format(self.GAME.round_resets.ante, 1000000)
return ret
end

Expand Down