How do I run actions from Scripts?

I wish to put a subtitle message from an end of a script depending on some conditons. Im not sure how to do this
Thanks

Dont think you can yet, or should I say only a few actions can be triggered from script at the moment.
Pretty sure subtitle isnt one of them.
You would typically call a script within the update subtitle action and the script returns the subtitle dependent on conditions.

Oh right… Ill try to get this working! A few other questions, how do you get the current time in the script?

The .NET way …

var dt = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");

The JScript way …

Using formatting from Windows …

var dt = new Date().toLocaleString()

Roll your own …

function getDateTime()
{
	var now = new Date();
	
	var dy = now.getDate();
	var mo = now.getMonth()+1; // month is 0-based, so we add 1
	var yr = now.getFullYear();
	var hr = now.getHours();
	var mi = now.getMinutes();
	var se = now.getSeconds();
	
	// build output like 2016-05-11_19.00.49
	// making sure to left-zero-pad numbers less than 10
	var dT = "";
	dT += yr
	dT += "-" + (mo < 10 ? '0'+mo : mo);
	dT += "-" + (dy < 10 ? '0'+dy : dy);
	dT += "_" + (hr < 10 ? '0'+hr : hr);
	dT += "." + (mi < 10 ? '0'+mi : mi);
	dT += "." + (se < 10 ? '0'+se : se);
	
	return dT;
}
1 Like

I did a different way and it seemed to work :slight_smile:

[code] var currentdate = new Date();
var datetime = currentdate.getDate() + “/”
+ (currentdate.getMonth()+1) + “/”
+ currentdate.getFullYear() + " @ "
+ currentdate.getHours() + “:”
+ currentdate.getMinutes() + “:”
+ currentdate.getSeconds();

        return datetime;[/code]