JS/C++ action, JS/C++ Condition

This will allow mixing events with JS/C++. For example you know quick way of doing something in code, but you don’t want to have to figure out how to write all necessary conditions in code. Code action is for you.

Opposite scenario: You know how to poll some data that returns true or false, but don’t want to figure out how to write code you need in JS or C++. Code condition is for you.

Real world scenario: I’m making gyroscope controlled game. To poll gyroscope, I’m using following code:

[code]var xtilt = runtimeScene.getVariables().get(“xtilt”);
var ztilt = runtimeScene.getVariables().get(“ztilt”);

if (window.DeviceOrientationEvent) {
window.addEventListener(‘deviceorientation’, function(e) {
ztilt.setNumber(e.beta);
xtilt.setNumber(e.gamma);
});
}[/code]

You probably noticed problem with this code. First of all, it’s JS :wink:, secondly while this code should be ran at the start of scene, it runs every frame, which as you may deduct leads to slower game and ultimately to performance around 1fps. If I could use JS action with that code, I could put that into an event that runs at the beginning of the scene only.

How about to use the Javascript code as sub event?
screenshot.png

Didn’t even realize there’s such possibility. But still, this feature would make great sense to be added.