summaryrefslogtreecommitdiff
path: root/modules/gdscript
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gdscript')
-rw-r--r--modules/gdscript/gd_editor.cpp3
-rw-r--r--modules/gdscript/gd_function.cpp6
-rw-r--r--modules/gdscript/gd_functions.cpp32
-rw-r--r--modules/gdscript/gd_functions.h2
-rw-r--r--modules/gdscript/gd_script.cpp2
5 files changed, 39 insertions, 6 deletions
diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gd_editor.cpp
index f8b45af85a..3fa0a38024 100644
--- a/modules/gdscript/gd_editor.cpp
+++ b/modules/gdscript/gd_editor.cpp
@@ -35,6 +35,7 @@
#ifdef TOOLS_ENABLED
#include "editor/editor_file_system.h"
#include "editor/editor_settings.h"
+#include "engine.h"
#endif
void GDScriptLanguage::get_comment_delimiters(List<String> *p_delimiters) const {
@@ -2371,7 +2372,7 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base
String GDScriptLanguage::_get_indentation() const {
#ifdef TOOLS_ENABLED
- if (SceneTree::get_singleton()->is_editor_hint()) {
+ if (Engine::get_singleton()->is_editor_hint()) {
bool use_space_indentation = EDITOR_DEF("text_editor/indent/type", 0);
if (use_space_indentation) {
diff --git a/modules/gdscript/gd_function.cpp b/modules/gdscript/gd_function.cpp
index cafcc1e965..13a7480a36 100644
--- a/modules/gdscript/gd_function.cpp
+++ b/modules/gdscript/gd_function.cpp
@@ -1233,10 +1233,10 @@ int GDFunction::get_default_argument_count() const {
return default_arguments.size();
}
-int GDFunction::get_default_argument_addr(int p_arg) const {
+int GDFunction::get_default_argument_addr(int p_idx) const {
- ERR_FAIL_INDEX_V(p_arg, default_arguments.size(), -1);
- return default_arguments[p_arg];
+ ERR_FAIL_INDEX_V(p_idx, default_arguments.size(), -1);
+ return default_arguments[p_idx];
}
StringName GDFunction::get_name() const {
diff --git a/modules/gdscript/gd_functions.cpp b/modules/gdscript/gd_functions.cpp
index 209bdadd67..65f0cbbe7d 100644
--- a/modules/gdscript/gd_functions.cpp
+++ b/modules/gdscript/gd_functions.cpp
@@ -70,6 +70,8 @@ const char *GDFunctions::get_func_name(Function p_func) {
"decimals",
"stepify",
"lerp",
+ "inverse_lerp",
+ "range_lerp",
"dectime",
"randomize",
"randi",
@@ -326,6 +328,22 @@ void GDFunctions::call(Function p_func, const Variant **p_args, int p_arg_count,
VALIDATE_ARG_NUM(2);
r_ret = Math::lerp((double)*p_args[0], (double)*p_args[1], (double)*p_args[2]);
} break;
+ case MATH_INVERSE_LERP: {
+ VALIDATE_ARG_COUNT(3);
+ VALIDATE_ARG_NUM(0);
+ VALIDATE_ARG_NUM(1);
+ VALIDATE_ARG_NUM(2);
+ r_ret = Math::inverse_lerp((double)*p_args[0], (double)*p_args[1], (double)*p_args[2]);
+ } break;
+ case MATH_RANGE_LERP: {
+ VALIDATE_ARG_COUNT(5);
+ VALIDATE_ARG_NUM(0);
+ VALIDATE_ARG_NUM(1);
+ VALIDATE_ARG_NUM(2);
+ VALIDATE_ARG_NUM(3);
+ VALIDATE_ARG_NUM(4);
+ r_ret = Math::range_lerp((double)*p_args[0], (double)*p_args[1], (double)*p_args[2], (double)*p_args[3], (double)*p_args[4]);
+ } break;
case MATH_DECTIME: {
VALIDATE_ARG_COUNT(3);
VALIDATE_ARG_NUM(0);
@@ -446,7 +464,7 @@ void GDFunctions::call(Function p_func, const Variant **p_args, int p_arg_count,
VALIDATE_ARG_COUNT(1);
VALIDATE_ARG_NUM(0);
int64_t num = *p_args[0];
- r_ret = nearest_power_of_2(num);
+ r_ret = next_power_of_2(num);
} break;
case OBJ_WEAKREF: {
VALIDATE_ARG_COUNT(1);
@@ -1252,6 +1270,8 @@ bool GDFunctions::is_deterministic(Function p_func) {
case MATH_DECIMALS:
case MATH_STEPIFY:
case MATH_LERP:
+ case MATH_INVERSE_LERP:
+ case MATH_RANGE_LERP:
case MATH_DECTIME:
case MATH_DEG2RAD:
case MATH_RAD2DEG:
@@ -1420,6 +1440,16 @@ MethodInfo GDFunctions::get_info(Function p_func) {
mi.return_val.type = Variant::REAL;
return mi;
} break;
+ case MATH_INVERSE_LERP: {
+ MethodInfo mi("inverse_lerp", PropertyInfo(Variant::REAL, "from"), PropertyInfo(Variant::REAL, "to"), PropertyInfo(Variant::REAL, "value"));
+ mi.return_val.type = Variant::REAL;
+ return mi;
+ } break;
+ case MATH_RANGE_LERP: {
+ MethodInfo mi("range_lerp", PropertyInfo(Variant::REAL, "value"), PropertyInfo(Variant::REAL, "istart"), PropertyInfo(Variant::REAL, "istop"), PropertyInfo(Variant::REAL, "ostart"), PropertyInfo(Variant::REAL, "ostop"));
+ mi.return_val.type = Variant::REAL;
+ return mi;
+ } break;
case MATH_DECTIME: {
MethodInfo mi("dectime", PropertyInfo(Variant::REAL, "value"), PropertyInfo(Variant::REAL, "amount"), PropertyInfo(Variant::REAL, "step"));
mi.return_val.type = Variant::REAL;
diff --git a/modules/gdscript/gd_functions.h b/modules/gdscript/gd_functions.h
index 93cb524118..11dfbd473c 100644
--- a/modules/gdscript/gd_functions.h
+++ b/modules/gdscript/gd_functions.h
@@ -62,6 +62,8 @@ public:
MATH_DECIMALS,
MATH_STEPIFY,
MATH_LERP,
+ MATH_INVERSE_LERP,
+ MATH_RANGE_LERP,
MATH_DECTIME,
MATH_RANDOMIZE,
MATH_RAND,
diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp
index 9d304c6d34..2d06c0f5d2 100644
--- a/modules/gdscript/gd_script.cpp
+++ b/modules/gdscript/gd_script.cpp
@@ -615,7 +615,7 @@ Error GDScript::reload(bool p_keep_state) {
if (basedir != "")
basedir = basedir.get_base_dir();
- if (basedir.find("res://") == -1 && basedir.find("user://") == -1) {
+ if (basedir != "" && basedir.find("res://") == -1 && basedir.find("user://") == -1) {
//loading a template, don't parse
return OK;
}