RadiantRoma Posted April 17, 2017 Share Posted April 17, 2017 Simple enough, I thought inst:ListenForEvent("onpickedfn", OnPicked) would be called whenever a flower is picked, because in the flower's prefab there is inst.components.pickable.onpickedfn = onpickedfn, but my OnPicked function never gets run. I know because there is a print statement immediately in the function. Is there another event to listen for, or something else I can do to know when a flower gets picked? Link to comment Share on other sites More sharing options...
IronHunter Posted April 17, 2017 Share Posted April 17, 2017 (edited) Inside the pickable component, I see two possible events that are pushed: picker:PushEvent("picksomething", { object = self.inst, loot = loot }) this one seems to reference the player and looks to be the one you want for this situation. "picksomething" If that doesn't work then the only other event in the pickable component is this one self.inst:PushEvent("picked", { picker = picker, loot = loot, plant = self.inst }) Which seems to reference the object being picked, still good to know about I guess. Hope this helps. Edited April 17, 2017 by IronHunter inst:ListenForEvent("picksomething", OnPicked) Link to comment Share on other sites More sharing options...
Serpens Posted April 17, 2017 Share Posted April 17, 2017 9 hours ago, Cherryzion said: Simple enough, I thought inst:ListenForEvent("onpickedfn", OnPicked) would be called whenever a flower is picked, because in the flower's prefab there is inst.components.pickable.onpickedfn = onpickedfn, but my OnPicked function never gets run. I know because there is a print statement immediately in the function. Is there another event to listen for, or something else I can do to know when a flower gets picked? as you can see in ironhunters response. events are not fired when somewhere inst.components.pickable.onpickedfn = onpickedfn is written. They are only fired with "PushEvent". This information helps the next time you are searching for an event Link to comment 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