|
14 | 14 | <return type="Variant" />
|
15 | 15 | <argument index="0" name="x" type="Variant" />
|
16 | 16 | <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] |
17 | 37 | </description>
|
18 | 38 | </method>
|
19 | 39 | <method name="absf">
|
|
118 | 138 | <argument index="1" name="min" type="Variant" />
|
119 | 139 | <argument index="2" name="max" type="Variant" />
|
120 | 140 | <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] |
121 | 161 | </description>
|
122 | 162 | </method>
|
123 | 163 | <method name="clampf">
|
|
347 | 387 | <return type="bool" />
|
348 | 388 | <argument index="0" name="id" type="int" />
|
349 | 389 | <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. |
350 | 391 | </description>
|
351 | 392 | </method>
|
352 | 393 | <method name="is_instance_valid">
|
|
750 | 791 | <return type="Variant" />
|
751 | 792 | <argument index="0" name="x" type="Variant" />
|
752 | 793 | <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] |
753 | 802 | </description>
|
754 | 803 | </method>
|
755 | 804 | <method name="signf">
|
|
0 commit comments