#is something like what you mean? so then
1 messages · Page 1 of 1 (latest)
Not quite (new_mult is a number (or a talisman table)). What are you trying to do here?
ill send the joker effect if it'll help?
so im trying to have a variable that stores the total mult before it changes, and a variable that stores the total mult after it changes. then i get the difference of the two numbers and add it to my chip count
rrright
the thing is i dont know when im supposed to call mult_postloss to store the mult at that point, which is why i was asking how to get the change earlier
oh no,,,,
Here's what we'd do:
- Keep track of the last known mult from
mod_mult() - After
mod_mult(), if there was a decrease, trigger jokers in a custom context - At the end of scoring, reset the last known mult
right okay
from what i have at the moment what would i have to change to start witht that
This is what we'd do. Do you understand how this works?
--[[
Mult Decrease scoring context by BakersDozenBagels.
Replace `My_Mod_Id` with your mod ID.
When mult decreases, triggers all Jokers with `context = { My_Mod_Id_mult_decrease = decrease_amount }`
--]]
local last_mult = 0
local raw_mod_mult = mod_mult
-- mod_mult is used after any mult change to apply effects like Rich Get Richer
function mod_mult(...)
local new_mult = raw_mod_mult(...)
if new_mult < last_mult then
for i = 1, #G.jokers.cards do
G.jokers.cards[i]:calculate_joker({
My_Mod_Id_mult_decrease = last_mult - new_mult,
})
end
end
last_mult = new_mult
return new_mult
end
-- Reset our tracker at the end of the round so we don't see a fake decrease
local raw_G_FUNCS_evaluate_play = G.FUNCS.evaluate_play
function G.FUNCS.evaluate_play(...)
raw_G_FUNCS_evaluate_play(...)
last_mult = 0
end
i can try to hold on
let me use my 12-day old lua brain and comprehend
sure
so it
- creates a variable called
last_mult - creates a second variable and assigns it the value of the current GLOBAL mod_mult
then within a function using the global mult mod as a point of origin,
- creates a variable and sets it equal to something going on with the local mod_mult
then if that variable is less than the value of last_mult,
- it sets ANOTHER variable equal to the difference between
last_multandnew_mult - then regardless of whether that last if was true or not it sets
lastequal tonew - then it returns
new_mult
as for that last bit at the end it looks like it
- creates a variable to pull the global value of the evaluate_play function
then within the global evaluation function
- it does something or other with the local value and resets
last_mult
at least that's my guess
so what a hook does: it replaces a function (usually one from the base game) but still uses the original. In this case, we're just doing something after to original function is called (but we don't really care about what that function is doing, in particular)
this is all that's happening with the fluff removed: (note that this won't run)
local last_mult = 0
function after_mult_changes(new_mult)
if new_mult < last_mult then
trigger_every_joker_with({ My_Mod_Id_mult_decrease = last_mult - new_mult })
end
last_mult = new_mult
end
function after_evaluate_play()
last_mult = 0
end
ohhhhhhhhhhhhhhhhhhhhh
so then do i still need the preloss postloss setup in calculate? or would i just change it
at this point your Joker doesn't need to worry about it at all
it'd just need to check for the existence of My_Mod_Id_mult_decrease
ok iâve got everything else
where do i check for this without imploding something?
Just in the calculate function
like âif [decreasevariable]â?
actually wait no itâs a number value that wonât work whoops
oh i was right nvm then phew
even 0 is truthy
calculate = function (self, card, context)
if context.joker_main then
SMODS.calculate_effect(context.blueprint_card or card, {
} )
card.ability.extra.chips = card.ability.extra.mult_preloss - card.ability.extra.mult_postloss
return{
chips = card.ability.extra.chips,
card = card
}
end
if context.hyperfixation_mod_mult_decrease and not context.blueprint_card then
card.ability.extra.chips = card.ability.extra.chips + card.ability.extra.chip_gain
return{
message = 'Soul...',
colour = G.C.CHIPS,
card = card
}
end
end
or should i have left context.before and just put and
you shouldn't need this, since you're handling it elsewhere
SMODS.calculate_effect(context.blueprint_card or card, {})
card.ability.extra.chips = card.ability.extra.mult_preloss - card.ability.extra.mult_postloss
and card.ability.extra.chip_gain should just be context.hyperfixation_mod_mult_decrease
but otherwise this looks correct
i literally just forgot to delete it lmfao
lmoa
and then i dont need to add it the config do i
since it alr exists
it's just chips in there
yep
config = {
extra = {
chips = 0
}
},
loc_vars = function (self, info_queue, card)
return{vars = {
card.ability.extra.chips
}}
end,
just making sure
same thing with loc vars right
ye
tested it with like the one boss that does it (the flint) and it works!
i will forever be grateful for your help
hey so i dont know if you pay attention to this old thing anymore, but since it's about the same function i figured i'll just say it again in here. now that i'm trying to get the jokers to support talisman, the hook function breaks.
specifically, at if new_mult < last_mult then as it's trying to compare a table with a number.
i know it's a talisman thing specifically, since talisman converts the entire mult system into a table. (plus i tested with it off and it worked fine) do you know what i'd have to do here to fix this?
you could check type(last_mult) == "table", and if so use the talisman comparison function
got it
let me try and figure that out rq
wait why last_mult?
that gets set to 0 at the beginning, while new_multgets set to the function of raw_mod_mult
actually i should
--mult-decrease scoring context designed by BakersDozenBagels below!
local last_mult = 0
local raw_mod_mult = mod_mult
-- mod_mult is used after any mult change to apply effects like Rich Get Richer
function mod_mult(...)
local new_mult = raw_mod_mult(...)
if new_mult < last_mult then
for i = 1, #G.jokers.cards do
G.jokers.cards[i]:calculate_joker({
hyperfixation_mod_mult_decrease = last_mult - new_mult,
})
end
end
last_mult = new_mult
return new_mult
end
-- Reset our tracker at the end of the round so we don't see a fake decrease
local raw_G_FUNCS_evaluate_play = G.FUNCS.evaluate_play
function G.FUNCS.evaluate_play(...)
raw_G_FUNCS_evaluate_play(...)
last_mult = 0
end
shouldve done that sooner actually whoops
OH CAUSE IT GETS SET TO NEW AT THE END DUH
i may be stupid
would that be placed up in this to_big function up top?
to_big = to_big or function(a)
return a
end
or would i be doing that check in the middle of the hook?
i'd do it in the middle (because iirc __lt doesn't work in Lua 5.1)
mmm ok
ok wait can you dumb down what you mean a little by this though
i might get the gist but not the executino
on
so when Talisman exists, the mult numbers might be tables (instead of numbers). In Lua 5.1, < doesn't work on tables, so instead you can check if either of the numbers is a table (or both if you want to be safe) and if so use the Talisman comparison instead of the normal one
yeah that's the part i dont get
what part of it would i check to see if there's any tables
like the specific line that causes the crash is if new_mult < last_mult then
would i put some sort of system on that line?
yep, exactly
as an overview it'd become something like if (<Talisman> and <Talisman Comparison>) or (not <Talisman> and a < b) then
oh wow really
ok let me see then
wait i mean
if (to_big and to_big(1)) or (not to_big and new_mult < last_mult) then
yeah?
instead of to_big(1), use to_big(new_mult):lt(to_big(last_mult))
you still want to compare, just not using <
__lt (the underscores are important) is something in a metatable that makes < work
ohhhhh
Num:lt() is a normal function
ok ok i got it i see
nvm that sucks
if (to_big and to_big(new_mult):lt(to_big(last_mult))) or (not to_big and new_mult < last_mult) then
like that right
ye
ive been trying to fix the talisman compatibilty after the steamodded and talisman updates,
i was advised to store the last mult there on that line (i already have the joker check)
what's the best way to store it? from what ive been told :lt isnt necessary anymore
this should already be correct (just by looking at it)
okay but it doesnât work
have you tried testing it in-game?
thatâs how i know it doesnât work lmfao
iâll send what it looks like as a whole rn
SMODS.Joker{ --Cyanosis/Blue Baby
key = 'cyanosis',
config = {
extra = {
chips = 0
}
},
rarity = 1,
atlas = 'IsaacJokers',
pos = {x = 4, y = 1},
cost = -1,
unlocked = false,
discovered = false,
blueprint_compat = true,
eternal_compat = true,
perishable_compat = true,
loc_vars = function (self, info_queue, card)
return{vars = {
card.ability.extra.chips
}}
end,
calculate = function (self, card, context)
if context.joker_main then
return{
chips = card.ability.extra.chips,
card = card
}
end
if context.hyperfixation_mod_mult_decrease and (to_big(card.ability.extra.chips) > to_big(1)) and not context.blueprint_card then
card.ability.extra.chips = card.ability.extra.chips + (context.hyperfixation_mod_mult_decrease * 10)
return{
message = 'Soul...',
colour = G.C.CHIPS,
card = card
}
end
end
} ]]
--mult-decrease scoring context designed by BakersDozenBagels below!
local last_mult = 0
local raw_mod_mult = mod_mult ]]
-- mod_mult is used after any mult change to apply effects like Rich Get Richer
function mod_mult(...)
local new_mult = raw_mod_mult(...)
if to_big(new_mult) < to_big(last_mult) then
for i = 1, #G.jokers.cards do
if G.jokers.cards[i].config.center_key == 'j_hpfx_cyanosis' then
G.jokers.cards[i]:calculate_joker({
hyperfixation_mod_mult_decrease = last_mult - new_mult,
})
end
end
end
last_mult = new_mult
return new_mult
end ]]
-- Reset our tracker at the end of the round so we don't see a fake decrease
local raw_G_FUNCS_evaluate_play = G.FUNCS.evaluate_play
function G.FUNCS.evaluate_play(...)
raw_G_FUNCS_evaluate_play(...)
last_mult = 0
end
try just moving last_mult = new_mult to right above local new_mult = raw_mod_mult(...)? that's what the other person is suggesting
well it just wont trigger
unless this is the version where it crashes
hold on
it's the version where it crashes
which line is that?
if to_big(new_mult) < to_big(last_mult) then
the one we used to have also crashed it though
curse/blessing of an updated smods ig
i took the og one to the guys in modding-dev and basically reduced it to what you see here
i ve also since moved the conversion function to the main file
could that be a factor actually
whole crash btw my bad
ah, this is without talisman
wait is it
hold on
oh yeah that was the other thing
the old code ended up making talisman a dependency instead of a compatibility
you can put to_big = to_big or function(...) return ... end somewhere to polyfill the function
i.e. to make it work with or without talisman
oh so instead of a
this is just defining the function if it doesn't exist
yeah what we had before was the same thing but with a instead of ...
yeah
fixing
also gonna try it with talisman ON before i fix that
ok THATS the one where Does nothing? occurs
adding the ellipsis ix
fix
still no chip gain...
Is it adding the chips but not showing a message?
no it just isnt adding them
so the values can use talisman?
check the recent messages in the Talisman thread hold on
as it stands you're only increasing the chips if the chips are at least 1
and it starts out at 0, so you never add chips
a solid 72% of programming is stupid tiny mistakes that break everything and take hours to find
you'll recover eventually :3
part of me is hoping it doesnât work is that weird
that's not weird
âbut why does it work for my other guy?â i was going to say
it starts
with chips
and mult
itâs totally gonna work isnât it đ
wait so i just change it to 0 right
i'd get rid of that whole condition
oh
why even check at all
will it still work with talisman without it
it should
i.e. if context.hyperfixation_mod_mult_decrease and (to_big(card.ability.extra.chips) > to_big(1)) and not context.blueprint_card then -> if context.hyperfixation_mod_mult_decrease and not context.blueprint_card then
(which shouldn't change compatibility)
askjldghalksdfgjhaldsfg
is it something with the hook maybe?
you can spam log messages everywhere (temporarily) to see what's going on
oh you also mistyped center.key as center_key
sendInfoMessage(message, "Logger Name")
doesn't matter a lot, i'd do "Hyperfixation"
well it's whatever you're logging
so if i said sendInfoMessage(mod_mult, âHyperfixationâ)
ye
move the last_mult = new_mult back to where it was
oh ok
but yes that should be fine
oh you can't put something after the return
sounds good
that's the first one (with mod_mult). use a string there instead (like "mod_mult called")
also the one with hyperfixation_mod_mult_decrease will just log nil
mhm
did you by chance remove the return value
nope
hmm
what's the diagnosis, doc? 
I Don't Know, Sorry
aw man
@stoic ferry do you remember cyanosis? the guy with the mult context you made so i could get him working? sorry if this is too random for you, it just uhhh isnt gaining chips anymore and i dont know why
obv i didnt wanna just send it out randomly so i just went to the old thread
yeah but it's kinda annoying
is it something you're willing to help with? alright if you arent
oh wow sorry about that

