Javascript actor with trigger input
-
I wanted to confirm that there's a way to interact with a javascript actor using a trigger input. If an actor that outputs a trigger is connected to an input, it changes to a trigger input. It's not clear how the code would be configured to listen for that input. Is it a boolean? or?
ThanksTom -
For example, I would like to randomly generate a value from a range other than 0-100. Using the random actor seems to generate a number heavily weighted towards whatever the max value selected is (i.e. it's generating 0-100 and rounding down to the max value.) I need it to generate a new value every time it is triggered by something.
so I wrote this code:function main()
{
var min = arguments[0];
var max = arguments[1];
var trig = arguments[2];
if (trig !== null) {
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
}
}
-
And... the answer is yes. It does work, I just suck at troubleshooting code.
here's the updated:function main()
{
var min = arguments[0];
var max = arguments[1];
var trig = arguments[2];
if (trig !== null) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
}
-
I am glad you worked it out...
How triggers are handled could be better covered in the tutorials.. I will look at making some updates. -
Speaking of how stuff is handled... I was trying to figure out today if it was possible to use javascript to determine the size (height and width in px) of an image file? The actor accepts image files as input...
-
Dear @tadakan,
Well, by "image file" I think you mean a media index -- i.e., a number. Javascript would not have the capability to access the necessary information from that number to give you the duration I'm afraid.Best Wishes,Mark -
Thanks Mark, that's what I meant, thanks for translating my thoughts.
Tom