Skip to content

Commit 4651b2a

Browse files
authored
Merge pull request #54417 from Anutrix/global-scope-doc-updates
Added or improved function description and codeblocks in @GlobalScope.xml
2 parents 7538c05 + 4212924 commit 4651b2a

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

doc/classes/@GlobalScope.xml

+49
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,26 @@
1414
<return type="Variant" />
1515
<argument index="0" name="x" type="Variant" />
1616
<description>
17+
Returns the absolute value of a [Variant] parameter [code]x[/code] (i.e. non-negative value). Variant types [int], [float] (real), [Vector2], [Vector2i], [Vector3] and [Vector3i] are supported.
18+
[codeblock]
19+
var a = abs(-1)
20+
# a is 1
21+
22+
var b = abs(-1.2)
23+
# b is 1.2
24+
25+
var c = abs(Vector2(-3.5, -4))
26+
# c is (3.5, 4)
27+
28+
var d = abs(Vector2i(-5, -6))
29+
# d is (5, 6)
30+
31+
var e = abs(Vector3(-7, 8.5, -3.8))
32+
# e is (7, 8.5, 3.8)
33+
34+
var f = abs(Vector3i(-7, -8, -9))
35+
# f is (7, 8, 9)
36+
[/codeblock]
1737
</description>
1838
</method>
1939
<method name="absf">
@@ -118,6 +138,26 @@
118138
<argument index="1" name="min" type="Variant" />
119139
<argument index="2" name="max" type="Variant" />
120140
<description>
141+
Clamps the [Variant] [code]value[/code] and returns a value not less than [code]min[/code] and not more than [code]max[/code]. Variant types [int], [float] (real), [Vector2], [Vector2i], [Vector3] and [Vector3i] are supported.
142+
[codeblock]
143+
var a = clamp(-10, -1, 5)
144+
# a is -1
145+
146+
var b = clamp(8.1, 0.9, 5.5)
147+
# b is 5.5
148+
149+
var c = clamp(Vector2(-3.5, -4), Vector2(-3.2, -2), Vector2(2, 6.5))
150+
# c is (-3.2, -2)
151+
152+
var d = clamp(Vector2i(7, 8), Vector2i(-3, -2), Vector2i(2, 6))
153+
# d is (2, 6)
154+
155+
var e = clamp(Vector3(-7, 8.5, -3.8), Vector3(-3, -2, 5.4), Vector3(-2, 6, -4.1))
156+
# e is (-3, -2, 5.4)
157+
158+
var f = clamp(Vector3i(-7, -8, -9), Vector3i(-1, 2, 3), Vector3i(-4, -5, -6))
159+
# f is (-4, -5, -6)
160+
[/codeblock]
121161
</description>
122162
</method>
123163
<method name="clampf">
@@ -347,6 +387,7 @@
347387
<return type="bool" />
348388
<argument index="0" name="id" type="int" />
349389
<description>
390+
Returns [code]true[/code] if the Object that corresponds to [code]instance_id[/code] is a valid object (e.g. has not been deleted from memory). All Objects have a unique instance ID.
350391
</description>
351392
</method>
352393
<method name="is_instance_valid">
@@ -750,6 +791,14 @@
750791
<return type="Variant" />
751792
<argument index="0" name="x" type="Variant" />
752793
<description>
794+
Returns the sign of [code]x[/code] as same type of [Variant] as [code]x[/code] with each component being -1, 0 and 1 for each negative, zero and positive values respectivelu. Variant types [int], [float] (real), [Vector2], [Vector2i], [Vector3] and [Vector3i] are supported.
795+
[codeblock]
796+
sign(-6.0) # Returns -1
797+
sign(0.0) # Returns 0
798+
sign(6.0) # Returns 1
799+
800+
sign(Vector3(-6.0, 0.0, 6.0) # Returns (-1, 0, 1)
801+
[/codeblock]
753802
</description>
754803
</method>
755804
<method name="signf">

0 commit comments

Comments
 (0)