Gathouria Posted February 5, 2018 Share Posted February 5, 2018 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 More sharing options...
alainmcd Posted February 5, 2018 Share Posted February 5, 2018 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. Link to comment https://forums.kleientertainment.com/forums/topic/87149-accessing-world-clock/#findComment-1000005 Share on other sites More sharing options...
Gathouria Posted February 5, 2018 Author Share Posted February 5, 2018 (edited) 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 February 5, 2018 by Gathouria Link to comment https://forums.kleientertainment.com/forums/topic/87149-accessing-world-clock/#findComment-1000050 Share on other sites More sharing options...
alainmcd Posted February 5, 2018 Share Posted February 5, 2018 Use GLOBAL.GetClock() if calling it from your modmain.lua. Link to comment https://forums.kleientertainment.com/forums/topic/87149-accessing-world-clock/#findComment-1000065 Share on other sites More sharing options...
Gathouria Posted February 6, 2018 Author Share Posted February 6, 2018 Thank you! Got everything wrapped up. Link to comment https://forums.kleientertainment.com/forums/topic/87149-accessing-world-clock/#findComment-1000136 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now