My mod crashes the game; is there anything I can do about it?


Recommended Posts

Okay it's not really a mod as it just adds a single looping function but idk what else to call it... I also wasn't sure whether to put it in bug reports or not because it involves the mod

I saw that there's a built-in function to export the game's textures to png files (thank you devs for adding it in, it makes things so much easier), but the only problem with it is that you can only do one tex file at a time and this gets really tedious after a while. I poked around the code and saw that there's another function that fetches all the data for cards, including the filepaths for their icons.

Long story short I was able to make a looping function that makes use of the game's built-in functions to batch-extract the negotiation card icons, but when I run it, the game crashes. I know the mod otherwise runs fine, because I can see the results of my "print" commands in the log file. I've attached it in the zip; any ideas? Let me know if I need to attach the log file too, as I'd like to remove some personally identifying information from it before uploading it.

Also, to clarify how I'm using it: I run the game in debug mode, press CTRL + TILDE (~) to bring up the debug console and enter "ExportIcons("negotiation")" into it.

GriftlandsExportIcons.zip

Link to comment
Share on other sites

I think that you can't do too many things in a frame. If a frame takes too long to run, it will crash the game.

I tried that before, and it's the same situation. The game crashes when I try to export everything in a given directory.

You should probably run it as a coroutine, though I have no idea how to do that.

Link to comment
Share on other sites

  • Developer

This is correct, internally the textures are queued to save over multiple frames.  However we also recently pooled render targets and so these will quickly run out if batch-exporting.

Until a more robust mechanism is in place, you could try forcing a delay between exports in your export_icons.lua like so:

function ExportIconsInternal(arg)
    local list = {}
    if arg == "negotiation" then
        for i, def in pairs( Content.GetAllNegotiationCards() ) do
            local icon = def.path_str
            local is_there = false
            for i, val in ipairs(list) do
                if icon == val then
                    is_there = true
                end
            end
            if is_there == false then --preventing duplicates
                table.insert(list, icon)
            end
        end
        for i, pic in pairs(list) do
            local name = string.gsub(pic, "negotiation/", '')
            print('Exporting ' .. '"'..pic..'"')
            UIHelpers.SaveTextureAsPNG(engine.asset.Texture(pic), pic)
            coroutine.yield( 0.1 )
            collectgarbage()
        end
    end
end

function ExportIcons(arg)
    TheGame.scheduler:DoCoroutine( 0.5, ExportIconsInternal, arg )
end

 

Link to comment
Share on other sites

13 minutes ago, rooks said:
Spoiler

 This is correct, internally the textures are queued to save over multiple frames.  However we also recently pooled render targets and so these will quickly run out if batch-exporting.

Until a more robust mechanism is in place, you could try forcing a delay between exports in your export_icons.lua like so:



function ExportIconsInternal(arg)
    local list = {}
    if arg == "negotiation" then
        for i, def in pairs( Content.GetAllNegotiationCards() ) do
            local icon = def.path_str
            local is_there = false
            for i, val in ipairs(list) do
                if icon == val then
                    is_there = true
                end
            end
            if is_there == false then --preventing duplicates
                table.insert(list, icon)
            end
        end
        for i, pic in pairs(list) do
            local name = string.gsub(pic, "negotiation/", '')
            print('Exporting ' .. '"'..pic..'"')
            UIHelpers.SaveTextureAsPNG(engine.asset.Texture(pic), pic)
            coroutine.yield( 0.1 )
            collectgarbage()
        end
    end
end

function ExportIcons(arg)
    TheGame.scheduler:DoCoroutine( 0.5, ExportIconsInternal, arg )
end

 

 

WOAH that was fast; thank you so much!!

Also, would it be okay to post the extracted images here in the forums? The art is to good to not share, in my opinion XD

Link to comment
Share on other sites

11 hours ago, minespatch said:

Would could use a Data mining thread for the Griftlands side of the forums.

I think I'll look into making one later, then, when I have the time. I already have all the sounds extracted (used different tools I already had on hand) so yeah it would be cool

As for now, uh

20200716091042_1.thumb.jpg.f258120ef57e08f3015bfccd01af4842.jpg

I gotta work out some of the bumps when trying to extract other textures...

Link to comment
Share on other sites

Archived

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.