Sir_Kasalott Posted October 16, 2017 Share Posted October 16, 2017 Hey guys and gals, I'm on the last(known) step of making my character mod, one last thing to do. I'm trying to work out how to Remove an item when it been placed into a chest/backpack or anything that's, not the character's inventory. now I have seen that there is this, inst.components.inventoryitem.cangoincontainer = false But from what it looks like, it just makes the item gets removed when placed in my inventory. please help, I'm sure that there is some kind of ListenForEvent for when an item is put into a container. But my little brain cant work it out. The first person to help me out gets 3 a half brownie point (I got a bit hungry). -Taps Link to comment https://forums.kleientertainment.com/forums/topic/83044-help-how-to-remove-an-item-when-placed-into-chest/ Share on other sites More sharing options...
alainmcd Posted October 16, 2017 Share Posted October 16, 2017 I'm feeling peckish... and lazy: local function deleteitemincontainer(inst, owner) inst:DoTaskInTime(0, function() if owner.components.container then inst:Remove() --owner.components.container:RemoveItem(inst) end end) end AddPrefabPostInit("cutgrass", function(inst) inst.components.inventoryitem:SetOnPutInInventoryFn(deleteitemincontainer) end) Deletes all cut grass in any container. inst:Remove() and owner.components.container:RemoveItem(inst) should be more or less the same in most cases, there could be some where you'd prefer the latter. The DoTaskInTime isn't absolutely necessary, but if you don't use it, the item gets "stuck" in the container and doesn't disappear until you close and reopen the container; it still flickers in the containter for a fraction of a second. There might be a more elegant solution. I'm assuming you understand what's going on and can change it to your liking, feel free to ask if anything isn't clear. Link to comment https://forums.kleientertainment.com/forums/topic/83044-help-how-to-remove-an-item-when-placed-into-chest/#findComment-964219 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