Codelyy Posted August 12, 2022 Share Posted August 12, 2022 (edited) This is likely a rather simple question to ask: Is there a method that is called when a player picks up an item? I want to perform some logic on any items picked up by my character but I'm struggling to find such a method. I assumed there would be some OnPickup method in the inventory component but I've had no luck with finding anything. Edited August 12, 2022 by codelyoko373 Link to comment https://forums.kleientertainment.com/forums/topic/142574-inventory-onpickup/ Share on other sites More sharing options...
Bumber64 Posted August 13, 2022 Share Posted August 13, 2022 (edited) local function OnPickup(inst, data) --put this anywhere in character file --inst is player, data.item is item end inst:ListenForEvent("onpickup", OnPickup) --put this in character fn Edited August 13, 2022 by Bumber64 Link to comment https://forums.kleientertainment.com/forums/topic/142574-inventory-onpickup/#findComment-1594050 Share on other sites More sharing options...
Codelyy Posted August 13, 2022 Author Share Posted August 13, 2022 3 hours ago, Bumber64 said: local function OnPickup(inst, data) --put this anywhere in character file --inst is player, data.item is item end inst:ListenForEvent("onpickup", OnPickup) --put this in character fn I realise that I misunderstood what picking up an item would mean in terms of the game. Basically I'm looking for a method that is called whenever anything is added to the players inventory. That PickUp event isn't triggered on you for example harvesting grass and adding that to your inventory Link to comment https://forums.kleientertainment.com/forums/topic/142574-inventory-onpickup/#findComment-1594069 Share on other sites More sharing options...
Bumber64 Posted August 14, 2022 Share Posted August 14, 2022 (edited) Looks like you just need to swap "onpickup" with "itemget". Event is pushed in inventory component (Inventory:GiveActiveItem and Inventory:GiveItem) like you suspected. Edited August 14, 2022 by Bumber64 Link to comment https://forums.kleientertainment.com/forums/topic/142574-inventory-onpickup/#findComment-1594273 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