-- Loop forever

while true do
	if isOnVar.Value then
		local minsAfterMidnight = (USE_CUSTOM_TIME) and minsAfterMidnightVar.Value or math.floor(lightingService:GetMinutesAfterMidnight())
		minsAfterMidnightVar.Value = minsAfterMidnight
		TryUpdate(minsAfterMidnight)
		
		if not prevIsOn then
			prevIsOn = true
			screen.Visible = true
		end
	else if prevIsOn then
			prevIsOn = false
			screen.Visible = false
		end
	end
	
	wait(msPerUpdateVar.Value/1000)
end
