Jump to content

Recommended Posts

I have a diggable item, i want it to "regrow" over time, a little like pickable item. What is the best way to achieve that ? I know the code i must use for the "regen" part, i think (something like testing if there is a workable component, and if not, adding one), but not how to do the regen part.

I'm not sure i should use dotaskintime since i want a regrow every ten days (more or less) and dotaskintime seems to be for short delay. Any advice ? Thanks :)

Maybe add a counter on your object and a ListenForEvent which catch when a new day begin and increase that counter. Then if the counter == 10, regrow and counter = 0.

 

EDIT: it won't be a ListenForEvent but something similar.

function EntityScript:WatchWorldState(var, fn)
    EntityWatchWorldState(self, var, fn)
    TheWorld.components.worldstate:AddWatcher(var, self, fn, self)
end

In your prefab init function you could add

inst:WatchWorldState("isday", OnNewDayFn)

 

Edited by ZupaleX

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