Jump to content

On[Event]changephase functions?


Recommended Posts

Functions that occur when a condition happens are common and useful.  When a structure is hammered it runs a function.  When the moon phase changes, events can be pushed to happen.  These pieces of code do seem to be referenced in the main function though, something like: inst.components.workable:SetOnFinishCallback(onhammered)
So there are two pieces, the order to watch out for the event, and the corresponding code that will happen.

I want to watch for a day change, season change, and when it starts to rain.  Does anyone know how to code this?
I have some guesses, but haven't been able to find any examples of this code in action yet.  A guess:  local function changeseason (inst, phase)

I did find this code, but haven't yet learned how to use it:
inst:AddComponent("timer")
inst:ListenForEvent("timerdone", OnTimerDone)

local function OnTimerDone(inst, data)

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...