Fadingwhite Posted May 24, 2015 Share Posted May 24, 2015 As the title says Is it possible to detect when a tree is chopped down or when rocks are mined?That is , when the actual loot is dropped, not during the animation phase. I know you can use a Listener somehow. Would it be possible to add a component to the player character that can listen to events in the world such as these? If so, how would it be done? Preferably something with Post Init.Thanks! Link to comment https://forums.kleientertainment.com/forums/topic/54329-is-it-possible-to-detect-when-a-tree-is-chopped-down-or-when-rocks-are-mined/ Share on other sites More sharing options...
Blueberrys Posted May 24, 2015 Share Posted May 24, 2015 @Fadingwhitelocal function check_worked(inst) inst:ListenForEvent("workfinished", function(inst) -- ... end)endAddPrefabPostInit("rock1", check_worked)AddPrefabPostInit("rock2", check_worked)-- AddPrefabPostInit("prefab_name", check_worked)-- etc...Check the workable component to see how the events are called.("..\scripts\components\workable", copied for reference)function Workable:WorkedBy(worker, numworks) numworks = numworks or 1 self.workleft = self.workleft - numworks self.lastworktime = GetTime() worker:PushEvent("working", {target = self.inst}) self.inst:PushEvent("worked", {worker = worker, workleft = self.workleft}) if self.onwork then self.onwork(self.inst, worker, self.workleft) end if self.workleft <= 0 then if self.onfinish then self.onfinish(self.inst, worker) end self.inst:PushEvent("workfinished") worker:PushEvent("finishedwork", {target = self.inst, action = self.action}) endend Link to comment https://forums.kleientertainment.com/forums/topic/54329-is-it-possible-to-detect-when-a-tree-is-chopped-down-or-when-rocks-are-mined/#findComment-640076 Share on other sites More sharing options...
Mobbstar Posted May 24, 2015 Share Posted May 24, 2015 (edited) The worker pushes the event "working" with data.target being the tree, rock, structure, grave, etc.Use this if you are making a character. The tree, rock, etc. pushes an event as seen in BlueBerrys post.Use this if your mod is character-independent. Edited May 24, 2015 by Mobbstar Link to comment https://forums.kleientertainment.com/forums/topic/54329-is-it-possible-to-detect-when-a-tree-is-chopped-down-or-when-rocks-are-mined/#findComment-640118 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