Jump to content

[Help] Using a custom item as an ingredient


Recommended Posts

Hello,

I've been doing my best at finding resources that already exist on the forum to help with debugging my mod, but I can't find the proper solution to this one.

I created an item that drops from trees and boulders and I'd like to use it as an ingredient for other items. 

I can DebugSpawn("energyshard") the item, but DST throws a Stack traceback error when I try to craft an item that uses it as an ingredient as I click the recipetab that contains the recipe, not as I attempt to craft it:

 

post-694923-0-33991400-1440999107_thumb.

 

If I try replacing the energyshard item with an item I have a recipe for, there is no error. I know it has something to do with lua not being able to find the tex/xml files but I'm not sure how else I can explicitly tell the script where to find the correlating image files.

I found a preexisting mod called Black Rock Shooter that does something similar and tried their method but I must be doing something wrong.

This is the bit of script in question:

------- ENERGY SHARDSTRINGS.NAMES.ENERGYSHARD = "Energy Shard"STRINGS.CHARACTERS.GENERIC.DESCRIBE.ENERGYSHARD = "Fuel for fusion!"local myShardIngredient = Ingredient( "energyshard", 2)myShardIngredient.atlas = "images/inventoryimages/shard.xml"

I've attached the modmain.lua, energyshard.lua and the images/inventoryimages/ directory

Any help would be amazing. This is my first post, so I hope I did this correctly.

inventoryimages.zip

modmain.lua

energyshard.lua

Link to comment
Share on other sites

Hello

 

first of all (and don't take it wrongly) your code is a mess. You should try to keep some proper sorting and indenting, it would be much more pleasant for you to work on it.

 

Back to the topic, your issue is 

STRINGS.NAMES.ENERGYSHARD = "Energy Shard"STRINGS.CHARACTERS.GENERIC.DESCRIBE.ENERGYSHARD = "Fuel for fusion!"local myShardIngredient = Ingredient( "energyshard", 2)myShardIngredient.atlas = "images/inventoryimages/shard.xml"
You see that your prefab is called energyshard but you named your image shard.tex. The game is looking for energyshard.tex but cannot find it (yes, even by specifying the atlas as beeing shard.xml)
 
So just keep the same name between the images associated to your prefab and the prefab itself. It will save you a lot of troubles.
 
Side note : 
Asset( "IMAGE", "images/inventoryimages/shard.tex"),Asset( "ATLAS", "images/inventoryimages/shard.xml"),
it is useless in the modmain since it is already in the prefab file.
local myShardIngredient = Ingredient( "energyshard", 2)myShardIngredient.atlas = "images/inventoryimages/shard.xml"
Just write this instead
local myShardIngredient = Ingredient( "energyshard", 2, "images/inventoryimages/shard.xml")

 

 

And I guess you will have similar issues with your other prefabs but that would be the same fix.

 

Good Luck

Edited by ZupaleX
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...