Jump to content

Recommended Posts

Hi,

so I found a strange issue. While making compatible two mods together. I'm adding recipe from one into the other. it works fine so far, except for one

there's an icon for dug_reeds that is used for inventory, I do like for all 8 other instances of similar objects and have code that looks like this :

Spoiler

-- name = "dug_reeds"

	local tempingredient = Ingredient(name, 1)
	local temprecipe = Recipe(name, { tempingredient }, RECIPETABS.SURVIVAL, TECH.NONE)
			temprecipe.atlas = "images/inventoryimages/dug_reed.xml"
			tempingredient.atlas = "images/inventoryimages/dug_reed.xml"

 

This code works fine for 8 different but similar objects (dug_mushrooms ....). I verified with "prints" that the code is executed properly. Also of note is that before I had "images/inventoryimages/dug_reeds.xml" instead, and the game was throwing an error complaining about unable to find assets.

so for me, it seems the code is fine, but unlike the others the image is not displayed as a recipe nor as an ingredient. However I verified that the icon shows up in inventory just fine. Not sure what's happening ??? is there specific restrictions for recipe & ingredient icons different from inventory icons ???

 

Thanks.

Edited by whismerhill

The asset is referenced by a string, but it doesn't load in the first place unless you tell it to. This is why prefabs have the 'Assets' table.

For textures used in recipes, the asset should be declared in the 'Assets' table in 'modmain.lua':

Assets = {
	Asset("ATLAS", "images/inventoryimages/dug_reed.xml"),
	Asset("IMAGE", "images/inventoryimages/dug_reed.tex"),
}

 

well all the assets are declared on the other mod in the prefab files of each object, and it seems like it's all declared as "local Assets". I'll try that though, can't hurt :p

I'm still gonna wait a bit, the other mod author said he would fix a  naming discrepancy I pointed out. Not that it's hard to do myself, I just want all subscribers to get the "fix" (In detail, assets are named : "dug_reed" whereas the object prefab & name is "dug_reeds") (In even more detail, this discrepancy, makes iterating through recipes  need an exception)

fixed,

it seems even though the code was correct, the game didn't like having a dug_reeds prefab with a dug_reed artwork

now it works fine or else I made a mistake somewhere that I never spotted.

Thanks guys !

The reason that it's declared as local in prefab definitions is that it's being passed as a parameter. In 'modmain.lua', it's a global variable. The 'modmain.lua' files are run in a nonstandard environment (which is why 'GLOBAL' exists in them), and the declared table is hence equivalent to a field when considered by the mod loader.

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