Sgoku Posted June 1, 2014 Share Posted June 1, 2014 Hello Community! Im new to the Dont Starve modding scene and would like to know if there is a kind of Listener,that i can use to execute an event when something is cooked. Thx for your help! Link to comment https://forums.kleientertainment.com/forums/topic/37048-oncook-event/ Share on other sites More sharing options...
squeek Posted June 1, 2014 Share Posted June 1, 2014 Unfortunately, there is no event for that. You'd have to do something like:local function OnSomethingCooked(cooked_thing, cooker) -- your code hereendAddComponentPostInit("stewer", function(component, inst) -- delay a frame so that the component can get initialized by the prefab inst:DoTaskInTime(0, function() -- save the old callback function if it exists local ondonecooking_base = component.ondonecooking or function() end component.ondonecooking = function(cooker) ondonecooking_base(cooker) OnSomethingCooked(component.product, cooker) end end)end) Link to comment https://forums.kleientertainment.com/forums/topic/37048-oncook-event/#findComment-492499 Share on other sites More sharing options...
Rincevvind Posted June 2, 2014 Share Posted June 2, 2014 (edited) but its possible to override StartCooking and do something like function Stewer:StartCooking()oldStartCooking(self)self.inst:DoTaskInTime(self.targettime-GetTime()+0.1, function() self.inst:PushEvent("stew",{product=self.product},GetWorld()) end)endits not completed code, just an idea, there must be onload/onsave handlers and its boringi guess much better to intercept ondonecooking something like:function Stewer:StartCooking()self.oldondonecooking = self.ondonecooking or nilself.ondonecooking = function()self.inst:PushEvent("stew",{product=self.product},GetWorld())if self.oldondonecooking then self:oldondonecooking() endendoldStartCooking(self)end Edited June 2, 2014 by Rincevvind Link to comment https://forums.kleientertainment.com/forums/topic/37048-oncook-event/#findComment-492698 Share on other sites More sharing options...
Rincevvind Posted June 2, 2014 Share Posted June 2, 2014 (edited) and already have idea for this event - like monster animals in some radius may walk to cookpot to eat something... like a player Edited June 2, 2014 by Rincevvind Link to comment https://forums.kleientertainment.com/forums/topic/37048-oncook-event/#findComment-492701 Share on other sites More sharing options...
Sgoku Posted June 2, 2014 Author Share Posted June 2, 2014 Thx for helping me! Link to comment https://forums.kleientertainment.com/forums/topic/37048-oncook-event/#findComment-492939 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