Jump to content

World Clock

Recommended Posts

I'm trying to use remainingtimeinphase from the clock component. Essentially, I need to be able to get use the time until morning (how much time night has left) inside of modmain but I can't seem to figure out the right syntax. Any help would be appreciated.

Link to comment
Share on other sites

You can use


this returns a number between 0 and 1 depending on the position of the arrow.

At the start of the night, it will return 0. In the middle, 0.5. In the end, 1.


To know how many seconds passed since the start of the night, you can listen to the clocktick event.


Or save the time when the night starts:

-- We save time when night startsinst:WatchWorldState("startnight", function(inst)	inst.time = GLOBAL.TheWorld.state.timeend)

And given that we know the percentage of time passed, and when the night started, we can:

a) Calculate the secs passed

local function secs_passed_in_night_phase(inst)	return GLOBAL.TheWorld.state.time - inst.timeend

b) Calculate the secs left

local secs_left_in_night_phase(inst)	return (1 - GLOBAL.TheWorld.state.timeinphase) * secs_passed_in_night_phase(inst) / GLOBAL.TheWorld.state.timeinphaseend
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

  • Create New...