From 32fef3feb4b4955b937a25bdceeb81548c354162 Mon Sep 17 00:00:00 2001 From: Wulgaren Date: Tue, 20 Jan 2026 21:27:10 +0100 Subject: [PATCH] Fix green joker simulation crash when extra field is indexed as table The base game's simulation code at card.lua:6801 attempts to index the 'extra' field as a table, but Cryptid's green_joker override sets extra to a number (1). This causes a crash: 'attempt to index field 'extra' (a number value)'. This fix adds a simulate function that: - Normalizes the extra field to a number before simulation - Handles cases where extra might be a table or nil - Returns proper simulation results so the base code doesn't need to access extra directly Fixes crash when simulating Green Joker effects. --- lib/cross-mod.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/cross-mod.lua b/lib/cross-mod.lua index 917c4fe00..54433d8a1 100644 --- a/lib/cross-mod.lua +++ b/lib/cross-mod.lua @@ -43,6 +43,25 @@ SMODS.Joker:take_ownership("green_joker", { } end end, + simulate = function(self, joker_obj, context) + -- Ensure extra is a number before simulation to prevent indexing errors + -- The base game code may try to access extra as a table, so we normalize it first + if joker_obj and joker_obj.ability then + if type(joker_obj.ability.extra) == "table" then + -- If extra was somehow converted to a table, extract the value + joker_obj.ability.extra = joker_obj.ability.extra.value or joker_obj.ability.extra.mult or 1 + elseif joker_obj.ability.extra == nil then + joker_obj.ability.extra = 1 + end + end + -- Provide simulation results + if context.joker_main then + return { + mult_mod = (joker_obj.ability.mult or 0), + } + end + return nil + end, loc_txt = {}, }, true)