Jump to content

[Need Help] Custom Item Properties

Recommended Posts

So I'm working on my first mod to learn how to program LUA so I can develop better mods in DST. In this mod, I want to add a ball of yarn that soothes the character, restoring their sanity by 25. I have the item as an edible, and every time that item is consumed, it restores the sanity as planned. I just don't like the idea of the character eating a ball of yarn. And I also don't really know how to make the item so it doesn't stack. I currently have it under a large item, but it still stacks;

inst.components.stackable.maxsize = TUNING.STACK_SIZE_LARGEITEM

instead of having it as


Should I have it as



If you need the code, this is yarn_ball.lua;

local assets =
	Asset("ANIM", "anim/yarn_ball.zip"),
    Asset( "ATLAS", "images/inventoryimages/yarn_ball.xml" ),

local function fn(Sim)
	local inst = CreateEntity()



    if not TheWorld.ismastersim then
        return inst


	inst.components.inventoryitem.atlasname = "images/inventoryimages/yarn_ball.xml"

	inst.components.stackable.maxsize = TUNING.STACK_SIZE_LARGEITEM
    inst.components.edible.healthvalue = 0
    inst.components.edible.hungervalue = 0
    inst.components.edible.sanityvalue = 25		
    inst.components.edible.foodtype = FOODTYPE.MEAT


    return inst

return Prefab("common/inventory/yarn_ball", fn, assets)

I have the foodtype as meat, so the character doesnt reject it, as they are a carnivore.


Sorry if this is a lot, I'm just really tripped up with this and want to learn how to create a decent item.

Edited by Mr.Cuddlesworth
The title fits topic better.
Link to comment
Share on other sites

I don't see any "unstackable" component in the files, i could have missed it, but why not just commenting the two line about stackable and see what it does ?

Also, maybe you could find a way to make an item like spider gland/healing salve, but for sanity ? I don't know if it's possible.

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