Jump to content

Recommended Posts

I'm working on a character mod with a custom starting item, but when starting up DST to test it, none of the icons or information about the mod load and the mod is labeled as "mod crashed" and remains un-selectable. So far, removing everything involving the custom starting item still does not fix the mod crashing on start-up, however, it does load up icons/mod information and allows the mod to be selectable on the list - therefor usable in some form. The only thing I've noticed is the following on the program file console:

Traceback (most recent call last):
  File "..\..\Don't Starve Mod Tools\mod_tools\compiler_scripts\image_build.py", line 110, in <module>
    process_file_to_atlas()
  File "..\..\Don't Starve Mod Tools\mod_tools\compiler_scripts\image_build.py", line 74, in process_file_to_atlas
    im = imgutil.OpenImage( image, size=None, border_size=border_size )
  File "C:\Program Files (x86)\Steam\steamapps\common\Don't Starve Mod Tools\mod_tools\buildtools\windows\Python27\lib\site-packages\klei\imgutil.py", line 32, in OpenImage
    im = Expand( im, border_size )
  File "C:\Program Files (x86)\Steam\steamapps\common\Don't Starve Mod Tools\mod_tools\buildtools\windows\Python27\lib\site-packages\klei\imgutil.py", line 4, in Expand
    new_img = ImageOps.expand( im, border = border_size )
  File "C:\Program Files (x86)\Steam\steamapps\common\Don't Starve Mod Tools\mod_tools\buildtools\windows\Python27\lib\site-packages\PIL\ImageOps.py", line 240, in expand
    out.paste(image, (left, top))
  File "C:\Program Files (x86)\Steam\steamapps\common\Don't Starve Mod Tools\mod_tools\buildtools\windows\Python27\lib\site-packages\PIL\Image.py", line 1088, in paste
    im.load()
  File "C:\Program Files (x86)\Steam\steamapps\common\Don't Starve Mod Tools\mod_tools\buildtools\windows\Python27\lib\site-packages\PIL\ImageFile.py", line 215, in load
    raise_ioerror(e)
  File "C:\Program Files (x86)\Steam\steamapps\common\Don't Starve Mod Tools\mod_tools\buildtools\windows\Python27\lib\site-packages\PIL\ImageFile.py", line 52, in raise_ioerror
    raise IOError(message + " when reading image file")
IOError: unrecognized data stream contents when reading image file
ERROR: Command failed!

 

as far as the custom item, this is the code I have for it:

local assets = {
    Asset("ANIM", "anim/spider_gland_salve.zip"),
    
    Asset("ATLAS", "images/inventoryimages/medikit.xml"),
    Asset("IMAGE", "images/inventoryimages/medikit.tex"),
    
}

local function commonfn()
    local inst = CreateEntity()
    
    inst.entity:AddTransform()
    inst.entity.AddAnimState()
    inst.entity.AddNetwork()
    
    MakeInventoryPhysics(inst)
    
    inst.AnimState:SetBank("spider_gland_salve")
    inst.AnimState:SetBuild("spider_gland_salve")
    inst.AnimState:PlayAnimation("idle")
    
    MakeInventoryFloatable(inst, "small", 0.05, 0.95)
    
    inst.entity:SetPristine()
    
    if not TheWorld.ismastersim then
        return inst
    end
    
    inst.AddComponent("finiteuses")
    inst.components.finiteuses:SetMaxUses(TUNING.MEDIKIT_USES)
    inst.components.finiteuses:SetUses(TUNING.MEDIKIT_USES)
    inst.components.finiteuses:SetOnFinished(inst.Remove)
    
    inst:AddComponent("inspectable")
    inst:AddComponent("inventoryitem")
    inst.AddComponent("tradable")
    
    inst:AddComponent("healer")
    inst.components.healer:SetHealthAmount(TUNING.HEALING_MED)
    
    inst.components.inventoryitem.imagename = "medikit"
    inst.components.inventoryitem.atlasname = "images/inventoryimages/medikit.xml"
    
    MakeHauntableLaunch(inst)
    
    return inst

end

return Prefab("medikit", fn, assets)

I also have the following configurable options in ModInfo:

configuration_options = {

        {
        name = "Medikit_Difficulty",
        label = "Medkit Crafting Difficulty",
        hover = "Crafting recipe difficulty levels.",
        
        options = {
            {data="easy", description="Easy",
                hover = "2 Spiderglands, 1 Honey"},
            {data="default", description="Default",
                hover = "3 Spiderglands, 2 Honey"},
            {data="difficult", description="Hard",
                hover = "6 Spiderglands, 3 Honey"},
        },
        default = "default"

        {
        name = "medikituses",
        label = "Medkit Uses"
        
        options = {
            {description = "1", data = 1},
            {description = "2 (Default)", data = 2},
            {description = "3", data = 3},
            {description = "4", data = 4},
            {description = "5", data = 5},
            
        },
        default = 2,
}
 

and once more the custom item is called again in ModMain:

... (other assets are above this line)
Asset( "IMAGE", "images/inventoryimages/medikit.tex" ),
Asset( "ATLAS", "images/inventoryimages/medikit.xml" ),

}

local Recipe = GLOBAL.Recipe
local ACTIONS = GLOBAL.ACTIONS
local ActionHandler = GLOBAL.ActionHandler

TUNING.MEDIKIT_USES = GetModConfigData("medikituses")

--Medikit Recipe
local recipe_difficulty = GetModConfigData("Medikit_Difficulty")

--default
if recipe_difficulty == "default" then
local medikitrecipe = AddRecipe ("medikit", {Ingredient("spidergland", 3), Ingredient("honey", 2)}, GLOBAL.RECIPETABS.WAR, GLOBAL.TECH.SCIENCE_ONE, nil, nil, nil, nil, "dwight", "images/inventoryimages/medikit.xml")
medikitrecipe.sortkey = -4
--easy
elseif recipe_difficulty == "easy" then
local medikitrecipe = AddRecipe("medikit", {Ingredient("spidergland", 2), Ingredient("honey", 1), GLOBAL.RECIPETABS.WAR, GLOBAL.TECH.NONE, nil, nil, nil, nil, "dwight", "images/inventoryimages/medikit.xml")
medikitrecipe.sortkey = -4

--difficult
elseif recipe_difficulty == "difficult" then
local medikitrecipe = AddRecipe("medikit", {Ingredient("spidergland", 6), Ingredient("honey", 3), GLOBAL.RECIPETABS.WAR, GLOBAL.TECH.SCIENCE_TWO, nil, nil, nil, nil, "dwight", "images/inventoryimages/medikit.xml")
medikitrecipe.sortkey = -4

end

I'm not sure if I'm forgetting some other place that the medikit item needs to be placed into code, but I do have the image files (.PNG, .TEX, .XML)  located in a new folder called "inventoryitems"

Basically I'm trying to make a medkit that heals you but has finite uses and is craftable (recipe still a W.I.P tbh considering how broken the item might be).

if anyone can help me figure this out that'd be amazing because as far as I know, I've tried everything from starting on step 1 (no medikit item in code/folders at all aka as the mod was prior to creating it) to individual steps all the way to all my code being implemented, trying to find out what is causing the mod to crash. :drunk: It's such a bummer because this is the last thing I wanted to implement before launching the mod in its entirety to the public.

Brains? Scrambled. Patience? Dead in the water. LUA has once more bested me in the ring of fire.

I could be very wrong, but my guess from the error would mean that it's trying to load an image that's corrupted or in the wrong format. I'd try temporarily moving any png out of the mod even though it's not being used in the code, just in case. Other than that, I'd delete the anim folder and let it recompile. I've never seen this exact error before though, so these things might not make a difference, but it's my best guess.  

  • Like 1

UPDATE:

 

turns out the tutorial I followed had incorrect settings for the TEX converter. After some (very frustrating) fiddling, the mod no longer crashes on start-up. However, I have not re-implemented the medkit item yet, so there's that to test and hopefully resolve.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...