Jump to content

Modded crafting recipe issue


Recommended Posts

I am attempting to make a mod that adds new bee items. I have added a version of royal jelly from DST and added a recipe for honeycombs using it. In the crafting menu, the image for the royal jelly does not show up, yet outside of the crafting menu there are not any issues. I am not sure how to fix this. The error log displays this message: 

WARNING! Could not find region 'OUTOFSPACE' from atlas '../mods/testbox/images/inventoryimages/royaljelly.xml'. Is the region specified in the atlas?

20190422173531_1.thumb.jpg.36442e70246e904781ed5e08a71591ae.jpg

Link to comment
Share on other sites

Your tex file has the image(s)
and your xml defines the region of the file to use

For this example I am assuming that your royaljelly.tex contains only 1 image of 128 x 128 pixels
if so, your royaljelly.xml should read something like this

<Atlas>
 <Texture filename="royaljelly.tex" />
 <Elements>
  <Element name="royaljelly.tex" u1="0.0078125" u2="0.9921875" v1="0.0078125" v2="0.9921875" />
 </Elements>
</Atlas>

The region of your tex file is defined by four edges...
u1, u2, v1, and v2

u1 is the leftmost edge of your image, and u2 is the rightmost, meaning pixel 1 is on the left
However, v1 is the BOTTOM edge of you image, and v2 is the TOP
so pixel 1 is at the bottom... and pixel 128 (or 256, or whatever) is at the top
The numbers are derived by percentage of the image dimensions.

inv_sides.png.a8056db8594db5a2689dbc8656acf7d1.png
In this example the mushroom soup (blue bowl with the mushrooms) occupies the following region
'u' pixels between 192 to 256 and 'v' pixels between 64 and 128 (remember counting up from the bottom)

<Elements>
  <Element name= item #1, u1 u2 v1 v2 />
  ...
  <Element name="soup_mushroom.tex" u1="0.75390625" u2="0.99609375" v1="0.25390625" v2="0.49609375" />
  ...
  <Element name= item #15, u1 u2 v1 v2 />
</Elements>


To avoid overlapping pixels in the images, instead of starting at pixel 0 and ending at 256, I choose to take the pixels between two points.
So from the left edge a region 64 pixels wide would be measured from pixel 1 instead of 0 reaching to pixel 63 instead of 64
likewise the next image after it would be measured from 65 to 127
So my soup has u1 of 193/256 and u2 of 255/256 (between 192 and 256)

In theory, if your tex file has only one image the region could be
u1="0" u2="1" v1="0" v2="1" />
However, I have never tried this, so I don't know if it would work, as I always define the region with 1 pixel 'border'

=-=-=-=-=-=-
Don't forget your tex files should be factors of 2 in dimensions starting at 2x2 and doubling with each step up,
4x4, 8x8, 16x16, 32 x 32, 64 x 64, 128 x 128, 256 x 256, etc. (although anything less than 64 pixels is IMHO too small)
So If you want five images of 64x64 in a single tex file, you must use a file of 256 x 256 with a lot of empty/unused space

Link to comment
Share on other sites

Thank you for your response. My region had been defined as u1="0" u2="1" v1="0" v2="1". I changed the region to u1="0.0078125" u2="0.9921875" v1="0.0078125" v2="0.9921875" but it still gives the same error message. I also tried with images from another mod with both regions and it still did not work. This leads me to believe that the problem is not with the image or atlas, but somewhere else in my code. Here is my mod folder:

testbox.zip

Link to comment
Share on other sites

Some things you could try:

  1. Try removing the line: inst.components.inventoryitem.imagename = "royaljelly"
    In most item mods I see, they don't specify the imagename, only the atlasname. I dunno. maybe it would work if you put "royaljelly.tex"?
  2. You have two lines of: local inst = CreateEntity()
    Remove one of them.
  3. Instead of doing this:
    local jelly = Ingredient("royal_jelly", 5)
    jelly.atlas = "images/inventoryimages/royaljelly.xml"

    you can just do this:
    local jelly = Ingredient("royal_jelly", 5, "images/inventoryimages/royaljelly.xml")
    in which case you really don't need to put it in a local variable anymore. This should properly set up the atlas variable (even though what you had was also acceptable).

A separate problem. In your test_box.lua you have these lines:

inst:ListenForEvent( "dusktime", StopSpawningFn(inst), GetWorld())
inst:ListenForEvent( "daytime", StartSpawningFn(inst), GetWorld())

When passing a reference to an existing function to ListenForEvent, your should not include the parentheses or the parameters. The difference is, without the parentheses and parameters, you are giving it s reference to the function. With the parentheses and parameters you are actually calling the function, and passing the return value of that function to the ListenForEvent function, instead of passing it a reference to your custom function. You do NOT want that. That makes ListenForEvent not call your functions, because you are not passing them a function.

That said, if you were to pass it an in-line function, you obviously need to include the parentheses and parameters, but also the function body e.g.

inst:ListenForEvent( "daytime", function(inst)
	someFunction(inst)
	inst.someVariable = 5
end
, GetWorld())

 

Link to comment
Share on other sites

I'm not sure if this would work as this is for DST, but I did this for my wagstaff mod to have custom items show up in recipes

local wagstaffnormalgoggles_recipe = AddRecipe("wagstaffnormalgoggles", {Ingredient("goldnugget", 1), Ingredient("pigskin", 1)}, tinkeringtab, TECH.NONE, nil, nil, nil, nil)
wagstaffnormalgoggles_recipe.atlas = "images/inventoryimages/wagstaffnormalgoggles.xml"

 

Link to comment
Share on other sites

33 minutes ago, Omaremad74 said:

I'm not sure if this would work as this is for DST, but I did this for my wagstaff mod to have custom items show up in recipes


local wagstaffnormalgoggles_recipe = AddRecipe("wagstaffnormalgoggles", {Ingredient("goldnugget", 1), Ingredient("pigskin", 1)}, tinkeringtab, TECH.NONE, nil, nil, nil, nil)
wagstaffnormalgoggles_recipe.atlas = "images/inventoryimages/wagstaffnormalgoggles.xml"

 

I don't think it's the image for the product that's the problem. It's the image for one of the ingredients that is not showing up, and that ingredient is a custom item, which seems to be where this stems from.

Link to comment
Share on other sites

26 minutes ago, Ultroman said:

I don't think it's the image for the product that's the problem. It's the image for one of the ingredients that is not showing up, and that ingredient is a custom item, which seems to be where this stems from.

Wooops, I thought I posted the right thing, I meant this
 

local wagstaffarmorgoggles_recipe = AddRecipe("wagstaffarmorgoggles", {Ingredient("wagstaffnormalgoggles", 1, "images/inventoryimages/wagstaffnormalgoggles.xml", "wagstaffnormalgoggles.tex"), Ingredient("cutstone", 1)}, tinkeringtab, TECH.NONE, nil, nil, nil, nil)
wagstaffarmorgoggles_recipe.atlas = "images/inventoryimages/wagstaffarmorgoggles.xml"

Look at the wagstaffnormalgoggles ingredient I referenced the xml and tex files right after it.

Link to comment
Share on other sites

30 minutes ago, Omaremad74 said:

 


local wagstaffarmorgoggles_recipe = AddRecipe("wagstaffarmorgoggles", {Ingredient("wagstaffnormalgoggles", 1, "images/inventoryimages/wagstaffnormalgoggles.xml", "wagstaffnormalgoggles.tex"), Ingredient("cutstone", 1)}, tinkeringtab, TECH.NONE, nil, nil, nil, nil)
wagstaffarmorgoggles_recipe.atlas = "images/inventoryimages/wagstaffarmorgoggles.xml"

Look at the wagstaffnormalgoggles ingredient I referenced the xml and tex files right after it.

That doesn't really make sense, though. The Ingredient "constructor" looks like this in original DS and Hamlet, respectively:

DS

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)

Hamlet

Ingredient = Class(function(self, type, amount, atlas)
	self.type = type
	self.amount = amount
	self.atlas = (atlas and resolvefilepath(atlas))
end)

The 'self' parameter is automatically filled, so it only takes 3 parameters, and you're giving it 4. The 4th parameter you give (the path to the tex file) will not be used for anything. For DST, which has a 4th parameter, that 4th parameter is labelled "deconstruct", and is NOT expecting a path to a texture (though I'm not sure what it actually wants in that parameter, but I'm guessing a function).

Another thing is that there is no AddRecipe function in DS. That's only in DST. That aside, for DST, if you provide AddRecipe with the atlas parameter, then you don't have to set it afterwards.

Link to comment
Share on other sites

17 hours ago, Ultroman said:

[snip]

 

Sorry, haha I just wanted to provide a possible solution. It worked for me in DST so maybe it works for DS? Anyhow thanks for informing me about some things

Link to comment
Share on other sites

30 minutes ago, Omaremad74 said:

Sorry, haha I just wanted to provide a possible solution. It worked for me in DST so maybe it works for DS? Anyhow thanks for informing me about some things

I get it :) Please don't be put down by my reply in any way. I also just want to help :)

Link to comment
Share on other sites

1: The line inst.components.inventoryitem.imagename = "royaljelly" is required. Changing it to "royaljelly.tex" does not work. I think the reason why you haven't seen that used is that most people define the image name after the crafting recipe in modmain. As royal jelly does not have a crafting recipe, the image name is defined in the prefab file instead.

3: I was not aware that you could put them in the same line. I have changed that.

4: The testbox structure was simply me taking the code from the bee box in the game files. As it works currently, I assumed that I didn't need to change anything else.

I do not know why this worked, but changing the name of the xml and .tex files from royaljelly to royal_jelly fixed the issue. Thank you for your help.

Link to comment
Share on other sites

1. That may be true.

3. Awesome :)

4. Okidoki. It just really shouldn't work xD

21 minutes ago, Awesome_A0 said:

I do not know why this worked, but changing the name of the xml and .tex files from royaljelly to royal_jelly fixed the issue. Thank you for your help.

That's super weird...I meticulously checked the references, and nothing seemed wrong. It's one of those moments where you just leave it be, and walk into the sunset :)

Link to comment
Share on other sites

I have actually been having a second problem, but I though that it was related to the first one. I was hoping that solving that one would help me to fix it, but it seems that is not the case. The second problem is that when building the textbox structure, the green version that shows you where you are placing it does not appear. When it is placed, the structure appears and then correctly plays the build animation. The strange thing is that no errors are generated, unlike the other problem. 

20190506214043_1.jpg

Link to comment
Share on other sites

I think there's something different when working with structures that have placers. Find a mod that makes a new structure, and see which extra textures you need. I would assume that if you had a placer-texture, then it would give you a warning as to why it isn't showing.

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.

×
×
  • Create New...