Forum

Get date in the logic node editor

06 September 2016 16:10 #11640
Hello again,

I don't succeed in understanding how to make it work.

I would like to get hour in a variable and minute in another in order to change rotation of a clock hands.

I have put the Konstantin's code between scripts tags in the head of my html frame like this :

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Montre</title>
<script>
var m_logn  = require("logic_nodes);

function app_initialization(canvas_elem, success) {
	m_logn.append_custom_callback("get_hours", get_hours_callback);
	load_scene();
}
function get_hours_callback(in_params, out_params) {
var mydate = new Date();
var hour = mydate.getHours();
var minute = mydate.getMinutes();

out_params[0] = hour; minute;

}
</script>
</head>
<body bgcolor="#000000" bottommargin="0" topmargin="0" leftmargin="0" rightmargin="0" marginheight="0" marginwidth="0"><center>

<div id="tr" overflow=" hidden">
				<iframe id="video"name="anim"  style =" width : 900px ; height :500px; background-color : #000000;"  frameborder = "no" color = "#000000" allowfullscreen src="webplayer.html?load=HorlogeTestCode.json&no_social"></iframe>
				</div>

</body></html>


And I have inserted a JS callback node in my blend file which call get_hours ID like the file attached

But, of course, the minute hand of my clock doesn't move to the right position when I open the scene in browser.

Could you guide me please ?
06 September 2016 17:07 #11642
And I have inserted a JS callback node in my blend file which call get_hours ID like the file attached

But, of course, the minute hand of my clock doesn't move to the right position when I open the scene in browser.

Could you guide me please ?
Hello!

Unfortunately JS scripting is not available in HTML, or WebPlayer projects.
I've attached a project archive from my presentation (node logic is not complete), so you can explore how html and JS files look like. Project can be imported via project manager interface
Blend4Web Team - developer
07 September 2016 17:48 #11668
Greatful thanks again !!

Now I can have my watch synchronised with the user's computer.

Wonderful.

But, since I'm not using the WebPlayer in order to have it working, I don't know how to allow the user to toggle in fullscreen if desired.
Is there a simple code to add in my html, CSS and js files ?

Thank you by advance.
 
Please register or log in to leave a reply.