Jump to content

Event for picking flowers


Recommended Posts

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

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)
Link to comment
Share on other sites

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

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
 Share

×
  • Create New...