JS Callback

13 September 2016 03:02 #11761
I'm having trouble getting the JS Callback to work.

From these forums I downloaded the Mighty_Button_111 for example and I've watched https://youtu.be/dWEHg5Yzcys?t=1113
several times, I'm just trying to get it to show me some output in the console to show that it's working but I get an error.

I'm using the default generated code from my project and inserting the Mighty_Button code in with minor changes.

Does anyone know what I'm doing wrong here?

var m_logic_nodes   = require("logic_nodes");

function init_cb(canvas_elem, success) {

if (!success) {
console.log("b4w init failure");


// ignore right-click on the canvas element
canvas_elem.oncontextmenu = function(e) {
return false;

m_logic_nodes.append_custom_callback("get_hours", get_hours_callback);

function get_hours_callback(in_params, out_params) {
var date = new Date();
var hours = date.getHours();

out_params[0] = hours;

On the console I get this message:

B4W ERROR: logic script error: no custom callback with id get_hours
13 September 2016 10:55 #11765
Does anyone know what I'm doing wrong here?

Everything looks correct. Could you please export and attach your project archive
Blend4Web Team - developer
13 September 2016 13:39 #11770
I confess I never used the JS Callback node.
I'm guessing here. But it seems that your function need to be called get_hours and not get_hours_callback.
Cause get_hours was the Callback ID used on your blender file.
13 September 2016 20:09 #11774
Hi Konstantin, thanks.

I've zipped and posted the whole project for download here:

hopefully just something simple.

RussoFaccin, thanks for responding.
Have a look at the link I provided, "get_hours" is a string containing the callback id which the logic nodes access. The function name is get_hours_callback.. on that note .. I even did try putting the get_hours_callback into the logic node to see if I could get anything to work ;) no luck!

13 September 2016 20:18 #11775
I'm using Blender 2.77a and B4W 16.08.

I built more or less the same test twice on a windows 7 machine and a windows 10 machine with identical Blender and B4W versions with the same result… so likely I'm making the same mistake on both

14 September 2016 12:05 #11784
I've zipped and posted the whole project for download here:

hopefully just something simple.
Hi, Mike!
I think I know what 's wrong
You probably open your blend4web scene with "Fast Preview" which has nothing to do with launching your project from the project manager.
"Fast Preview" uses "Scene Viewer" app only to preview your scene. So code from your project's JS file isn't executed at all.

So the only thing you need to do is to launch your project from the project manager menu

P.S. Projects can be easily exported/imported from the project manager's toolbar:
Blend4Web Team - developer
14 September 2016 17:59 #11798
I did try publishing to my webserver but I must have done something wrong on that step.. now that it's functioning I can continue ..

Thanks for your help!
Please register or log in to leave a reply.