Difference between revisions of "VisionaireObject Command: getFloat"

From The Official Visionaire Studio: Adventure Game Engine Wiki
(Created page with "Returns the decimal value of a VisionaireObject field. == Syntax == <syntaxhighlight lang="lua"> getFloat(field) </syntaxhighlight> == Parameters == {| class="ts" |- ! st...")
 
 
(One intermediate revision by the same user not shown)
Line 17: Line 17:
 
|-
 
|-
 
| field
 
| field
| int
+
| integer
 
| The field which specifies a decimal value. The field type must be "t_float".
 
| The field which specifies a decimal value. The field type must be "t_float".
''Specify the field by the field constant (V + object table name in singular + field name) or by its id, see the example.''
+
''Specify the field constant name (V + object table name in singular + field name) or the field id, see the example.''
 
|}
 
|}
  
Line 39: Line 39:
 
'''Example 1:''' Get the current size of a character.
 
'''Example 1:''' Get the current size of a character.
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- Specify the field by the field constant or by its id
+
-- Specify the field constant name or the field id
 
local char_size = getObject("Characters[hero]"):getFloat(VCharacterSize)
 
local char_size = getObject("Characters[hero]"):getFloat(VCharacterSize)
 
local char_size = getObject("Characters[hero]"):getFloat(749)
 
local char_size = getObject("Characters[hero]"):getFloat(749)

Latest revision as of 20:13, 11 August 2023

Returns the decimal value of a VisionaireObject field.


Syntax

getFloat(field)


Parameters

Parameter Type Description
field integer The field which specifies a decimal value. The field type must be "t_float".

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


Return values

Type Description
decimal The decimal value of the field.


Examples

Example 1: Get the current size of a character.

-- Specify the field constant name or the field id
local char_size = getObject("Characters[hero]"):getFloat(VCharacterSize)
local char_size = getObject("Characters[hero]"):getFloat(749)

-- The shorthand notation offers a more convenient way to achieve the same
local char_size = Characters["hero"].Size