summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2016-08-07 20:08:15 -0300
committerJuan Linietsky <reduzio@gmail.com>2016-08-07 20:08:15 -0300
commit0b8f0670c54ea8697806e3560b7dc99b93f923ea (patch)
tree2bc54bc19f4b7651de4626fcc734827b38d46df4
parentb77200728e7f2b2dd446a9717c83a20c9aac0ce4 (diff)
Automatically turn on process callbacks if relevant callbacks in node exists
-rw-r--r--core/os/keyboard.cpp2
-rw-r--r--modules/visual_script/visual_script.cpp17
2 files changed, 18 insertions, 1 deletions
diff --git a/core/os/keyboard.cpp b/core/os/keyboard.cpp
index 26b481840a..9710638234 100644
--- a/core/os/keyboard.cpp
+++ b/core/os/keyboard.cpp
@@ -443,7 +443,7 @@ int keycode_get_count() {
}
int keycode_get_value_by_index(int p_index) {
- _keycodes[p_index].code;
+ return _keycodes[p_index].code;
}
const char* keycode_get_name_by_index(int p_index) {
diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp
index 9074a08bf4..50de59b466 100644
--- a/modules/visual_script/visual_script.cpp
+++ b/modules/visual_script/visual_script.cpp
@@ -1,5 +1,7 @@
#include "visual_script.h"
#include "visual_script_nodes.h"
+#include "scene/main/node.h"
+
#include "globals.h"
#define SCRIPT_VARIABLES_PREFIX "script_variables/"
@@ -1848,6 +1850,21 @@ void VisualScriptInstance::create(const Ref<VisualScript>& p_script,Object *p_ow
max_input_args = 0;
max_output_args = 0;
+ if (p_owner->cast_to<Node>()) {
+ //turn on these if they exist and base is a node
+ Node* node = p_owner->cast_to<Node>();
+ if (p_script->functions.has("_process"))
+ node->set_process(true);
+ if (p_script->functions.has("_fixed_process"))
+ node->set_fixed_process(true);
+ if (p_script->functions.has("_input"))
+ node->set_process_input(true);
+ if (p_script->functions.has("_unhandled_input"))
+ node->set_process_unhandled_input(true);
+ if (p_script->functions.has("_unhandled_key_input"))
+ node->set_process_unhandled_key_input(true);
+ }
+
for(const Map<StringName,VisualScript::Variable>::Element *E=script->variables.front();E;E=E->next()) {
variables[E->key()]=E->get().default_value;
}