Difference between revisions of "VisionaireObject Command: getBool"

From The Official Visionaire Studio: Adventure Game Engine Wiki
m (Text replacement - "{{toc}}" to "")
Line 1: Line 1:
{| class="toccolours mw-collapsible mw-collapsed ts"
+
Returns the boolean value of a VisionaireObject field.
|-
 
! Function History
 
|-
 
| Available since v3.0
 
|}
 
  
  
Returns the boolean value of a linked condition. A boolean value is either <span style="color:lightgreen;">true</span> or <span class="red">false</span>.
+
== Syntax ==
 
+
<syntaxhighlight lang="lua">
 
+
getBool(field)
Syntax:
 
<syntaxhighlight>
 
getBool(t_bool)
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
  
Example: using getBool to return the boolean value of a condition
+
== Parameters ==
<syntaxhighlight>
 
getObject("Conditions[door_open]"):getBool(VConditionValue) --  return boolean value of condition "door_open"
 
</syntaxhighlight>
 
  
 +
{| class="ts"
 +
|-
 +
! style="width:15%" | Parameter
 +
! style="width:15%" | Type
 +
! Description
 +
|-
 +
| field
 +
| int
 +
| The field which specifies a boolean value. The field type must be "t_bool".
 +
''Specify the field by the field constant (V + object table name in singular + field name) or by its id, see the example.''
 +
|}
  
<span class="bold underline">Arguments</span>
 
  
none
+
== Return values ==
  
 +
{| class="ts"
 +
|-
 +
! style="width:15%" | Type
 +
! Description
 +
|-
 +
| boolean
 +
| The boolean value of the field.
 +
|}
  
<span class="bold underline">Flags</span>
 
  
none
+
== Examples ==
  
 +
'''Example 1:''' Get the boolean value of a condition.
 +
<syntaxhighlight lang="lua">
 +
-- Specify the field by the field constant
 +
local door_state = getObject("Conditions[door_closed]"):getBool(VConditionValue)
  
<span class="bold underline">Return</span>
+
-- Specify the field by its id
 +
local door_state = getObject("Conditions[door_closed]"):getBool(194)
  
'''t_bool''' <br/>
+
-- The shorthand notation offers a more convenient way to achieve the same
Returns <span style="color:lightgreen;">true</span> or <span class="red">false</span>.
+
local door_state = Conditions["door_closed"].Value
 +
</syntaxhighlight>
 +
{{toc}}

Revision as of 19:05, 11 August 2023

Returns the boolean value of a VisionaireObject field.


Syntax

getBool(field)


Parameters

Parameter Type Description
field int The field which specifies a boolean value. The field type must be "t_bool".

Specify the field by the field constant (V + object table name in singular + field name) or by its id, see the example.


Return values

Type Description
boolean The boolean value of the field.


Examples

Example 1: Get the boolean value of a condition.

-- Specify the field by the field constant
local door_state = getObject("Conditions[door_closed]"):getBool(VConditionValue)

-- Specify the field by its id
local door_state = getObject("Conditions[door_closed]"):getBool(194)

-- The shorthand notation offers a more convenient way to achieve the same
local door_state = Conditions["door_closed"].Value