Sign in to follow this  
RadiantRoma

Event for picking flowers

Recommended Posts

RadiantRoma    386

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? 

Share this post


Link to post
Share on other sites
IronHunter    390

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 by IronHunter
inst:ListenForEvent("picksomething", OnPicked)

Share this post


Link to post
Share on other sites
Serpens    551
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 ;)

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this