#xmult on stone card destroy

1 messages · Page 1 of 1 (latest)

old igloo
#

let's just do this

#

@west falcon

west falcon
#

sure LOL

#

anyways

old igloo
#

xmult on stone card destroy

west falcon
#

so far all i have rn for the code is just
calculate = function(self, card, context) if context.remove_playing_cards and not context.blueprint then return { } end end
so where in there would the SMODS.has_enhancement(removed_card, "m_stone") go? would that go in place of the "if and not then" line or would that go in the area between it & return

old igloo
#

you'll need to do what canio does and use a for loop to check each of the removed cards

west falcon
#

so that
for _, removed_card in ipairs(context.removed) do if removed_card:is_face() then face_cards = face_cards + 1 end end
section?

old igloo
#

yep

#

and then you can replace the removed_card:is_face() part with the has_enhancement thing

west falcon
#

i see, okay

#

what would i do about that "face_cards = face_cards + 1" part?

old igloo
#

yeah I was just about to say, see how on line 4760 they create a local variable to count the number of face cards destroyed? you'll need that too

west falcon
#

OH i do see that

old igloo
#

but you can rename it to stone_cards or something

west falcon
#

i see i see

old igloo
#

if you rename it you'll have to replace it everywhere face_cards is used

west falcon
#

so literally the whole
if context.remove_playing_cards and not context.blueprint then local face_cards = 0 for _, removed_card in ipairs(context.removed) do if removed_card:is_face() then face_cards = face_cards + 1 end end if face_cards > 0 then card.ability.extra.xmult = card.ability.extra.xmult + face_cards * card.ability.extra.xmult_gain return { message = localize { type = 'variable', key = 'a_xmult', vars = { card.ability.extra.xmult } } } end
section can just be "stone_cards" replaced, plus the replacement of the has_enhancement thing

old igloo
#

I mean your card is basically canio for stone cards

#

so it makes sense

west falcon
#

yeah thats the idea lol

#

ill give it a try to see if i can get the rest of the way

old igloo
#

you'll also need that bit at the end so that the joker actually applies its xmult during scoring, otherwise it'll just increase it and never get scored lol

west falcon
#

OH only one more question. how do i get the mult live-updating in the description?

old igloo
#

so that gets into localization

#

have you set up a localization file yet

#

how much have you made for your mod so far

west falcon
#

i have my assets & src folders, my json and my lua, i forgot to make my localization one tho

#

getting it made rn

#

okay folder & file made

old igloo
#

so here's the template they have for jokers on the wiki

return {
    descriptions = {
        -- this key should match the set ("object type") of your object,
        -- e.g. Voucher, Tarot, or the key of a modded consumable type
        Joker = {
            -- this should be the full key of your object, including any prefixes
            j_mod_joker = {
                name = 'Name',
                text = {
                    'This is the first line of this description',
                    'This is the second line of this description',
                },
                -- only needed when this object is locked by default
                unlock = {
                    'This is a condition',
                    'for unlocking this card',
                },
            },
            -- multiple description box example
            j_mod_multi_joker = {
                name = 'Name',
                text = {
                    {
                       'First line of box 1',
                       'Second line of box 1',
                    },
                    {
                       'First line of box 2',
                       'Second line of box 2',
                    }
        }
            },
        },
    },
}
west falcon
#

yeah i did see that much

old igloo
#

a very important thing to know about how your mod's data is stored internally is that any time you need your (joker/enhancement/edition/etc)'s key, what you actually put is something like j_modprefix_key

#

the j_ says this key belongs to a joker, modprefix is whatever you put in the mod json, and then key is whatever you put for key = in your joker

west falcon
#

yeah i saw that too :] thank you though

old igloo
#

(things like consumables and enhancements and everything else use something other than j_)

west falcon
#

so since my key is set to "rgrt", my full key for that joker (since its internal name is 'mach') would be 'j_rgrt_mach'?

#

or would it just be rgrt_mach

west falcon
#

gotcha!

#

last thing i need to figure out before i work on my own, is how to do the live-updating mult description

old igloo
#

right

west falcon
#

is that gonna use the "#1#" thing?

old igloo
#

yeah

west falcon
#

i seeeee i see okay

old igloo
#

(which there is an example of in that canio code)

west falcon
#

excellent. time to test this before i go to bed

#

well that aint a good sign

#

...wait that's in my main mod file lua wtf

#

it didnt have any issues beforehand, and i didnt edit it since then
hm

#

genuinely no clue whats causing this 😔

#

i gotta get ready for bed since i do have work in the morning but i will post my code for both the joker itself & its localization

#

jokers.lua:

    -- Key for code to find it with
    key = "RegretMod",
    -- The name of the file, for the code to pull the atlas from
    path = "Regretevator.png",
    -- Width of each sprite in 1x size
    px = 71,
    -- Height of each sprite in 1x size
    py = 95
}

-- Mach
SMODS.Joker {
    key = 'mach',

    loc_txt = {
        name = 'Mach',
        text = {
            "{C:white,X:mult} X#1# {} Mult"
        }
    },

    config = { extra = { xmult = 1, xmult_gain = 1.5 } },
    loc_vars = function(self, info_queue, card)
        return { vars = { card.ability.extra.xmult_gain, card.ability.extra.xmult } }
    end,

    rarity = 1,
    atlas = 'RegretMod',
    pos = { x = 0, y = 0 },
    soul_pos = { x = 0, y = 1},
    cost = 7,

    unlocked = true,
    discovered = true,
    blueprint_compat = true,

    calculate = function(self, card, context)
        if context.remove_playing_cards and not context.blueprint then
            local stone_cards = 0
            for _, removed_card in ipairs(context.removed) do
                if SMODS.has_enhancement(removed_card, "m_stone") then stone_cards = stone_cards + 1 end
            end
            if stone_cards > 0 then
                card.ability.extra.xmult = card.ability.extra.xmult + stone_cards * card.ability.extra.xmult_gain
                return { message = localize { type = 'variable', key = 'a_xmult', vars = { card.ability.extra.xmult } } }
            end
            if context.joker.main then
                return {
                    xmult = card.ability.extra.xmult
                }
        end
    end,
}```
#

default.lua:

    descriptions = {
        Joker = {
            j_rgrt_mach = {
                ['name'] = '{C:edition,E:2}Mach{}'
                ['text'] = {
                    "This Joker gains {X:mult,C:white} X#1# Mult",
                    "when a {C:attention}stone{} card",
                    "is destroyed",
                    "{C:inactive}(Currently {X:mult,C:white} X#2# {C:inactive} Mult)",
                },
            },
        },
    }
},```
#

made them actually readable hopefully

#

oh i think i see at least one thing i screwed up

#

wait nvm nope. im still lost lmao

old igloo
west falcon
#

the “regretevator.lua” file mentioned? yeah one sec

#

regretevator.lua (this is mostly stitched together from what i found in another joker mod, but it wasn't giving me issues till i started messing with mach's functionality)


to_number = to_number or function(x)
    return x
end

contains = function(table, item)
    for k, v in pairs(table) do
        if v == item then
            return true
        end
    end
    return false
end```

----

regretevator.json

```{
    "id": "RegretMod",
    "name": "Regretevator",
    "author": ["ActuallyBinaryProto"],
    "description": "A mod that adds Regretevator-themed Jokers to Balatro!",
    "prefix": "rgrt",
    "main_file": "regretevator.lua",
    "badge_colour": "008000",
    "version": "0.0.1"
}```
west falcon
#

alrighty i am now home from work

west falcon
#

trying to go over this and see what the issue is, and i'm not finding anything that is calling on a nil value

west falcon
#

@old igloo apologies for the ping but if you end up bein available within the next few hrs to look at this stuff lmk :] you have been immensely helpful and i appreciate it a lot

west falcon
proud canopy
# west falcon <@773936558700232724> since ya offered- i'm being thrown this error, and all of ...
    if context.remove_playing_cards and not context.blueprint then
        local stone_cards = 0
        for _, removed_card in ipairs(context.removed) do
            if SMODS.has_enhancement(removed_card, "m_stone") then
                stone_cards = stone_cards + 1
            end
        end
        if stone_cards > 0 then
            card.ability.extra.xmult = card.ability.extra.xmult + stone_cards * card.ability.extra.xmult_gain
            return {
                message = localize {
                    type = 'variable',
                    key = 'a_xmult',
                    vars = { card.ability.extra.xmult }
                }
            }
        end
        if context.joker.main then
            return {
                xmult = card.ability.extra.xmult
            }
        end
    end -- This was missing!
end,```
#

oopsies

#

idk try this

#

AND REMOVE THE COMMAS I PUT AT THE BEGINNING AND END

west falcon
#

you are so goated. gonna give this a try

west falcon
proud canopy
#

lol

#

the unbearable life of a coder

#

the sisyphean endeavor

west falcon
#

well now im getting

[SMODS _ "src/utils.lua"]:191: [SMODS RegretMod "localization/default.lua"]:6: '}' expected (to close '{' at line 4) near '['```
#

my localization file looks like

#
    descriptions = {
        Joker = {
            j_rgrt_mach = {
                ['name'] = '{C:edition,E:2}Mach{}'
                ['text'] = {
                    "This Joker gains {X:mult,C:white} X#1# Mult",
                    "when a {C:attention}stone{} card",
                    "is destroyed",
                    "{C:inactive}(Currently {X:mult,C:white} X#2# {C:inactive} Mult)",
                }
            }
        }
    }
}```
#

am i just like. being stupid rn

#

did i miss smth

#

@proud canopy i am so sorry for repeatedly harassing you 💔

proud canopy
#

nah ur good bruh

#
    descriptions = {
        Joker = {
            j_rgrt_mach = {
                ['name'] = '{C:edition,E:2}Mach{}',
                ['text'] = {
                    "This Joker gains {X:mult,C:white} X#1# Mult",
                    "when a {C:attention}stone{} card",
                    "is destroyed",
                    "{C:inactive}(Currently {X:mult,C:white} X#2# {C:inactive} Mult)",
                }
            }
        }
    }
}```
#

u were missing a comma

west falcon
#

GODDDD

#

thank you 😭

proud canopy
#

np bruh

west falcon
#

IT WOOOORKS

#

it launches at least

proud canopy
#

YESSS

#

u should lowk stream

old igloo
west falcon
#

all good, and i solved the problems with pseudo's help!

#

i got Mach working!

#

buffed the 1.5 to 2 since stone cards are hard to come by

#

but otherwise this screenshot is accurate

#

and she functions!

old igloo
#

awesome, glad to hear it

west falcon
#

i credited you and pseudo at the end of the joker code for all yalls help btw

#

i will be doing that for everyone who helps me directly like yall have

old igloo
#

aw thanks, very kind of you

#

well nevertheless I'll be around in a bit if you have questions

west falcon
#

ill be actually going to sleep on time tonight so i dont think ill be doin anything else tn besides starting work on the revised texture