Jump to content

Recommended Posts

So I'm in the middle of basing a DS mod off a DST one and have gotten a good way in and have some stuff working, but this is my first mod so I'm learning with it. I translated over the firepit countdown fine with what I've gleaned the code structure is, but I don't see how to access the world's clock/other world variables.

My intent for it is to read from the clock and display, either during night or dusk and night, how much time is left until morning. I could probably figure out that part by trial and error after figuring out how to access the clock, but I don't see how to access it in the first place.

Link to comment
https://forums.kleientertainment.com/forums/topic/87149-accessing-world-clock/
Share on other sites

15 hours ago, Gathouria said:

I don't see how to access it

GetClock()

15 hours ago, Gathouria said:

My intent for it is to read from the clock and display, either during night or dusk and night, how much time is left until morning.

function TimeUntilDaytime()
  local phase = GetClock():GetPhase()
  if phase == "day" then return 0 end
  return GetClock():GetTimeLeftInEra() + (phase == "dusk" and GetClock():GetNightTime() or 0)
end

Though it probably won't work properly in worlds with no daytime.

For some reason my game seems to crash when I call on GetClock, so I assumed I wasn't doing it correctly. I'm being told it's a nil value. I have

local Clock = require "components/clock"

which I thought would correct that, but doesn't seem to.

Edited by Gathouria

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