Report post

Are you sure you want to report the post shown below? This will send an email to the ATVO administrators. Please include a short reason for reporting.

Users reporting for no reason may be locked out.


Post

Posted by Nick Thissen
on
You'd need some way to distinguish daytime from night time, most likely using the time of day in the sim. How you do that exactly is up to you. At the very least you'd need a script that checks both the time of day, and the sky type.

The easiest I can think of is to append "Night" to the sky name when the time is between certain hours (e.g. 8pm and 7am). Then you'd name your night images as "Clear Night", "Mostly Cloudy Night", etc. Then, use a script like below to decide when to append "Night" to the sky. Use that script as the converter script for your dynamic image binding.

Note: the binding should now consist of two bindings: (1) the "livedatetime_object" and (2) the "sky" binding.



using System;
using ATVO.ThemesSDK;
using ATVO.ThemeEditor.ThemeModels;
using ATVO.ThemeEditor.Scripting.DotNET;

namespace Scripts
{
public class WeatherConverter : IScript
{
public object Execute(ThemeContentItem item, object value, string parameter, ISimulation sim)
{
if (value == null)
return null;

var values = (object[])value;
if (values?.Length != 2)
return null;

// Get the two binding values
// First binding should be: "livedatetime_object"
// Second binding should be: "sky"
var time = (DateTime) values[0];
var sky = (string) values[1];

// When is "night time"?
// Arbitrary choice here: between 20:00 and 07:00
if (time.Hour > 20 || time.Hour < 7)
{
// Append "night" to the sky name
sky = sky + " Night";
}

return sky;
}
}
}