Jump to content

inventoryimage disappeared


Recommended Posts

So I'm adding a new food item with a cooked and dried version.

I originally had my prefabs named "smallmonstermeat", "cookedsmallmonstermeat", and "driedsmallmonstermeat"

After looking into how the AddIngredientValues function in "cooking.lua" works, I realized I wanted to rename them to "smallmonstermeat_cooked" and "smallmonstermeat_dried". So I did that.

I renamed the prefabs, but I did not rename the inventory images. I still have the same atlas file names in my assets, and I'm still assigning the same inventory image to the prefabs with

inst.components.inventoryitem.atlasname = "images/inventoryimages/cookedsmallmonstermeat.xml"

But when I run the game, I can spawn or give myself this item using c_give("smallmonstermeat_cooked"), and it works, i get the item, i can see that it perishes over time, i can right click to eat it and i get the correct amount of health, hunger, and sanity, but the inventory image is missing. it's blank. i only know i have something because the slot turns green and perishes. I can pick up the invisible item and drop it on the ground and anim still works. literally everything is working with this prefab except for the inventory image. But i haven't changed anything with it. If i rename the prefab back to "cookedsmallmonstermeat" the inventory image works again. What is the deal here? Why is the inventory image not working when I change the prefab name?

Link to comment
Share on other sites

Do you have this ?

 


			inst.components.inventoryitem.imagename = "cookedsmallmonstermeat"	
    		inst.components.inventoryitem.atlasname = "images/inventoryimages/cookedsmallmonstermeat.xml"

Sometime imagename is needed. Maybe it could help.

If not, it will probably be quicker to link your mod here.

Link to comment
Share on other sites

1 hour ago, HomShaBom said:

Do you know why this is sometimes needed?

Your atlas file is probably something like:

<Atlas><Texture filename="cookedsmallmonstermeat.tex" /><Elements><Element name="cookedsmallmonstermeat.tex" u1="0" u2="0" v1="1" v2="1" /></Elements></Atlas>

The texture filename is the filename of the tex file that has the images.

The elements are how the game cuts the texture file to make a tiny texture, out of a big texture.

The game has an inventoryimages.xml file, that has "inventoryimages.tex" as texture filename, and has item elements like "umbrella.tex".

 

By default, the game looks for "smallmonstermeat_cooked.tex", your prefab.

So what you need is:

<Atlas><Texture filename="cookedsmallmonstermeat.tex" /><Elements><Element name="smallmonstermeat_cooked.tex" u1="0" u2="0" v1="1" v2="1" /></Elements></Atlas>

To define the image the game will look for.

Link to comment
Share on other sites

Ok, so I think I got it. The .tex file is like several images (but could only be 1) inside of 1 file, and the .xml file defines the boundaries of each individual image inside of it and gives them a name. When you use the DST mod tools to automatically generate your .tex and .xml files from a .png then it ends up using the png file name as the image name. And DST defaults the prefab's imagename to the prefab's name. So if the name of the prefab matches the name of the png then you don't need to assign the imagename but if it is different then you do need to assign the imagename.

Link to comment
Share on other sites

20 minutes ago, HomShaBom said:

So if the name of the prefab matches the name of the png then you don't need to assign the imagename but if it is different then you do need to assign the imagename.

Probably that yes :)

 

This tool is really convenient when you want to create one .tex file for multiple inventory image. Like, if you have smallmonstermeat.png, smallmonstermeat_cooked.png and smallmonstermeat_dried.png, you could create a "smallmonstermeat.tex" that will contain the three inventory image. After that, you just have to use :

 


			inst.components.inventoryitem.imagename = "smallmonstermeat"	
    		inst.components.inventoryitem.atlasname = "images/inventoryimages/smallmonstermeat.xml"
			
			inst.components.inventoryitem.imagename = "smallmonstermeat_cooked"	
    		inst.components.inventoryitem.atlasname = "images/inventoryimages/smallmonstermeat.xml"
			
			inst.components.inventoryitem.imagename = "smallmonstermeat_dried"	
    		inst.components.inventoryitem.atlasname = "images/inventoryimages/smallmonstermeat.xml"

For each variant.

I find it really useful, instead of having to create .tex and .xml manually.

 

Link to comment
Share on other sites

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
 Share

×
  • Create New...