Jump to content

Custom Item Not Showing

Recommended Posts

My mod adds a throwing spike (akin to the Harpoon from Shipwrecked), and while it does function, it doesn't show up on the ground, while flying mid-air or while held in the hand slot on the character model, but it does show up in the inventory. I would very much appreciate some help.

On a side note, how do you add a custom recipe to only a custom character? (Much like Wigfrid's Battle Spear and Helm)

Throwing Spike.rar

Link to comment
Share on other sites

I haven't look at your item yet. But for the custom recipe on your character you could use the same code I used to create mine on my mod.

1st, inside your modmain.lua, you have to write at the top of your script this :

local Ingredient = GLOBAL.Ingredient
local require = GLOBAL.require

2nd, you will have to load your item in the modmain too. You could write this :

PrefabFiles = {

3rd, make sure you load every assets you need before continuing. Such as your character images/atlas and your item anim/atlas.

4th, you have to make a string name and a description for your item, they will appear in the recipe tab! You can also write how your character will describe it on inspection, which is a different "description". I took the exemple from my mod. Here what is should look like :

GLOBAL.STRINGS.NAMES.ORANGEPOTION = "Hunger Potion" --the name of the item, it appears like that in the recipe tab.
GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.ORANGEPOTION = "Smells good food." --shows when the character inspects the potion.
STRINGS.RECIPE_DESC.ORANGEPOTION = "Its like foooooood!" --Shows under the recipe tab, to describe what is the item.

5th, at the bottom of your script, you have to add the crafting part where you will add every item needed for your recipe. Again, I take exemple from my own mod. Here what it should look like :

RECIPETABS['character_name_TAB'] = {str = "character_name_TAB", sort=1000, icon = "character_name.tex", icon_atlas = "images/recipe_tab/character_name.xml"}
STRINGS.TABS.CHARACTER_NAME_TAB="My Recipe Tab"	-- It can change, put yourelf a cool name for your tab!

local itemname_recipe = AddRecipe("itemname", {Ingredient("carrot", 2), Ingredient("pumpkin", 1)}, RECIPETABS.character_name_TAB, TECH.NONE , nil , nil, nil, nil, "character_name" , "images/inventoryimages/itemname.xml")

Don't forget to replace character_name by your name and itemname by your item name (throwing_spike? idk...). You can change the ingredients used for the recipe and every number if you want. If you are not sure what is the ID you want to use, go check on don't starve wiki, I think every ID are written for each item in game.

6th, If you have noticed, there is a new folder that appear in the craft section, which is : "images/recipe_tab/character_name.xml".

You have to create that folder in order to make it works! That folder is specially for your recipe, it worth time making it ;)

Go under images, and create a new folder which you will call recipe_tab.

Inside that folder, put in your own .png image that will fit the tab of your custom recipe. Make sure the .png image has a transparent background and has a size of 128x128.

Once done, convert your 128x128 .png image into a .tex file. Each .tex file are associated with their .xml file (atlas). If you managed to create your own character so far, you might be able to edit the .xml file in there. If there is no .xml, I guess you can get one from another folder?

7th, Make sure you have your item image in the inventoryimages folder and everything is well coded.

8th, Launch the game and see what you got! :)




Edited by D4rkh0bb1T
Link to comment
Share on other sites

For the swap issue, make sure you call the right assets in the item code :

local assets =
    Asset("ANIM", "anim/item_name.zip"),
    Asset("ANIM", "anim/swap_item_name.zip"),
	Asset("IMAGE", "images/inventoryimages/item_name.tex"),
	Asset("ATLAS", "images/inventoryimages/item_name.xml")

The OnEquip&OnUnequip function will let you equip/desequip the item, using the swap thing on the arm section of your character :

local function OnEquip(inst, owner) 
    owner.AnimState:OverrideSymbol("swap_object", "swap_item_name", "item_name")

local function OnUnequip(inst, owner) 

Then, the animation part in the code :


Add the item a equippable ability and tell the game where to find the image of your item :

    inst.components.inventoryitem.imagename = "item_name"
    inst.components.inventoryitem.atlasname = "images/inventoryimages/item_name.xml"
    inst.components.equippable:SetOnEquip( OnEquip )
    inst.components.equippable:SetOnUnequip( OnUnequip )

The Coding part is done and should be right for now. Next, we have to create folders in the exported folder...


What you want is to create two folder for each item. One will be for the ground animation, and the other one will be for the swap animation.

So go to exported folder, and inside it, create a folder called ground_item_name and swap_item_name.


Ground_item_name folder : Inside this one, you'll have a image (mine are 64x64) that you will call ground_item_name (just like the folder...)

Open spriter and make a new project. They will ask you where you want to create it. Simple, create it inside ground_item_name folder.

Spriter will open and you'll get a blank project. In the project, put your ground_item_name.png. (You might find it in the palette area)

Make sure you put the item right in the middle and that the image does not go below the bottom line.

The animation section should be called item_name, and under it, the animation itself, called idle.

Save the project and name it as ground_item_name. Close it. In the folder you should have a ground_item_name.png image and ground_item_name.scml. The autocompiler will build the animation and will create a .zip file. You are done with the Ground Item.


Swap_item_name folder : Same thing as above but with many differences. Put your image in the folder and call it swap_item_name.

Create a new spriter project inside swap_item_name folder and put your image inside for it fits the best.

The animation section should be called swap_item_name, and under it, the animation itself, called BUILD.

Save the project and name swap_item_name. You should have 2 files : swap_item_name.png and swap_item_name.scml.


Don't forget to delete the .zip file in the anim folder as the autocompiler will re-create them!

I hope it will work. Well, it worked for me.




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

  • Create New...