Does anyone know a simple javascript function that will choose a scene based on which combination of timelines have run? In my simple example there are three coloured boxes. For example, if the red and blue box timelines have been triggered i would like to jump to scene redblue on the jump to scene button but if only the red timeline has been triggered it would jump to the red scene etc etc.
Thanks for the response but I don’t think that’s quite what I’m after. I need to jump to particular scene based on which combination of timelines have been triggered.
I’ve tried using the end time in each timeline as a variable and using the total (y) to choose which scene it jumps to on a mouse click of the button. It does not work but I’m stumped.
What showed up for me regarding the code not running properly for the “SceneSelector” function is You are missing a bracket on line 39 (missing bracket shown & highlighted in attached file).
//init ( run this bit eonce)
if(typeof hypeDocument.customData.timelinesRan == 'undefined' ){
//-- we will add the timeline name here so we only count it once
hypeDocument.customData.timelinesRan = []
//-- this will be our counter
hypeDocument.customData.timelinesCounter = 0
}
//-- always run below
//-- timeline names and values
var runList = {'bluetl':5,'greentl':1,'redtl':3}
//-- which timeline called this function
var timelineName = event.timelineName
var thisTimelinenumber = runList[timelineName]
//-- timeline name is not in array
if (!hypeDocument.customData.timelinesRan.includes(timelineName)){
//-- add timeline name
hypeDocument.customData.timelinesRan.push()
//-- sum up the total
hypeDocument.customData.timelinesCounter += thisTimelinenumber
}
Then change your other function to
var result = hypeDocument.customData.timelinesCounter
if (result == 1) {
hypeDocument.showSceneNamed('green', hypeDocument.kSceneTransitionCrossfade, 1.1);
} else if (result == 3) {
hypeDocument.showSceneNamed('red', hypeDocument.kSceneTransitionInstant, 1.1);
} else if (result == 5) {
hypeDocument.showSceneNamed('blue', hypeDocument.kSceneTransitionCrossfade, 1.1);
} else if (result == 4) {
hypeDocument.showSceneNamed('redgreen', hypeDocument.kSceneTransitionCrossfade, 1.1);
} else if (result == 6) {
hypeDocument.showSceneNamed('greenblue', hypeDocument.kSceneTransitionCrossfade, 1.1);
} else if (result == 8) {
hypeDocument.showSceneNamed('redblue', hypeDocument.kSceneTransitionCrossfade, 1.1);
} else {
hypeDocument.showSceneNamed('redgreenblue', hypeDocument.kSceneTransitionCrossfade, 1.1);
}