itayfeder / Fusion-Jokers

Fuse jokers into special powerful versions!
GNU General Public License v3.0
4 stars 5 forks source link

[Suggestion] Use string instead of index number for the Fusion rarity #1

Open ChromaPIE opened 5 months ago

ChromaPIE commented 5 months ago

So recently bug I'm facing is that the game crashes when resetting/creating new profile (crash log https://mclo.gs/LBsmICE) I'm no pro at this so I simply copied and pasted codes from Relic Jokers, which introduces two new rarities but uses strings for them, adjusted both Luas of Fusion Jokers and More Fluff (it adds a fusion joker) a little, used a string "fusion" instead, and got the crash fixed without breaking anything (hopefully).

english5040 commented 5 months ago

In case anyone's listening- the problem is that the manipulation of G.P_JOKER_RARITY_POOLS happens in INIT.FusionJokers(), it needs to happen at the end of init_item_prototypes(). (The game does init_item_prototypes after initializing Steamodded when you switch profiles for some reason. On startup it's the other order.)

Deleting table.insert(G.P_JOKER_RARITY_POOLS, {}) and table.insert(G.C.RARITY, HEX("F7D762")) and adding the following code at top level should just fix this issue:

local init_item_prototypes_ref = Game.init_item_prototypes
function Game:init_item_prototypes()
    init_item_prototypes_ref(self)
    table.insert(G.P_JOKER_RARITY_POOLS, {})
    table.insert(G.C.RARITY, HEX("F7D762"))
end

also I guess G.ARGS.LOC_COLOURS["fusion"] = HEX("F7D762") instead of G.ARGS.LOC_COLOURS["fusion"] = ...

ChromaPIE commented 5 months ago

Thanks for the workaround! but my point is I lowkey feel like it's basically planting an explosive for the future when you have way more mods to choose from. i dont know if internally there's any mod loading priority type of thing. if there do be something like that then i'm afraid if you load like 2, 3 or more mods adding their own custom rarities the 5 wouldn't be 5 anymore, so a string like "fusion" will be much safer, if you don't want to deal with mod compat issues.

ChromaPIE commented 5 months ago

@english5040 don't know what went wrong but I tried applying the given change, and it shows the inserting to a nil crash on entering the game

function SMODS.INIT.FusionJokers()
    local mod_id = "FusionJokers"
    local mod_obj = SMODS.findModByID(mod_id)

    local init_item_prototypes_ref = Game.init_item_prototypes
    function Game:init_item_prototypes()
        init_item_prototypes_ref(self)
        table.insert(G.P_JOKER_RARITY_POOLS, {})
        table.insert(G.C.RARITY, HEX("F7D762"))
    end

    loc_colour("mult", nil)
    G.ARGS.LOC_COLOURS["fusion"] = HEX("F7D762")

    ......
english5040 commented 5 months ago

oh, all the init_item_prototypes stuff has to go at top level (outside any function)

english5040 commented 5 months ago

and I think doing e.g. 'fusion' as the key is probably better in the long term, yeah! my code is honestly only to demonstrate what's going on. ideally, do both- use 'fusion' as the key and rearrange the code.

ChromaPIE commented 5 months ago

oop you actually said that sorry. thanks for the reply!

EDIT: well i moved it all the way to the top (under the mod info, of course) but still getting that crash. thats super weird

EDIT: I kept my way of fixing this, but again I'm not quite sure what some of the codes actually do except basic ones

function SMODS.INIT.FusionJokers()
    local mod_id = "FusionJokers"
    local mod_obj = SMODS.findModByID(mod_id)

    local SMODS_inject_jokers_ref = SMODS.injectJokers
    function SMODS.injectJokers()
        G.P_JOKER_RARITY_POOLS["fusionJokersFusion"] = {}
        local movedTable = G.P_JOKER_RARITY_POOLS["fusionJokersFusion"]
        table.insert(G.P_JOKER_RARITY_POOLS, 5, movedTable)
        SMODS_inject_jokers_ref()
    end

    loc_colour("mult", nil)
    G.C.RARITY[5] = HEX('F7D762')
    G.ARGS.LOC_COLOURS["fusion"] = G.C.RARITY[5]
......

i forced the new table to be at index 5 so i dont have to change the rest of the codes or even more fluff. I'll use it as a temp workaround for now to get me back to the gaming asap.