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 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 Share on other sites More sharing options...
Gathouria Posted February 5, 2018 Author Share Posted February 5, 2018 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. Link to comment 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 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 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.