Mr.Cuddlesworth Posted June 14, 2017 Share Posted June 14, 2017 (edited) 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:AddComponent("stackable") inst.components.stackable.maxsize = TUNING.STACK_SIZE_LARGEITEM instead of having it as inst:AddComponent("stackable") Should I have it as inst:AddComponent("unstackable") ? 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() inst.entity:AddTransform() inst.entity:AddAnimState() inst.entity:AddNetwork() MakeInventoryPhysics(inst) inst.AnimState:SetBank("petals") inst.AnimState:SetBuild("yarn_ball") inst.AnimState:PlayAnimation("anim") if not TheWorld.ismastersim then return inst end inst.entity:SetPristine() inst:AddComponent("inventoryitem") inst.components.inventoryitem.atlasname = "images/inventoryimages/yarn_ball.xml" inst:AddComponent("stackable") inst.components.stackable.maxsize = TUNING.STACK_SIZE_LARGEITEM inst:AddComponent("edible") inst.components.edible.healthvalue = 0 inst.components.edible.hungervalue = 0 inst.components.edible.sanityvalue = 25 inst.components.edible.foodtype = FOODTYPE.MEAT inst:AddComponent("inspectable") return inst end 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 June 14, 2017 by Mr.Cuddlesworth The title fits topic better. Link to comment https://forums.kleientertainment.com/forums/topic/79860-need-help-custom-item-properties/ Share on other sites More sharing options...
Lumina Posted June 14, 2017 Share Posted June 14, 2017 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 https://forums.kleientertainment.com/forums/topic/79860-need-help-custom-item-properties/#findComment-931796 Share on other sites More sharing options...
Mr.Cuddlesworth Posted June 14, 2017 Author Share Posted June 14, 2017 (edited) Alright, I'll try it Thanks! Edit: It's not stackable anymore, thanks, Lumina! I'm still stumped on how not make the item an edible and still function. Edited June 14, 2017 by Mr.Cuddlesworth Link to comment https://forums.kleientertainment.com/forums/topic/79860-need-help-custom-item-properties/#findComment-931797 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now