Jump to content

Recommended Posts

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)

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)end
its not completed code, just an idea, there must be onload/onsave handlers and its boring

i 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 by Rincevvind

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
×
  • Create New...