#For Each Joker Function

1 messages · Page 1 of 1 (latest)

weak coral
#

Hey everyone, im making a joker card that for each Joker of a specific type gives you some Mult, i tried this function but it crashes the game and it also uses SMODS.Joker rather than accesing which jokers the player currrently has which is obviously wrong but i dont know how to do it the right way, any help is appreciated!

update = function (self, card, dt)
card.ability.extra.shells = 0
for joker in SMODS.Joker do
if joker.key == "Shell" then
card.ability.extra.shells = card.ability.extra.shells + 1
end
end
end,

delicate hazel
#

Should probably not use the update function for that and have it be in the calculate function where the scoring actually happens, because that doesn't need to run every frame
Then, to get the owned jokers, you have G.jokers.cards; you can iterate over those instead
Or alternatively, #SMODS.find_card(joker), which just gives you the amount of jokers with that name (find_card gives you a list, the # gives the length of the list)
Then, I don't think you need to store that as a seperate variable, and can just multiply that with the mult in the calculate function and the locvars for the text
If you have any questions let me know :3

weak coral
#

it didnt work unfortunaly heres the function i wrote:

calculate = function(self, card, context)
card.ability.extra.shells = #SMODS.find_card("Shell")

    if context.joker_main then
        return {
            Xmult_mod = 1 + card.ability.extra.xmult * card.ability.extra.shells,
            message = localize { type = 'variable', key = 'a_xmult', vars = { 1 + card.ability.extra.xmult * card.ability.extra.shells } }
        }
    end
end
thorn plume
weak coral
delicate hazel
#

Also there's many different ways something can "not work", so it's helpful if you describe what's happening or what isn't happening Frog

weak coral
#

as the image showed its remaining at X1 mult, hope that helps, also i just realized i started this thread in the wrong channel

delicate hazel
#

Also, the joker key is j_[your mod prefix]_[jokey key], so shell probably won't find anything

weak coral
#

so in my case it would be j_crabro_Shell?

delicate hazel
#

Maybe? I don't know what the mod prefix and the joker key are set tto

thorn plume
# weak coral

You should define the multiplier in loc_vars, not config, as config is a static variable and does not change. Here's a sample I wrote from a mod I'm developing:

loc_txt = {
        name = "Wine",
        text = { -- the description text underneath the joker's name
            "Gives {C:mult}+10{} Mult",
            "per Ante beat",
            "{C:inactive}(Currently +#1# mult)"
        }
    },
    rarity = 2,
    loc_vars = function (self, info_queue, card)
        return {
            vars = {
                card.ability.extra
            }
        }
    end
#

In this context, card.ability.extra would equal 10*(G.GAME.round_resets.ante - 1)
If the Ante was 2, then the math would be 10*(2-1), which is 10.

delicate hazel
thorn plume
delicate hazel
thorn plume
delicate hazel
#

Yeah that's what it's there for, that's the placeholder. It's not defining anything, you're just passing the variable
I just got confused by the wording
Though, isn't that what they were already doing? Or am I missing something

weak coral
#

for anyone finding this thread in the future heres the final code i wrote:

SMODS.Joker {
    key = 'Hermit Crab',
    loc_txt = {
        name = 'Hermit Crab',
        text = {
            "{X:mult,C:white}X#1#{} Mult for each",
            "{C:attention}Shell Joker{}",
            "{C:inactive}(Currently {X:mult,C:white}X#2#{C:inactive})"
        }
    },

    config = { extra = { xmult = 2 } },

    loc_vars = function(self, info_queue, card)
        return { vars = { card.ability.extra.xmult, card.ability.extra.xmult * (1 + #SMODS.find_card("j_crabro_Shell")) } }
    end,

    rarity = 2,

    atlas = 'crabro',

    pos = { x = 1, y = 0 },

    cost = 6,

    calculate = function(self, card, context)
        if context.joker_main then
            return {
                Xmult_mod = card.ability.extra.xmult * (1 + #SMODS.find_card("j_crabro_Shell")),
                message = localize { type = 'variable', key = 'a_xmult', vars = { card.ability.extra.xmult * (1 + #SMODS.find_card("j_crabro_Shell")) } }
            }
        end
    end
}
delicate hazel
#

If you're just displaying the X mult as the message, you don't have to explicitly do that, if you return xmult then it automatically adds the message to it

thorn plume
weak coral
#

yep all works!

thorn plume
#

Okay, just wanted to check since you forgot to remove config

delicate hazel
#

Why would they remove config, they're using that?

thorn plume
delicate hazel
#

Loc vars isnt overriding anything though?

#

Theyre using the values from config and passing them into both the calculate and the loc vars