Skip to content
Sebastián Venturino edited this page Feb 8, 2025 · 19 revisions

JokerDisplay API Documentation

Getting Started

If you want to add support for another mod or edit how vanilla Jokers look, it's recommended that you first look at how Jokers are already defined in display_definitions.lua.

If you are adding support in your mod, first you want to check if the player has JokerDisplay installed and that the main JokerDisplay object is loaded.

if JokerDisplay then
    -- Definition code
end

It's also recommended to write the definitions in a separate file so they don't take too much space in your code. This can be done using SMODS.load_file.

if JokerDisplay then
    SMODS.load_file("joker_display_definitions.lua")()
end

Then either inside the conditional or in a separate file you have to define your Joker under JokerDisplay.Definitions using the Joker's key.

local jd_def = JokerDisplay.Definitions -- You can assign it to a variable to use as shorthand

jd_def["j_prefix_key"] = {
    -- Definition
}

From version 1.8.1 you can now do this if you don't want to have your definitions separated from your Joker initialization:

SMODS.Joker{
    -- Your code
    joker_display_def = function(JokerDisplay)
        return {
            -- Definition
        }
    end
}

Here's an example of how Bloodstone is defined so you can look at the general structure:

jd_def["j_bloodstone"] = {
    text = {
        { ref_table = "card.joker_display_values", ref_value = "count", retrigger_type = "mult" },
        { text = "x",                              scale = 0.35 },
        {
            border_nodes = {
                { text = "X" },
                { ref_table = "card.ability.extra", ref_value = "Xmult" }
            }
        }
    },
    reminder_text = {
        { text = "(" },
        { ref_table = "card.joker_display_values", ref_value = "localized_text", colour = lighten(G.C.SUITS["Hearts"], 0.35) },
        { text = ")" }
    },
    extra = {
        {
            { text = "(" },
            { ref_table = "card.joker_display_values", ref_value = "odds" },
            { text = ")" },
        }
    },
    extra_config = { colour = G.C.GREEN, scale = 0.3 },
    calc_function = function(card)
        local count = 0
        if G.play then
            local text, _, scoring_hand = JokerDisplay.evaluate_hand()
            if text ~= 'Unknown' then
                for _, scoring_card in pairs(scoring_hand) do
                    if scoring_card:is_suit("Hearts") then
                        count = count +
                            JokerDisplay.calculate_card_triggers(scoring_card, scoring_hand)
                    end
                end
            end
        else
            count = 3
        end
        card.joker_display_values.count = count
        card.joker_display_values.odds = localize { type = 'variable', key = "jdis_odds", vars = { (G.GAME and G.GAME.probabilities.normal or 1), card.ability.extra.odds } }
        card.joker_display_values.localized_text = localize("Hearts", 'suits_plural')
    end
}

Check the documentation for more info.

Clone this wiki locally