0
Отвечен

Show messages time depending

Leandro Augusto 5 лет назад обновлен Tatiana Kiselyova (expert) 5 лет назад 4

I want to show on panel messages like Good Morning, Good Afternoon and Good Evening depending on time of the day.

I think about to use SetInteval and a function to check how time it is. But I don´t know if it is a good choice.

Can you help me?

ХОРОШО, МНЕ ПОНРАВИЛОСЬ

Thanks for helping!

Оценка удовлетворенности от Leandro Augusto 5 лет назад
+1
На рассмотрении

Hello

You can track time changes using the global listener and system time tokens.

https://dev.iridi.com/Systems_API/en#IR.SetGlobalListener

https://dev.iridi.com/Tokens_API/en#Time

Depending on the value of the token, you can show different messages. Example:

IR.AddListener(IR.EVENT_START,0,function()
{

function UpdateMessage()
{
if(IR.GetVariable("System.Time.Hour")>=6 && IR.GetVariable("System.Time.Hour")<12)
IR.Log("Goog Morning!")
if(IR.GetVariable("System.Time.Hour")>=12 && IR.GetVariable("System.Time.Hour")<18)
IR.Log("Good Afternoon!")
if(IR.GetVariable("System.Time.Hour")>=18 && IR.GetVariable("System.Time.Hour")<0)
IR.Log("Good Evening!")
if(IR.GetVariable("System.Time.Hour")>=0 && IR.GetVariable("System.Time.Hour")<6)
IR.Log("Goog Night!")

}

UpdateMessage();

IR.SetGlobalListener(IR.EVENT_GLOBAL_TAG_CHANGE, UpdateMessage);
IR.SubscribeTagChange("System.Time.Hour");
});

Sorry,

But it only works on project starting? If project is opened on panel, message doesn´t update automatically.

Hello.
The script will be triggered when the application starts, and during its operation

Сервис поддержки клиентов работает на платформе UserEcho