JS Callback
13 September 2016 03:02
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?
On the console I get this message:
B4W ERROR: logic script error: no custom callback with id get_hours
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");
return;
}
m_preloader.create_preloader();
// ignore right-click on the canvas element
canvas_elem.oncontextmenu = function(e) {
e.preventDefault();
e.stopPropagation();
return false;
};
m_logic_nodes.append_custom_callback("get_hours", get_hours_callback);
load();
}
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
13 September 2016 13:39
13 September 2016 20:09
Hi Konstantin, thanks.
I've zipped and posted the whole project for download here:
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!
Link
I've zipped and posted the whole project for download here:
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!
Link
13 September 2016 20:18
14 September 2016 12:05
I've zipped and posted the whole project for download here:Hi, Mike!
Here
hopefully just something simple.
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:
14 September 2016 17:59