summaryrefslogtreecommitdiff
path: root/modules/gdscript
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gdscript')
-rw-r--r--modules/gdscript/doc_classes/@GDScript.xml16
-rw-r--r--modules/gdscript/gdscript_parser.cpp3
2 files changed, 17 insertions, 2 deletions
diff --git a/modules/gdscript/doc_classes/@GDScript.xml b/modules/gdscript/doc_classes/@GDScript.xml
index b6de5dbf62..3eaee53789 100644
--- a/modules/gdscript/doc_classes/@GDScript.xml
+++ b/modules/gdscript/doc_classes/@GDScript.xml
@@ -1241,6 +1241,16 @@
# infinite loop between 0.0 and 0.99
f = wrapf(f + 0.1, 0.0, 1.0)
[/codeblock]
+ [codeblock]
+ # infinite rotation (in radians)
+ angle = wrapf(angle + 0.1, 0.0, TAU)
+ [/codeblock]
+ Note: If you just want to wrap between 0.0 and [code]n[/code] (where [code]n[/code] is a positive float value) then it's better for performance to use [method fmod] method like [code]fmod(number, n)[/code].
+ The usage of [code]wrapf[/code] is more flexible than using the [method fmod] approach by giving the user a simple control over the minimum value. It also fully supports negative numbers, e.g.
+ [codeblock]
+ # infinite rotation (in radians)
+ angle = wrapf(angle + 0.1, -PI, PI)
+ [/codeblock]
</description>
</method>
<method name="wrapi">
@@ -1267,6 +1277,12 @@
# infinite loop between 0 and 9
frame = wrapi(frame + 1, 0, 10)
[/codeblock]
+ Note: If you just want to wrap between 0 and [code]n[/code] (where [code]n[/code] is a positive integer value) then it's better for performance to use modulo operator like [code]number % n[/code].
+ The usage of [code]wrapi[/code] is more flexible than using the modulo approach by giving the user a simple control over the minimum value. It also fully supports negative numbers, e.g.
+ [codeblock]
+ # result is -2
+ var result = wrapi(-6, -5, -1)
+ [/codeblock]
</description>
</method>
<method name="yield">
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp
index f2afad74da..85b270b369 100644
--- a/modules/gdscript/gdscript_parser.cpp
+++ b/modules/gdscript/gdscript_parser.cpp
@@ -776,8 +776,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
}
_add_warning(GDScriptWarning::UNASSIGNED_VARIABLE_OP_ASSIGN, -1, identifier.operator String());
}
- FALLTHROUGH;
- }
+ } break;
case GDScriptTokenizer::TK_OP_ASSIGN: {
lv->assignments += 1;
lv->usages--; // Assignment is not really usage