#is something like what you mean? so then

1 messages · Page 1 of 1 (latest)

stoic ferry
#

Not quite (new_mult is a number (or a talisman table)). What are you trying to do here?

icy dirge
#

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

stoic ferry
#

rrright

icy dirge
#

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

stoic ferry
#

yeah

#

you're going to have to do your own bookkeeping for it, unfortunately

icy dirge
#

oh no,,,,

stoic ferry
#

Here's what we'd do:

  1. Keep track of the last known mult from mod_mult()
  2. After mod_mult(), if there was a decrease, trigger jokers in a custom context
  3. At the end of scoring, reset the last known mult
icy dirge
#

right okay

#

from what i have at the moment what would i have to change to start witht that

stoic ferry
#

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
icy dirge
#

i can try to hold on
let me use my 12-day old lua brain and comprehend

stoic ferry
#

sure

icy dirge
#

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_mult and new_mult
  • then regardless of whether that last if was true or not it sets last equal to new
  • 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

stoic ferry
#

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
icy dirge
#

ohhhhhhhhhhhhhhhhhhhhh

#

so then do i still need the preloss postloss setup in calculate? or would i just change it

stoic ferry
#

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

icy dirge
#

oh wow thats awesome

#

gonna edit the calculate function rq

icy dirge
stoic ferry
#

Just in the calculate function

icy dirge
#

like “if [decreasevariable]”?

#

actually wait no it’s a number value that won’t work whoops

stoic ferry
#

yeah, just if context.My_Mod_Id_mult_decrease then ... end

#

numbers are truthy

icy dirge
#

oh i was right nvm then phew

stoic ferry
#

even 0 is truthy

icy dirge
#
    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

stoic ferry
#

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

icy dirge
stoic ferry
#

lmoa

icy dirge
#

and then i dont need to add it the config do i

#

since it alr exists

#

it's just chips in there

stoic ferry
#

yep

icy dirge
#
    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

stoic ferry
#

yep

#

loc_vars only needs the things you're displaying anyways

icy dirge
#

thought so but i jsut wanted to make sure

#

i guess moment of truth then right

stoic ferry
#

ye

icy dirge
#

tested it with like the one boss that does it (the flint) and it works!

#

i will forever be grateful for your help

stoic ferry
#

awesome!

#

love to hear it

icy dirge
# stoic ferry ye

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?

stoic ferry
#

you could check type(last_mult) == "table", and if so use the talisman comparison function

icy dirge
#

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

icy dirge
#

or would i be doing that check in the middle of the hook?

stoic ferry
#

i'd do it in the middle (because iirc __lt doesn't work in Lua 5.1)

icy dirge
#

mmm ok

icy dirge
#

i might get the gist but not the executino

#

on

stoic ferry
#

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

icy dirge
#

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?

stoic ferry
#

yep, exactly

#

as an overview it'd become something like if (<Talisman> and <Talisman Comparison>) or (not <Talisman> and a < b) then

icy dirge
#

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?

stoic ferry
#

instead of to_big(1), use to_big(new_mult):lt(to_big(last_mult))

#

you still want to compare, just not using <

icy dirge
#

wait but i thought lt didnt work

#

or is this different

stoic ferry
#

__lt (the underscores are important) is something in a metatable that makes < work

icy dirge
#

ohhhhh

stoic ferry
#

Num:lt() is a normal function

icy dirge
#

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

stoic ferry
#

ye

icy dirge
#

ok then

#

moment of truth 2!

#

it works!!

#

tysm again

icy dirge
stoic ferry
icy dirge
#

okay but it doesn’t work

stoic ferry
#

have you tried testing it in-game?

icy dirge
#

that’s how i know it doesn’t work lmfao

stoic ferry
#

loam

#

uhhhhh

icy dirge
#

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
stoic ferry
#

try just moving last_mult = new_mult to right above local new_mult = raw_mod_mult(...)? that's what the other person is suggesting

icy dirge
#

is that really it

#

cause new_mult isnt defined yet

stoic ferry
#

yyyeah

#

uh what flavor of "not working" is it?

icy dirge
#

well it just wont trigger

#

unless this is the version where it crashes

#

hold on

#

it's the version where it crashes

stoic ferry
#

which line is that?

icy dirge
#

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

icy dirge
stoic ferry
#

ah, this is without talisman

icy dirge
#

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

stoic ferry
#

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

stoic ferry
#

this is just defining the function if it doesn't exist

icy dirge
#

yeah what we had before was the same thing but with a instead of ...

stoic ferry
#

yeah

icy dirge
#

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...

stoic ferry
#

Is it adding the chips but not showing a message?

icy dirge
#

no it just isnt adding them

stoic ferry
#

hmmm

#

hey what did you mean by (to_big(card.ability.extra.chips) > to_big(1))

icy dirge
#

so the values can use talisman?

#

check the recent messages in the Talisman thread hold on

stoic ferry
#

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

icy dirge
#

no way it’s that easy

#

you’re lying

#

dont do this to me

stoic ferry
#

a solid 72% of programming is stupid tiny mistakes that break everything and take hours to find

#

you'll recover eventually :3

icy dirge
#

part of me is hoping it doesn’t work is that weird

stoic ferry
#

that's not weird

icy dirge
#

“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

stoic ferry
#

i'd get rid of that whole condition

icy dirge
#

oh

stoic ferry
#

why even check at all

icy dirge
#

will it still work with talisman without it

stoic ferry
#

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)

icy dirge
#

i got it dw

#

it didn’t work GUMI_CAN_FINALLY

#

but also it didn’t work imsickofyourshitbrother

stoic ferry
#

askjldghalksdfgjhaldsfg

icy dirge
#

is it something with the hook maybe?

stoic ferry
#

you can spam log messages everywhere (temporarily) to see what's going on

#

oh you also mistyped center.key as center_key

icy dirge
#

WHAT

#

ok so

#

how do i set up a log message again

#

before i mess up

stoic ferry
#

sendInfoMessage(message, "Logger Name")

icy dirge
#

what do i put for logger name

#

just DebugPlus?

stoic ferry
#

doesn't matter a lot, i'd do "Hyperfixation"

icy dirge
#

real

#

and message is supposed to just be message right

stoic ferry
#

well it's whatever you're logging

icy dirge
#

so if i said sendInfoMessage(mod_mult, “Hyperfixation”)

stoic ferry
#

ye

icy dirge
#

ok cool

#

how's this

stoic ferry
#

move the last_mult = new_mult back to where it was

icy dirge
#

oh ok

stoic ferry
#

but yes that should be fine

icy dirge
#

why is the code red oh no

#

what's wrong here

stoic ferry
#

oh you can't put something after the return

icy dirge
#

oh ok

#

ill just move it behind then

stoic ferry
#

sounds good

icy dirge
#

oh it didn’t

#

like that

stoic ferry
#

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

stoic ferry
#

mhm

icy dirge
#

didnt send the full crash oops

stoic ferry
#

did you by chance remove the return value

icy dirge
stoic ferry
#

hmm

icy dirge
#

what's the diagnosis, doc? NAILS

stoic ferry
#

I Don't Know, Sorry

icy dirge
#

aw man

icy dirge
#

@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

stoic ferry
#

probably an SMODS update broke it

#

as smods tends to do

icy dirge
#

that

makes sens

#

are you any good with that sort of thing?

stoic ferry
#

yeah but it's kinda annoying

icy dirge
#

is it something you're willing to help with? alright if you arent

stoic ferry
#

not today at least

#

i am Exhausted

icy dirge
#

oh wow sorry about that