summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rw-r--r--doc/classes/@GDScript.xml13
-rw-r--r--doc/classes/UndoRedo.xml22
-rw-r--r--doc/classes/int.xml16
3 files changed, 35 insertions, 16 deletions
diff --git a/doc/classes/@GDScript.xml b/doc/classes/@GDScript.xml
index a7b58352cc..7b4b3e43ba 100644
--- a/doc/classes/@GDScript.xml
+++ b/doc/classes/@GDScript.xml
@@ -811,7 +811,7 @@
<description>
Random range, any floating point value between [code]from[/code] and [code]to[/code].
[codeblock]
- prints(rand_range(0, 1), rand_range(0, 1)) # prints 0.135591 0.405263
+ prints(rand_range(0, 1), rand_range(0, 1)) # prints e.g. 0.135591 0.405263
[/codeblock]
</description>
</method>
@@ -830,7 +830,7 @@
<description>
Returns a random floating point value on the interval [code][0, 1][/code].
[codeblock]
- randf() # returns 0.375671
+ randf() # returns e.g. 0.375671
[/codeblock]
</description>
</method>
@@ -838,11 +838,12 @@
<return type="int">
</return>
<description>
- Returns a random 32 bit integer. Use remainder to obtain a random value in the interval [code][0, N][/code] (where N is smaller than 2^32 -1).
+ Returns a random unsigned 32 bit integer. Use remainder to obtain a random value in the interval [code][0, N][/code] (where N is smaller than 2^32 -1).
[codeblock]
- randi() % 20 # returns random number between 0 and 19
- randi() % 100 # returns random number between 0 and 99
- randi() % 100 + 1 # returns random number between 1 and 100
+ randi() # returns random integer between 0 and 2^32 - 1
+ randi() % 20 # returns random integer between 0 and 19
+ randi() % 100 # returns random integer between 0 and 99
+ randi() % 100 + 1 # returns random integer between 1 and 100
[/codeblock]
</description>
</method>
diff --git a/doc/classes/UndoRedo.xml b/doc/classes/UndoRedo.xml
index 93806ac326..8d98bcfdb0 100644
--- a/doc/classes/UndoRedo.xml
+++ b/doc/classes/UndoRedo.xml
@@ -8,22 +8,22 @@
Common behavior is to create an action, then add do/undo calls to functions or property changes, then committing the action.
Here's an example on how to add an action to Godot editor's own 'undoredo':
[codeblock]
- var undoredo = get_undo_redo() # method of EditorPlugin
+ var undo_redo = get_undo_redo() # Method of EditorPlugin.
func do_something():
- pass # put your code here
+ pass # Put your code here.
func undo_something():
- pass # put here the code that reverts what's done by "do_something()"
+ pass # Put here the code that reverts what's done by "do_something()".
func _on_MyButton_pressed():
var node = get_node("MyNode2D")
- undoredo.create_action("Move the node")
- undoredo.add_do_method(self, "do_something")
- undoredo.add_undo_method(self, "undo_something")
- undoredo.add_do_property(node, "position", Vector2(100,100))
- undoredo.add_undo_property(node, "position", node.position)
- undoredo.commit_action()
+ undo_redo.create_action("Move the node")
+ undo_redo.add_do_method(self, "do_something")
+ undo_redo.add_undo_method(self, "undo_something")
+ undo_redo.add_do_property(node, "position", Vector2(100,100))
+ undo_redo.add_undo_property(node, "position", node.position)
+ undo_redo.commit_action()
[/codeblock]
[method create_action], [method add_do_method], [method add_undo_method], [method add_do_property], [method add_undo_property], and [method commit_action] should be called one after the other, like in the example. Not doing so could lead to crashes.
If you don't need to register a method you can leave [method add_do_method] and [method add_undo_method] out, and so it goes for properties. You can register more than one method/property.
@@ -125,6 +125,7 @@
</argument>
<description>
Create a new action. After this is called, do all your calls to [method add_do_method], [method add_undo_method], [method add_do_property], and [method add_undo_property], then commit the action with [method commit_action].
+ The way actions are merged is dictated by the [code]merge_mode[/code] argument. See [enum MergeMode] for details.
</description>
</method>
<method name="get_current_action_name" qualifiers="const">
@@ -159,10 +160,13 @@
</methods>
<constants>
<constant name="MERGE_DISABLE" value="0" enum="MergeMode">
+ Makes [code]do[/code]/[code]undo[/code] operations stay in separate actions.
</constant>
<constant name="MERGE_ENDS" value="1" enum="MergeMode">
+ Makes so that the action's [code]do[/code] operation is from the first action created and the [code]undo[/code] operation is from the last subsequent action with the same name.
</constant>
<constant name="MERGE_ALL" value="2" enum="MergeMode">
+ Makes subsequent actions with the same name be merged into one.
</constant>
</constants>
</class>
diff --git a/doc/classes/int.xml b/doc/classes/int.xml
index 4855fa2848..7175b9fd88 100644
--- a/doc/classes/int.xml
+++ b/doc/classes/int.xml
@@ -4,7 +4,21 @@
Integer built-in type.
</brief_description>
<description>
- Integer built-in type.
+ Signed 64-bit integer type.
+ It can take values in the interval [code][-2^63, 2^63 - 1][/code], i.e. [code][-9223372036854775808, 9223372036854775807][/code]. Exceeding those bounds will wrap around.
+ [code]int[/code] is a [Variant] type, and will thus be used when assigning an integer value to a [Variant]. It can also be enforced with the [code]: int[/code] type hint.
+ [codeblock]
+ var my_variant = 0 # int, value 0
+ my_variant += 4.2 # float, value 4.2
+ var my_int: int = 1 # int, value 1
+ my_int = 4.2 # int, value 4, the right value is implicitly cast to int
+ my_int = int("6.7") # int, value 6, the String is explicitly cast with [method int]
+
+ var max_int = 9223372036854775807
+ print(max_int) # 9223372036854775807, OK
+ max_int += 1
+ print(max_int) # -9223372036854775808, we overflowed and wrapped around
+ [/codeblock]
</description>
<tutorials>
</tutorials>