Jump to content

Recommended Posts

So my prefab is perfect in the inventory, and on the ground, but otherwise when its in a crafting tab it seems to break.

 

eaShik6.png

 

Quick notes: 'SCIENCE = 3' is a part of the mod I'm working on, its not the issue, I don't think.

 

I have other custom prefabs that work perfectly fine in the tab, so I'm not sure what it is, besides maybe the fact that the affected item shares a lua file with another prefab, they both however work and show themselves perfectly in the inventory, and on the ground.

 

Lines relevant to prefab in Modmain:

local wironrecipe = Recipe( "iron", { Ingredient("ore", 3) }, RECIPETABS.REFINE, {SCIENCE = 3, MAGIC = 0, ANCIENT = 0})wironrecipe.atlas = "images/inventoryimages/iron.xml"

Lines relevant to the image in its file: 

    inst:AddComponent("inventoryitem")    inst.components.inventoryitem.imagename = "iron"    inst.components.inventoryitem.atlasname = "images/inventoryimages/iron.xml"    inst.entity:AddMiniMapEntity()	    inst.MiniMapEntity:SetIcon( "iron.tex" )

So what should I be looking at? The dual-prefab lua file? My assets? The way I'm calling them? Again, similar prefabs are working just fine ._.

 

@Fireandthethud,

 

From recipe.lua:

Ingredient = Class(function(self, type, amount, atlas)    self.type = type    self.amount = amount	self.atlas = (atlas and resolvefilepath(atlas))					or resolvefilepath("images/inventoryimages.xml")end)

Try adding the path to your ore prefab's inventory atlas as the 3rd argument to Ingredient(), eg:

local wironrecipe = Recipe( "iron", { Ingredient("ore", 3, "images/inventoryimages/ore.xml") }, RECIPETABS.REFINE, {SCIENCE = 3, MAGIC = 0, ANCIENT = 0})

Okay, so here is the edit I made to the code:

local wironrecipe = Recipe( "iron", { Ingredient("ore", 3, "images/inventoryimages/ore.xml") }, RECIPETABS.REFINE, {SCIENCE = 3, MAGIC = 0, ANCIENT = 0})wironrecipe.atlas = "images/inventoryimages/iron.xml"

Put log returns: 

WARNING! Could not find region 'iron.tex' from atlas 'images/inventoryimages.xml'. Is the region specified in the atlas?images/inventoryimages.xml[...]...m/steamapps/common/dont_starve/data/scripts/util.lua:276: Could not find an asset matching images/inventoryimages/.xml in any of the search paths.

I also tried making the 3rd argument end in .tex instead of .xml but that didn't work either

Btw, just for my knowledge is Inventoryimages.xml where the .xml files are all group together? Because it sounds odd it was looking for iron.tex in it.

 

How does that work?

Actually, the atlas is the 4th argument, so shouldn't I have a 2nd argument to fill in? Right now I think it might be reading the 3rd argument of amount as the .xml

 

Edit: Nope not that, it searched for "3" as an asset

Edited by Fireandthethud
Actually, the atlas is the 4th argument

 

The first argument is self, but that's invisible to the user.

 

Because it sounds odd it was looking for iron.tex in it.

 

That's because

    self.atlas = (atlas and resolvefilepath(atlas))                    or resolvefilepath("images/inventoryimages.xml")

which is a compact way to write this:

if atlas ~= nil then    if resolvefilepath(atlas) ~= nil then        self.atlas = atlas    endelse    self.atlas = resolvefilepath("images/inventoryimages.xml)end

It essentially uses inventoryimages.xml as a fallback for when it can't resolve the file path provided.

 

Are you defining this recipe from within modmain?

Okay, so upon further inspection...
 

GLOBAL.STRINGS.NAMES.IRON = "Metalic Metal"GLOBAL.STRINGS.RECIPE_DESC.IRON = "Great for inventing new machines!"GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.IRON = "Sturdy building materials for science."local wironrecipe = Recipe( "iron", { Ingredient("ore", 3, "images/inventoryimages/ore.xml") }, RECIPETABS.REFINE, {SCIENCE = 3, MAGIC = 0, ANCIENT = 0})wironrecipe.atlas = "images/inventoryimages/iron.xml"

Allowed for the icon to be displayed properly. Thank you @Corrosive

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...