#xmult on stone card destroy
1 messages · Page 1 of 1 (latest)
xmult on stone card destroy
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
you'll need to do what canio does and use a for loop to check each of the removed cards
so that
for _, removed_card in ipairs(context.removed) do if removed_card:is_face() then face_cards = face_cards + 1 end end
section?
yep
and then you can replace the removed_card:is_face() part with the has_enhancement thing
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
OH i do see that
but you can rename it to stone_cards or something
i see i see
if you rename it you'll have to replace it everywhere face_cards is used
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
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
OH only one more question. how do i get the mult live-updating in the description?
so that gets into localization
have you set up a localization file yet
how much have you made for your mod so far
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
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',
}
}
},
},
},
}
yeah i did see that much
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
yeah i saw that too :] thank you though
(things like consumables and enhancements and everything else use something other than j_)
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
this one
gotcha!
last thing i need to figure out before i work on my own, is how to do the live-updating mult description
right
is that gonna use the "#1#" thing?
yeah
i seeeee i see okay
and those get filled in by the loc_vars function on your joker
https://github.com/Steamodded/smods/wiki/Localization#loc_vars
(which there is an example of in that canio code)
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
can you show the main mod file when you get the chance?
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"
}```
alrighty i am now home from work
trying to go over this and see what the issue is, and i'm not finding anything that is calling on a nil value
@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
@proud canopy since ya offered- i'm being thrown this error, and all of my mod's code is posted below
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
you are so goated. gonna give this a try
well, now i'm getting a different error from my localization file so ill try and fix that LMFAOOO
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 💔
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
np bruh
sorry I'm at work, I'll be around in like an hour. Don't feel bad about the ping, I'm happy to help :)
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!
awesome, glad to hear it
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
aw thanks, very kind of you
well nevertheless I'll be around in a bit if you have questions
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