Ensure object exists

This commit is contained in:
Emik 2026-10-01 18:34:49 +02:00
parent 8784e13aa4
commit bce3753088
Signed by: emik
GPG key ID: 6B0CD72A5E503BDF
3 changed files with 236 additions and 5 deletions

222
lovely.stub.toml Normal file
View file

@ -0,0 +1,222 @@
[manifest]
version = "1.0.0"
dump_lua = true
priority = 115
[[patches]]
[patches.pattern]
target = "card.lua"
pattern = "if v ~= chosen_joker then"
position = "at"
payload = """if v ~= chosen_joker and
not next(SMODS.find_card('j_jane_saint')) and
not next(SMODS.find_card('j_jen_saint')) and
not next(SMODS.find_card('j_jen_saint_attuned')) then"""
match_indent = true
[[patches]]
[patches.pattern]
target = '=[SMODS jen "Jen.lua"]'
pattern = "'rot',"
position = "after"
payload = "'escapey',"
match_indent = true
[[patches]]
[patches.pattern]
target = '=[SMODS jen "Jen.lua"]'
pattern = "if cen.click_noise then"
position = "before"
payload = """
if cen.key == "j_jen_escapey" then
local escapey_per = 10
cen.click_noise_vol = 0.4
cen.click_noise = 'jen_plasticButton' .. math.random(2)
cen.click_noise_per = math.random() / escapey_per + (escapey_per * 2 - 1) / (escapey_per * 2)
end
"""
match_indent = true
[[patches]]
[patches.pattern]
target = '=[SMODS jen "Jen.lua"]'
pattern = "--SOUNDS"
position = "after"
payload = """
SMODS.Sound({
key = "plasticButton1",
path = "plasticButton1.ogg"
})
SMODS.Sound({
key = "plasticButton2",
path = "plasticButton2.ogg"
})
"""
match_indent = true
[[patches]]
[patches.pattern]
target = '=[SMODS jen "Jen.lua"]'
pattern = "local crimbo_quotes = {"
position = "before"
payload = """
local function destructible(card)
return card.ability.consumeable and not card.highlighted and not (card.ability or {}).eternal
end
local escapey_quotes = {
marble = {"there is no escape..."},
normal = {
{"", "I can't wait to work with you!"},
{"", "Did you need something from me?"},
{"", "Oh! I'm just so happy to see you!"},
{"Can I say something irrelevant?", "I promise it won't be long."},
{"Tell me about your buddies!", "Assuming you have them, anyway."},
},
scared = {
"What am I going to do?!",
"I'm not scared, you are!",
"Tell me when this is over...",
"I can't keep looking at this!",
"Let me go hide in this corner... Okay?",
},
}
local function escapey_button_text(card)
if card.debuff then
return "DEBUFFED"
end
for _, v in ipairs(G.consumeables.cards) do
if destructible(v) then
return "CONSUME"
end
end
return "ESCAPE"
end
SMODS.Joker {
key = "escapey",
atlas = "jenescapey",
pronouns = "they_them",
loc_txt = {
name = "Escapey",
text = {
"{s:1.25}Use to sell {C:attention,s:1.25}tags",
"{s:1.25}for {X:money,C:white,s:1.25}$#1#X{s:1.25} each",
"If any {C:attention}consumables",
"are unselected, sell",
"those for {C:money}$#3# {}instead",
"{C:inactive,s:0.75,E:1}#4#",
"{C:inactive,s:0.75,E:1}#5#{C:red,s:1.5,E:1}#6#",
},
},
config = {extra = {money = 2, xmoney = 2, max = 200, escape_label = "ESCAPE"}},
attributes = {"destroy_card", "economy", "tag"},
pos = {x = 0, y = 0},
sinis = {x = 2, y = 0},
soul_pos = {x = 1, y = 0},
cost = 4,
rarity = 2,
eternal_compat = true,
blueprint_compat = false,
perishable_compat = true,
inject = not SMODS.Attribute and function(...)
SMODS.Joker.inject(...)
Bakery_API.usable_jokers.j_jen_escapey = true
end or nil,
loc_vars = function(_, _, card)
local extra = card.ability.extra
local normal = Jen.sinister and {"", ""} or
pseudorandom_element(escapey_quotes.normal, pseudoseed "EscapeyQuotes") or {"", ""}
local scared = not Jen.sinister and "" or
pseudorandom_element(escapey_quotes.scared, pseudoseed "EscapeyQuotes") or ""
return {vars = {extra.xmoney, number_format(extra.max), extra.money, normal[1], normal[2], scared}}
end,
calculate = function(_, card)
local extra = card.ability.extra
local label = extra.escape_label
extra.escape_label = escapey_button_text(card)
local _ = label ~= extra.escape_label and Bakery_API.rehighlight(card)
end,
Bakery_can_use = function(_, card)
if not jl.canuse() or card.debuff then
return false
end
if next(G.GAME.tags) then
return true
end
for _, v in ipairs(G.consumeables.cards) do
if destructible(v) then
return true
end
end
return false
end,
Bakery_use_button_text = function(_, card)
return card.ability.extra.escape_label
end,
Bakery_use_joker = function(self, card)
if card.debuff then
return
end
local times, xtimes = 0, 0
local extra = card.ability.extra
for _, v in ipairs(G.consumeables.cards) do
if destructible(v) then
v:start_dissolve({HEX "57ecabff"}, nil, 1.6)
times = times + 1
end
end
if times == 0 then
local delay = #G.GAME.tags >= self.tag_threshold and 0 or 1 / #G.GAME.tags
local trigger = delay == 0 and "immediate" or "before"
for _, v in ipairs(G.GAME.tags) do
Q(function()
attention_text {
scale = 0.7,
align = "cm",
text = "ESC",
cover = v.HUD_tag,
colour = G.C.WHITE,
cover_colour = G.C.BLACK,
hold = 0.3 / G.SETTINGS.GAMESPEED,
}
play_sound("cancel", 1.66, 0.5)
v.HUD_tag.states.visible = false
v:remove()
end, delay, nil, trigger, nil, delay ~= 0)
xtimes = xtimes + 1
end
end
local tag_money = G.GAME.dollars
local tag_times = math.pow(extra.xmoney, xtimes) - 1
ease_dollars(math.ceil(times * extra.money + tag_money * tag_times))
end,
tag_threshold = 30,
}
"""
match_indent = true
[[patches]]
[patches.pattern]
target = '=[SMODS _ "src/utils.lua"]'
pattern = "function SMODS.has_enhancement(card, key)"
position = "after"
payload = "if not card.config then return false end"
match_indent = true

View file

@ -8,7 +8,10 @@ priority = 115
target = "card.lua" target = "card.lua"
pattern = "if v ~= chosen_joker then" pattern = "if v ~= chosen_joker then"
position = "at" position = "at"
payload = "if v ~= chosen_joker and not next(SMODS.find_card('j_jane_saint')) then" payload = """if v ~= chosen_joker and
not next(SMODS.find_card('j_jane_saint')) and
not next(SMODS.find_card('j_jen_saint')) and
not next(SMODS.find_card('j_jen_saint_attuned')) then"""
match_indent = true match_indent = true
[[patches]] [[patches]]
@ -24,7 +27,7 @@ match_indent = true
target = "functions/common_events.lua" target = "functions/common_events.lua"
pattern = "if v.name == 'Black Hole' or v.name == 'The Soul' or v.hidden then" pattern = "if v.name == 'Black Hole' or v.name == 'The Soul' or v.hidden then"
position = "at" position = "at"
payload = "if Jane.hidden(v) then" payload = "if Jane and Jane.hidden(v) or v.name == 'Black Hole' or v.name == 'The Soul' or v.hidden then"
match_indent = true match_indent = true
[[patches]] [[patches]]
@ -32,7 +35,9 @@ match_indent = true
target = "functions/misc_functions.lua" target = "functions/misc_functions.lua"
pattern = "G.GAME.current_round.current_hand.chips*G.GAME.current_round.current_hand.mult" pattern = "G.GAME.current_round.current_hand.chips*G.GAME.current_round.current_hand.mult"
position = "at" position = "at"
payload = '''Jane.get_chipmult_sum(G.GAME.current_round.current_hand.chips, G.GAME.current_round.current_hand.mult)''' payload = '''Jane and
Jane.get_chipmult_sum(G.GAME.current_round.current_hand.chips, G.GAME.current_round.current_hand.mult) or
G.GAME.current_round.current_hand.chips*G.GAME.current_round.current_hand.mult'''
match_indent = true match_indent = true
[[patches]] [[patches]]
@ -159,7 +164,7 @@ match_indent = true
target = "functions/state_events.lua" target = "functions/state_events.lua"
pattern = '''hand_chips\*mult\)''' pattern = '''hand_chips\*mult\)'''
position = "at" position = "at"
payload = "Jane.get_chipmult_sum(hand_chips, mult))" payload = "Jane and Jane.get_chipmult_sum(hand_chips, mult) or hand_chips*mult)"
[[patches]] [[patches]]
[patches.pattern] [patches.pattern]
@ -286,6 +291,10 @@ SMODS.Joker {
eternal_compat = true, eternal_compat = true,
blueprint_compat = false, blueprint_compat = false,
perishable_compat = true, perishable_compat = true,
inject = not SMODS.Attribute and function(...)
SMODS.Joker.inject(...)
Bakery_API.usable_jokers.j_jen_escapey = true
end or nil,
loc_vars = function(_, _, card) loc_vars = function(_, _, card)
local extra = card.ability.extra local extra = card.ability.extra

View file

@ -16,5 +16,5 @@
"Bakery (>=3.2.0~*)" "Bakery (>=3.2.0~*)"
], ],
"conflicts": [], "conflicts": [],
"version": "1.11.29" "version": "1.11.30"
} }