Time of Day scene-loading?


#1

Hey gang,

I’ve been trying to load different scene based on Time of Day on page-load, and naturally Not Quite Getting It. Any suggestions here?

Here’s my code (using 10 for afternoon for testing purposes):

var myDate = new Date(); 
if ( myDate.getHours() > 18 )  
	{ 
		hypeDocument.showSceneNamed('evening');
	} else if { ( myDate.getHours() > 10 )			
		hypeDocument.showSceneNamed('afternoon');
	}				

}

dayornight.hype.zip (27.2 KB)

Thank you to all in advance…


(René) #2

Typo! You misplaced the bracket, it should be:
var myDate = new Date();

if ( myDate.getHours() > 18 ){ 
	hypeDocument.showSceneNamed('evening');
} else if ( myDate.getHours() > 10 ){	
	hypeDocument.showSceneNamed('afternoon');
}

(René) #3

I should use a ‘start’-scene with the script on scene-load. Check this out: dayornight.hype.zip (31.1 KB)


#4

Oh ffs :wink: KILL ME NOW. Un grand merci René! (with the assumption you’re French-speaking)


(René) #5

You’re welcome, it was nothing…
:slight_smile:
Although my name is French, I’m born and raised in the Netherlands :wink:


#6

Aaah, that’s two silly mistakes today. Apologies René!