summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Franke <arnfranke@yahoo.com>2020-06-21 01:50:28 -0400
committerAaron Franke <arnfranke@yahoo.com>2020-06-21 03:08:28 -0400
commit08577fab145d797b204822829477ff2087ac3c39 (patch)
tree618195e45825ffcebef8f35ba31b32800c00eac7
parent2753f0ae8378eeb081649c3a25a2b9c856e67aeb (diff)
Update bool documentation to be more clear
-rw-r--r--doc/classes/bool.xml13
1 files changed, 7 insertions, 6 deletions
diff --git a/doc/classes/bool.xml b/doc/classes/bool.xml
index 4482a280b2..869fc14d40 100644
--- a/doc/classes/bool.xml
+++ b/doc/classes/bool.xml
@@ -4,14 +4,14 @@
Boolean built-in type.
</brief_description>
<description>
- Boolean is a built-in type. It can represent any data type that is either a true or false value. You can think of it as an switch with on or off (1 or 0) setting. It's often used as part of programming logic in condition statements like [code]if[/code] statements.
- [b]Note:[/b] In a code below [code]if can_shoot[/code] is equivalent of [code]if can_shoot == true[/code]. It is good practice to follow the natural spoken language structure when possible. Use [code]if can_shoot[/code] rather than [code]if can_shoot == true[/code] and use [code]if not can_shoot[/code] rather than [code]if can_shoot == false[/code].
+ Boolean is a built-in type. There are two boolean values: [code]true[/code] and [code]false[/code]. You can think of it as an switch with on or off (1 or 0) setting. Booleans are used in programming for logic in condition statements, like [code]if[/code] statements.
+ Booleans can be directly used in [code]if[/code] statements. The code below demonstrates this on the [code]if can_shoot:[/code] line. You don't need to use [code]== true[/code], you only need [code]if can_shoot:[/code]. Similarly, use [code]if not can_shoot:[/code] rather than [code]== false[/code].
[codeblock]
var can_shoot = true
func shoot():
if can_shoot:
- # Perform shooting actions here.
+ pass # Perform shooting actions here.
[/codeblock]
The following code will only create a bullet if both conditions are met: action "shoot" is pressed and if [code]can_shoot[/code] is [code]true[/code].
[b]Note:[/b] [code]Input.is_action_pressed("shoot")[/code] is also a boolean that is [code]true[/code] when "shoot" is pressed and [code]false[/code] when "shoot" isn't pressed.
@@ -46,7 +46,7 @@
<argument index="0" name="from" type="int">
</argument>
<description>
- Cast an [int] value to a boolean value, this method will return [code]true[/code] if called with an integer value different to 0 and [code]false[/code] in other case.
+ Cast an [int] value to a boolean value, this method will return [code]false[/code] if [code]0[/code] is passed in, and [code]true[/code] for all other ints.
</description>
</method>
<method name="bool">
@@ -55,7 +55,7 @@
<argument index="0" name="from" type="float">
</argument>
<description>
- Cast a [float] value to a boolean value, this method will return [code]true[/code] if called with a floating-point value different to 0 and [code]false[/code] in other case.
+ Cast a [float] value to a boolean value, this method will return [code]false[/code] if [code]0.0[/code] is passed in, and [code]true[/code] for all other floats.
</description>
</method>
<method name="bool">
@@ -64,7 +64,8 @@
<argument index="0" name="from" type="String">
</argument>
<description>
- Cast a [String] value to a boolean value, this method will return [code]true[/code] if called with a non-empty string and [code]false[/code] in other case. Examples: [code]bool("False")[/code] returns [code]true[/code], [code]bool("")[/code] returns [code]false[/code].
+ Cast a [String] value to a boolean value, this method will return [code]false[/code] if [code]""[/code] is passed in, and [code]true[/code] for all non-empty strings.
+ Examples: [code]bool("False")[/code] returns [code]true[/code], [code]bool("")[/code] returns [code]false[/code].
</description>
</method>
</methods>