Jump to content

Upgraded graft img is always overridden

Recommended Posts

I'm surprised no one's run into this yet, but not even the example mods have upgraded grafts, so:

Making modded grafts goes well enough until you make an upgraded form, a _plus form. If you specify an "img =" field, even if you're absolutely perfect with the filename, all you'll get is the dreaded Pink Square. Why?

I blame Content.AddGraft. Specifically this first bit here.

local function AddGraft( id, graft_def )
    assert(id, "NO ID FOR GRAFT")

    graft_def.id = id

    local basic_id = graft_def.base_id or id:match( "(.*)_plus.*$" )
    if basic_id then
        UpgradeGraft( id, graft_def, basic_id )

    -- Generate conventional icon paths for non-upgraded cards. 
    if graft_def.img == nil or basic_id then
        local path
        if graft_def.type == GRAFT_TYPE.MUTATOR then
            path = string.format( "icons/mutators/%s.tex", id:lower() )
        elseif graft_def.type == GRAFT_TYPE.PERK then
            path = string.format( "icons/perks/perk_%s.tex", id:lower() )
            path = string.format( "icons/items/graft_%s.tex", graft_def.icon_override or id:lower() )
        graft_def.img = engine.asset.Texture( path, true )
        graft_def.img_path = graft_def.img and path
        if graft_def.img:IsDefault() then
            graft_def.img = global_images.default

Even if graft_def.img is not nil (as in it's specified by the file), if the graft has a basic_id (which it will by virtue of being a _plus), then the function will override the def's img by looking in the data/icons/items folder for a texture that likely won't exist.

If you're reusing existing textures (which I am for the most part), you can get around this by specifying an icon_override field instead of an img field. But for any modder trying to add a file from outisde data.zip? In its current form, I'm pretty sure they're out of luck right now.

Link to comment
Share on other sites

  • Developer

I've fixed this in the mainline currently, pending an update.  Grafts (including upgraded ones) can specify an img explicitly to use:

example_graft =
	name = "Example Graft",
	img = "icons/items/graft_whatever.tex",


Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

  • Create New...