Make Void always hidden, make hooking more resilient to lag

This commit is contained in:
Emik 2026-06-06 19:34:08 +02:00
parent dff89f4062
commit f8d865d5c1
Signed by: emik
GPG key ID: 6B0CD72A5E503BDF
7 changed files with 52 additions and 34 deletions

View file

@ -3,7 +3,7 @@
"id": "Roland", "id": "Roland",
"name": "Roland", "name": "Roland",
"prefix": "Roland", "prefix": "Roland",
"version": "2.8.19", "version": "2.8.20",
"badge_colour": "8BE9FD", "badge_colour": "8BE9FD",
"display_name": "Roland", "display_name": "Roland",
"main_file": "src/main.lua", "main_file": "src/main.lua",

View file

@ -67,7 +67,7 @@ SMODS.Challenge {
local spin_to_win = SMODS.Challenge { local spin_to_win = SMODS.Challenge {
key = "Spin_To_Win", key = "Spin_To_Win",
jokers = f(4):map(f().const {id = "j_Bakery_Spinner", eternal = true}):table(), jokers = f(4):map(f().const {id = "j_joker", eternal = true}):table(),
restrictions = {banned_cards = {{id = "c_Roland_coolheaded"}}}, restrictions = {banned_cards = {{id = "c_Roland_coolheaded"}}},
pronouns = "they_them", pronouns = "they_them",
apply = function(self) apply = function(self)
@ -261,12 +261,6 @@ SMODS.Challenge {
} }
q(function() q(function()
if not G.P_CENTERS.j_Bakery_Spinner then
f(spin_to_win.jokers):each(function(v)
v.id = "j_joker"
end)
end
f { f {
{G.P_TAGS, is_banned_from_pastry, pastries.banned_tags}, {G.P_TAGS, is_banned_from_pastry, pastries.banned_tags},
{G.P_BLINDS, is_banned_from_pastry, pastries.banned_other}, {G.P_BLINDS, is_banned_from_pastry, pastries.banned_other},
@ -280,3 +274,13 @@ q(function()
f(v[1]):where(v[2]):each(adder(v[3])) f(v[1]):where(v[2]):each(adder(v[3]))
end) end)
end) end)
q(function()
if not G.P_CENTERS.j_Bakery_Spinner then
return true
end
f(spin_to_win.jokers):each(function(v)
v.id = "j_Bakery_Spinner"
end)
end)

View file

@ -205,7 +205,7 @@ q(function()
local estate = G.P_CENTERS.j_Bakery_Estate local estate = G.P_CENTERS.j_Bakery_Estate
if not estate then if not estate then
return return true
end end
---@param card Card|{ Roland_frozen: {estate: integer} } ---@param card Card|{ Roland_frozen: {estate: integer} }
@ -214,18 +214,14 @@ q(function()
return 1 return 1
end end
card.Roland_frozen.estate = card.Roland_frozen.estate or card.Roland_frozen.estate = card.Roland_frozen.estate or card.rank or 1
f(card.area.cards):swap():any(function(_, k)
return k == card
end) or 1
return card.Roland_frozen.estate return card.Roland_frozen.estate
end end
local orig_calculate = estate.calculate local orig_calculate = estate.calculate
function estate:calculate(card, context, ...) function estate:calculate(card, context, ...)
if not card or not card.edition or not card.edition.Roland_frozen then if not ((card or {}).edition or {}).Roland_frozen then
return orig_calculate(self, card, context, ...) return orig_calculate(self, card, context, ...)
end end
@ -241,7 +237,7 @@ q(function()
local orig_loc_vars = estate.loc_vars local orig_loc_vars = estate.loc_vars
function estate:loc_vars(info_queue, card, ...) function estate:loc_vars(info_queue, card, ...)
if not card or not card.edition or not card.edition.Roland_frozen then if not ((card or {}).edition or {}).Roland_frozen then
return orig_loc_vars(self, info_queue, card, ...) return orig_loc_vars(self, info_queue, card, ...)
end end
@ -255,7 +251,7 @@ q(function()
local proxy = G.P_CENTERS.j_Bakery_Proxy local proxy = G.P_CENTERS.j_Bakery_Proxy
if not proxy then if not proxy then
return return true
end end
---@param card Card|{ Roland_frozen: {proxy: string} } ---@param card Card|{ Roland_frozen: {proxy: string} }
@ -308,7 +304,7 @@ q(function()
local orig_flip_double_sided = (Bakery_API or {}).flip_double_sided local orig_flip_double_sided = (Bakery_API or {}).flip_double_sided
if not orig_flip_double_sided then if not orig_flip_double_sided then
return return true
end end
function Bakery_API.flip_double_sided(card, ...) function Bakery_API.flip_double_sided(card, ...)

View file

@ -10,7 +10,23 @@ local function protect(fun)
end end
end end
local function protect_ev(fun) local function protect_ev(fun, retries)
if type(fun) == "function" and retries then
local orig_fun = fun
fun = function(...)
local ret = orig_fun(...)
if ret == true then
sendErrorMessage(retries, "Roland")
retries = retries - 1
return retries <= 0
else
return ret
end
end
end
if type(fun) == "table" then if type(fun) == "table" then
fun.func = protect(fun.func) fun.func = protect(fun.func)
fun = getmetatable(fun) == Event and fun or Event(fun) fun = getmetatable(fun) == Event and fun or Event(fun)
@ -63,10 +79,10 @@ local f = assert(SMODS.load_file "src/lib/funky.lua")() or require "lib.funky"
--- Queues an event to be run. --- Queues an event to be run.
--- Note that events added this way implicitly `return true` unless you explicitly `return false`, unlike the vanilla ones. --- Note that events added this way implicitly `return true` unless you explicitly `return false`, unlike the vanilla ones.
--- @param fun (fun():false|nil)|Event The event or a function to run turn into an event. --- @param fun (fun():boolean?)|Event The event or a function to run turn into an event.
--- @param front boolean|nil `true` to add the event to the front of the queue, rather than the end. --- @param front? boolean `true` to add the event to the front of the queue, rather than the end.
local function q(fun, front) local function q(fun, front)
G.E_MANAGER:add_event(protect_ev(fun), nil, front) G.E_MANAGER:add_event(protect_ev(fun, SMODS.current_mod and 100), nil, front)
end end
--- Determines if a center is allowed to be usable. --- Determines if a center is allowed to be usable.

View file

@ -14,8 +14,12 @@ end
q(function() q(function()
-- Special shoutout to all contributors. <3 -- Special shoutout to all contributors. <3
---@type table<string, {name: string, fg: table, bg: table}> ---@type table<string, {name: string, fg: table, bg: table}>?
local contributors, mods = Bakery_API.contributors, SMODS.Mods local contributors = (Bakery_API or {}).contributors
if not contributors then
return true
end
contributors.Roland_aster = { contributors.Roland_aster = {
name = "asterSSH", name = "asterSSH",
@ -35,7 +39,7 @@ q(function()
bg = HEX "ff79c6ff", bg = HEX "ff79c6ff",
} }
if mods.DebugPlus and mods.Roland.config.import_funky then if SMODS.Mods.DebugPlus and SMODS.Mods.Roland.config.import_funky then
_G.f, _G.q, _G.u = unpack(qol) _G.f, _G.q, _G.u = unpack(qol)
end end
end, true) end, true)

View file

@ -147,7 +147,7 @@ spectral {
end, end,
} }
local void = spectral { spectral {
key = "void", key = "void",
pronouns = "it_its", pronouns = "it_its",
artist = "aster", artist = "aster",
@ -205,7 +205,3 @@ local void = spectral {
} }
end, end,
} }
q(function()
void.hidden = not SMODS.Mods.Cryptid
end)

View file

@ -130,13 +130,15 @@ function get_blind_amount(ante, ...)
end end
q(function() q(function()
if not G.P_CENTERS.c_Bakery_Scribe then local scribe = G.P_CENTERS.c_Bakery_Scribe
return
if not scribe then
return true
end end
local orig_can_use = G.P_CENTERS.c_Bakery_Scribe.can_use local orig_can_use = scribe.can_use
function G.P_CENTERS.c_Bakery_Scribe.can_use(...) function scribe.can_use(...)
return orig_can_use(...) and return orig_can_use(...) and
(SMODS.Mods.Roland.config.scribable_basket or f(G.jokers.highlighted):all(function(v) (SMODS.Mods.Roland.config.scribable_basket or f(G.jokers.highlighted):all(function(v)
return v.config.center.key ~= "j_Roland_basket" return v.config.center.key ~= "j_Roland_basket"