Goregonzola Posted January 8, 2021 Share Posted January 8, 2021 (edited) Hello there! I have a hard time figuring out what's wrong with my coding. I feel like I'm totally missing out something. I'm trying to make my custom item stackable, but whenever I try to spawn it with commands, the game crashes with the attached message. I use this coding in my item's .lua file in the local function section: Quote inst:AddComponent("stackable") inst.components.stackable.maxsize = TUNING.STACK_SIZE_LARGEITEM Is there anything additional coding I would have to do? Here's my complete item.lua coding so far: Spoiler local assets= { Asset("ANIM", "anim/wishpower.zip"), Asset("ATLAS", "images/inventoryimages/wishpower.xml"), Asset("IMAGE", "images/inventoryimages/wishpower.tex"), } local prefabs = { } local function fn(Sim) local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddAnimState() inst.entity:AddNetwork() inst.entity:AddSoundEmitter() MakeInventoryPhysics(inst) inst.AnimState:SetBank("wishpower") inst.AnimState:SetBuild("wishpower") inst.AnimState:PlayAnimation("idle") inst:AddComponent("stackable") inst.components.stackable.maxsize = TUNING.STACK_SIZE_LARGEITEM if not TheWorld.ismastersim then return inst end inst.entity:SetPristine() inst:AddComponent("inventoryitem") inst.components.inventoryitem.imagename = "wishpower" inst.components.inventoryitem.atlasname = "images/inventoryimages/wishpower.xml" MakeHauntableLaunch(inst) return inst end Edited January 8, 2021 by BillTheCipher Link to comment https://forums.kleientertainment.com/forums/topic/125868-solved-how-can-i-make-an-item-stackable/ Share on other sites More sharing options...
Thomas_klei Posted January 8, 2021 Share Posted January 8, 2021 Spoiler local assets= { Asset("ANIM", "anim/wishpower.zip"), Asset("ATLAS", "images/inventoryimages/wishpower.xml"), Asset("IMAGE", "images/inventoryimages/wishpower.tex"), } local prefabs = { } local function fn(Sim) local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddAnimState() inst.entity:AddNetwork() inst.entity:AddSoundEmitter() MakeInventoryPhysics(inst) inst.AnimState:SetBank("wishpower") inst.AnimState:SetBuild("wishpower") inst.AnimState:PlayAnimation("idle") if not TheWorld.ismastersim then return inst end inst.entity:SetPristine() -- Should be beneath the " if not TheWorld.ismastersim then" inst:AddComponent("stackable") inst.components.stackable.maxsize = TUNING.STACK_SIZE_LARGEITEM inst:AddComponent("inventoryitem") inst.components.inventoryitem.imagename = "wishpower" inst.components.inventoryitem.atlasname = "images/inventoryimages/wishpower.xml" MakeHauntableLaunch(inst) return inst end This should work, I put a little comment as well 1 Link to comment https://forums.kleientertainment.com/forums/topic/125868-solved-how-can-i-make-an-item-stackable/#findComment-1414611 Share on other sites More sharing options...
Goregonzola Posted January 8, 2021 Author Share Posted January 8, 2021 @thomas4846 Love ya Link to comment https://forums.kleientertainment.com/forums/topic/125868-solved-how-can-i-make-an-item-stackable/#findComment-1414613 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