List of variables and functions
Variables
These variables are available by default in VTS Editor and their value evolves automatically. You cannot change them.
Variable | Type | Description |
_score | integer | Current global score. This score is equal to the sum of all skill's scores. |
_minScore | integer | Minimum overall score. This score is equal to the sum of the minimum scores for all skills. |
_maxScore | integer | Maximum overall score. This score is equal to the sum of the maximum scores for all skills. |
_time | integer | Number of whole seconds elapsed since the beginning of the scenario. |
_timeDecimal | decimal | Elapsed seconds since the beginning of the scenario. |
_timeDisplay | text | Elapsed time since the beginning of the scenario, in text format. |
_globalTimeDisplay | text | Current time (hours, minutes, seconds), in text format. |
_hour | integer | Current hour. Without minutes and seconds. |
_minute | integer | Current minute. |
_second | integer | Current second. |
_userID | text | Learner identifier used to connect to the platform. Only works if the learner is logged in, via an LMS or VTS Perform. Otherwise, returns an empty text. |
_userLastName | text | Learner's last name, as defined by the platform hosting the module. Only works if the learner is authenticated on an LMS or VTS Perform. Otherwise, returns empty text. |
_userFirstName | text | Learner's first name, as defined by the platform hosting the module. Only works if the learner is authenticated on an LMS or VTS Perform. Otherwise, returns empty text. |
_project | text | Project's name. |
_version | text | Project version (set in project settings). |
_author | text | Project author (set in project settings). |
_scenario | text | Scenario name |
_color | text | Main color of this project, defined in the project home page. |
_colorContent | text | Main content color of this project, defined in the project home page. |
_bgColor | text | Secondary color of this project, defined in the project home page. |
_bgColorContent | text | Secondary content color of this project, defined in the project home page. |
_dateDisplay | text | The date at scenario start. |
_year | integer | Current year. |
_month | integer | Current month number. |
_day | integer | Day number in the current month. |
_dayOfWeek | integer | Day of week, from 1 to 7, from monday to sunday. |
_dayOfYear | integer | Number of the current day in the year. Between 1 and 366. |
_windows | flag | true if this Experience is playing on Windows. |
_mac | flag | true if this Experience is playing on Mac. |
_android | flag | true if this Experience is playing on an Android device (smartphone or tablet). |
_iOS | flag | true if this Experience is playing on an iOS device (iPhone or iPad). |
_web | flag | true if this Experience is playing in a web browser. |
_scorm | flag | true if this Experience is playing as SCORM in an LMS. |
_computer | flag | true if this Experience is playing on a computer. |
_tablet | flag | true if this Experience is playing on a tablet. |
_smartphone | flag | true if this Experience is playing on a smartphone. |
_mobile | flag | true if this Experience is playing on a mobile device (smartphone or tablet). |
_editor | flag | true if this Experience is played in VTS Editor. Allows for example to display specific messages only during a test in VTS Editor (with a Conditions block), without having to remove them during a publication. |
_useVRControllers | flag | true if this Experience is playing on a VR headset with Controllers. |
_viewH | decimal | Horizontal angle of the camera in a 360° scenery. Between 0 and 360. |
_viewV | decimal | Vertical angle of the camera in a 360° scenery. Between -90 and 90. |
_INDEX | integer | Special variable. Can only be used when triggering a Clickable Zones block. Position of a clickable area (from 1 to N) in the list of areas of the Clickable Zones block being initialized. |
_clickedZoneIndex | integer | Number of the last clicked zone, among all the clickable zone in the block where it is defined. The number of the first zone is 1. |
_clickedZoneX | decimal | Horizontal relative position of the last clicked zone. [OBSOLETE] Please use _clickedZonePosX instead. |
_clickedZoneY | decimal | Vertical relative position of the last clicked zone. [OBSOLETE] Please use _clickedZonePosY instead. |
_clickedZonePosX | decimal | Horizontal position of the last clicked zone. (considered Anchored to the center) |
_clickedZonePosY | decimal | Vertical position of the last clicked zone. |
_clickedZoneSizeX | decimal | Width of the last clicked zone. (or right offset if stretched) |
_clickedZoneSizeY | decimal | Height of the last clicked zone. |
_countdown | integer | Time of the active Countdown block (in seconds). |
Functions
rand
rand() : decimal
Returns a random decimal number between 0 and 1.
Example | Result |
rand() | 0.504 |
rand() | 0.398 |
rand(integer a) : integer
Returns a random integer between 0 and a (exclusive).
Example | Result |
rand(2) | 0 |
rand(10) | 8 |
rand(integer a, integer b) : integer
Returns a random integer between a (inclusive) and b (exclusive).
Example | Result |
rand(-5, 3) | -3 |
rand(20, 26) | 21 |
rand(decimal a, decimal b) : decimal
Returns a random decimal number between a (inclusive) and b (exclusive).
Example | Result |
rand(2.3, 2.7) | 2.431 |
rand(0.4, 0.65) | 0.513 |
rand(list a) : value
Returns a randomly chosen element from the list a.
Example | Result |
rand([13,21,17,8]) | 17 |
rand([13,21,17,8]) | 21 |
min
min(integer a, integer b) : integer
Returns the smallest of the two values a and b.
Example | Result |
min(2, 5) | 2 |
min(18, 4) | 4 |
min(decimal a, decimal b) : decimal
Returns the smallest of the two values a and b.
Example | Result |
min(2.0, 3.7) | 2.0 |
min(14.0, 5.25) | 5.25 |
max
max(integer a, integer b) : integer
Returns the largest of the two values a and b.
Example | Result |
max(2, 5) | 5 |
max(18, 4) | 18 |
max(decimal a, decimal b) : decimal
Returns the largest of the two values a and b.
Example | Result |
max(2.0, 3.7) | 3.7 |
max(14.0, 5.25) | 14.0 |
abs
abs(integer a) : integer
Returns the absolute value of a.
Example | Result |
abs(-5) | 5 |
abs(12) | 12 |
abs(decimal a) : decimal
Returns the absolute value of a.
Example | Result |
abs(-5.32) | 5.32 |
abs(12.7) | 12.7 |
ceil
ceil(decimal a) : integer
Returns the nearest integer greater to or equal to a.
Example | Result |
ceil(2.33) | 3 |
ceil(-5.3) | -5 |
ceil(8) | 8 |
floor
floor(decimal a) : integer
Returns the nearest integer smaller to or equal to a.
Example | Result |
floor(2.33) | 2 |
floor(-5.3) | -6 |
floor(8) | 8 |
round
round(decimal a) : integer
Rounds the decimal number a to the nearest integer.
Example | Result |
round(2.33) | 2 |
round(-5.3) | -5 |
round(8) | 8 |
divide
divide(integer a, integer b) : decimal
Divides the number a by the number b, keeping the decimal part of the result (unlike a division via the / operator which keeps only the integer part of the result).
Example | Result |
divide(7, 2) | 3.5 |
divide(4, 3) | 1.333 |
divide(decimal a, decimal b) : decimal
Divides the number a by the number b, keeping the decimal part of the result (unlike a division via the / operator which keeps only the integer part of the result).
Example | Result |
divide(7, 2) | 3.5 |
divide(4, 3) | 1.333 |
clamp
clamp(integer a, integer b, integer c) : integer
Clamps the value a between the minimum b and the maximum c.
Example | Result |
clamp(2, 4, 7) | 4 |
clamp(5, 4, 7) | 5 |
clamp(decimal a, decimal b, decimal c) : decimal
Clamps the value a between the minimum b and the maximum c.
Example | Result |
clamp(2, 4, 7.0) | 4.0 |
clamp(5, 4.0, 7) | 5.0 |
clamp01
clamp01(decimal a) : decimal
Clamps the decimal number a between 0 and 1.
Example | Result |
clamp01(2.3) | 1.0 |
clamp01(0.75) | 0.75 |
pow
pow(integer a, integer b) : integer
Returns a raised to the power b.
Example | Result |
pow(2, 5) | 32 |
pow(-5, 3) | -125 |
pow(decimal a, decimal b) : decimal
Returns a raised to the power b.
Example | Result |
pow(2.0, 3) | 8.0 |
pow(-5.0, 3) | -125.0 |
sqrt
sqrt(decimal a) : decimal
Returns the square root of a.
a must be a positive number.
Example | Result |
sqrt(25) | 5.0 |
sqrt(38.3) | 6.189 |
squareRoot
squareRoot(decimal a) : decimal
Returns the square root of a.
a must be a positive number.
Example | Result |
squareRoot(25) | 5.0 |
squareRoot(38.3) | 6.189 |
exp
exp(decimal a) : decimal
Returns e raised to the power a.
Example | Result |
exp(0.0) | 1.0 |
exp(1.0) | 2.718 |
log
log(decimal a) : decimal
Returns log(a) in base e.
Example | Result |
log(1.0) | 0.0 |
log(exp(1.0)) | 1.0 |
cos
cos(decimal a) : decimal
Returns the cosine of angle a, with a in radians.
Example | Result |
cos(1) | 0.54 |
cos(_pi) | -1.0 |
cos(2 * _pi) | 1.0 |
cos(_pi / 2) | 0.0 |
sin
sin(decimal a) : decimal
Returns the sine of angle a, with a in radians.
Example | Result |
sin(1) | 0.841 |
sin(_pi) | 0.0 |
sin(2 * _pi) | 0.0 |
sin(_pi / 2) | 1.0 |
tan
tan(decimal a) : decimal
Returns the tangent of angle a, with a in radians.
Example | Result |
tan(1) | 1.557 |
tan(_pi) | 0.0 |
tan(2 * _pi) | 0.0 |
tan(_pi / 4) | 1.0 |
acos
acos(decimal a) : decimal
Returns arccos(a).
Example | Result |
acos(1 / sqrt(2)) * (180 / _pi) | 45.0 |
asin
asin(decimal a) : decimal
Returns arcsin(a).
Example | Result |
asin(1 / sqrt(2)) * (180 / _pi) | 45.0 |
atan
atan(decimal a) : decimal
Returns arctan(a).
Example | Result |
atan(1) * (180 / _pi) | 45.0 |
length
length(text a) : integer
Returns the number of characters in the text a, spaces included.
Example | Result |
length("Paris") | 5 |
length("New York") | 8 |
contains
contains(text a, text b) : flag
Returns true if the text a contains the text b.
Example | Result |
contains("Paris", "ari") | true |
contains("New York", "Yokr") | false |
contains(list a, value b) : flag
Returns true if the list a contains the value b.
Example | Result |
contains([2,3,5], 2) | true |
contains([2,3,5], 8) | false |
contains(dictionary a, value b) : flag
Returns true if the dictionary a contains the value b.
Example | Result |
contains({"foo":3,"bar":5}, 3) | true |
contains({"foo":3,"bar":5}, 8) | false |
contains(text a, text b, integer c) : flag
Returns true if the text a contains the text b with a c characters accuracy.
startsWith
startsWith(text a, text b) : flag
Returns true if the text a starts with the text b.
Example | Result |
startsWith("Paris", "Pa") | true |
startsWith("New York", "York") | false |
endsWith
endsWith(text a, text b) : flag
Returns true if the text a ends with the text b.
Example | Result |
endsWith("Paris", "Pa") | false |
endsWith("New York", "York") | true |
trim
trim(text a) : text
Returns the text a without spaces at start and end.
Example | Result |
trim(" Paris ") | "Paris" |
trim("New York") | "New York" |
removeSpaces
removeSpaces(text a) : text
Returns the text a without spaces.
Example | Result |
removeSpaces("Paris") | "Paris" |
removeSpaces("New York") | "NewYork" |
replace
replace(text a, text b, text c) : text
Returns the result of replacing text b by c in text a.
Example | Result |
replace("Paris Paris", "ris", "tate") | "Patate Patate" |
replace("New York", "ris", "tate") | "New York" |
toLower
toLower(text a) : text
Returns the text a in lower case.
Example | Result |
toLower("Paris") | "paris" |
toLower("New York") | "new york" |
toUpper
toUpper(text a) : text
Returns the text a in upper case.
Example | Result |
toUpper("Paris") | "PARIS" |
toUpper("New York") | "NEW YORK" |
firstCharToUpper
firstCharToUpper(text a) : text
Returns the text a with its first character in upper case.
Example | Result |
firstCharToUpper("paris") | "Paris" |
firstCharToUpper("new york") | "New york" |
wordsFirstCharToUpper
wordsFirstCharToUpper(text a) : text
Returns the text a, capitalizing the first character of each word and lower-casing all others.
Example | Result |
wordsFirstCharToUpper("paris") | "Paris" |
wordsFirstCharToUpper("NEW york") | "New York" |
wordsFirstCharToUpper("jean-luc picard") | "Jean-Luc Picard" |
subtext
subtext(text a, integer b) : text
In the text a, returns the text from the character at position b, to the end of the text. The first character is at position 1.
Example | Result |
subtext("Paris", 1) | "Paris" |
subtext("New York", 2) | "ew York" |
subtext(text a, integer b, integer c) : text
In the text a, returns the text from the character at position b, of length c. The first character is at position 1.
Example | Result |
subtext("Paris", 1, 3) | "Par" |
subtext("New York", 2, 4) | "ew Y" |
format
format(decimal a, text b) : text
Returns the number a as a text, using the b format. Use the character 0 to indicate a required digit. Use the # character to indicate an optional digit. Any other character in the format will be added as is.
Example | Result |
format(4.3, "00.00") | "04.30" |
format(4.379, "0.00") | "4.38" |
format(4, "0.0#") | "4.0" |
format(4.3, "0.0#") | "4.3" |
format(4.37, "0.0#") | "4.37" |
format(4.379, "0.0#") | "4.38" |
format(4.3792, "0.0#") | "4.38" |
format(integer a, text b) : text
Returns the number a as a text, using the b format. Use the character 0 to indicate a required digit. Use the # character to indicate an optional digit. Any other character in the format will be added as is.
Example | Result |
format(4, "00") | "04" |
format(374, "00") | "374" |
formatTime
formatTime(decimal a, text b) : text
Returns the time a (in seconds) as a text, using the b format.
Example | Result |
formatTime(129.3, "mm\:ss") | "02:09" |
formatTime(8321, "hh\:mm\:ss") | "02:18:41" |
formatTime(2812, "h\:m") | "0:46" |
padStart
padStart(text a, integer b, text c) : text
Write the text a. If the text is shorter than b characters, add the character c at the beginning as many times as necessary to reach b characters in total.
Example | Result |
padStart("hello", 8, "#") | "###hello" |
padStart("23", 5, "*") | "***23" |
padEnd
padEnd(text a, integer b, text c) : text
Write the text a. If the text is shorter than b characters, add the character c at the end as many times as necessary to reach b characters in total.
Example | Result |
padEnd("hello", 8, "#") | "hello###" |
padEnd("23", 5, "*") | "23***" |
toInteger
toInteger(decimal a) : integer
Converts the decimal number a to an integer, rounded to the lowest integer.
Example | Result |
toInteger(12.0) | 12 |
toInteger(34.7) | 34 |
toInteger(integer a) : integer
Converts a to an integer.
Example | Result |
toInteger(25) | 25 |
toInteger(text a) : integer
Tries to convert the text a to an integer. If not possible, returns 0 instead.
Example | Result |
toInteger("320") | 320 |
toInteger("-53.20") | 0 |
toInteger("Paris") | 0 |
toInteger(text a, integer b) : integer
Tries to convert the text a to an integer. If not possible, returns b instead.
Example | Result |
toInteger("320", 17) | 320 |
toInteger("-53.20", 17) | 17 |
toInteger("Paris", 17) | 17 |
toDecimal
toDecimal(integer a) : decimal
Converts a to a decimal number.
Example | Result |
toDecimal(25) | 25.0 |
toDecimal(decimal a) : decimal
Converts a to a decimal number.
Example | Result |
toDecimal(12.0) | 12.0 |
toDecimal(34.7) | 34.7 |
toDecimal(text a) : decimal
Tries to convert the text a to a decimal number. If not possible, returns 0.0 instead.
Example | Result |
toDecimal("320") | 320.0 |
toDecimal("-53.20") | -53.2 |
toDecimal("Paris") | 0.0 |
toDecimal(text a, decimal b) : decimal
Tries to convert the text a to a decimal number. If not possible, returns b instead.
Example | Result |
toDecimal("320.0", 3.1) | 320.0 |
toDecimal("-53.20", 3.1) | -53.2 |
toDecimal("Paris", 3.1) | 3.1 |
toText
toText(integer a) : text
Converts a to a text.
Example | Result |
toText(25) | "25" |
toText(decimal a) : text
Converts a to a text.
Example | Result |
toText(12.0) | "12.0" |
toText(34.758032) | "34.758" |
toText(flag a) : text
Converts a to a text.
Example | Result |
toText(true) | "true" |
toText(false) | "false" |
toText(text a) : text
Converts a to a text.
Example | Result |
toText("Paris") | "Paris" |
toText("New York") | "New York" |
toText(list a, text b) : text
Returns a text containing each element of the list a in order, separated by the text b.
Example | Result |
toText([2,3,5], "-") | "2-3-5" |
toText([2,3,5], ", ") | "2, 3, 5" |
toText([2,3,5], "\n") | "2 3 5" |
toText(list a, text b, text c) : text
Returns a text containing each element of the list a in order, separated by the text b, and each prefixed by the text c.
Example | Result |
toText([2,3,5], ", ", "#") | "#2, #3, #5" |
toText([2,3,5], "\n", "- ") | "- 2 - 3 - 5" |
isFlag
isFlag(value a) : flag
Returns true if a is a flag.
Example | Result |
isFlag(true) | true |
isFlag(-7) | false |
isFlag(3.15) | false |
isFlag("Paris") | false |
isBoolean
isBoolean(value a) : flag
Returns true if a is a flag.
Example | Result |
isBoolean(true) | true |
isBoolean(-7) | false |
isBoolean(3.15) | false |
isBoolean("Paris") | false |
isInteger
isInteger(value a) : flag
Returns true is a is an integer.
Example | Result |
isInteger(true) | false |
isInteger(-7) | true |
isInteger(3.15) | false |
isInteger("Paris") | false |
isDecimal
isDecimal(value a) : flag
Returns true if a is a decimal number.
Example | Result |
isDecimal(true) | false |
isDecimal(-7) | false |
isDecimal(3.15) | true |
isDecimal("Paris") | false |
isText
isText(value a) : flag
Returns true if a is a text.
Example | Result |
isText(true) | false |
isText(-7) | false |
isText(3.15) | false |
isText("Paris") | true |
countFlags
countFlags(flag a, flag b) : integer
Returns the number of true flags among the flags given in parameters.
Example | Result |
countFlags(false, false) | 0 |
countFlags(false, true, false) | 1 |
countFlags(true, true, false, true) | 3 |
countFlags(3 < 10, 42 >= 50, true) | 2 |
countFlags(flag a, flag b, flag c) : integer
Returns the number of true flags among the flags given in parameters.
Example | Result |
countFlags(false, false) | 0 |
countFlags(false, true, false) | 1 |
countFlags(true, true, false, true) | 3 |
countFlags(3 < 10, 42 >= 50, true) | 2 |
countFlags(flag a, flag b, flag c, flag d) : integer
Returns the number of true flags among the flags given in parameters.
Example | Result |
countFlags(false, false) | 0 |
countFlags(false, true, false) | 1 |
countFlags(true, true, false, true) | 3 |
countFlags(3 < 10, 42 >= 50, true) | 2 |
countFlags(flag a, flag b, flag c, flag d, flag e) : integer
Returns the number of true flags among the flags given in parameters.
Example | Result |
countFlags(false, false) | 0 |
countFlags(false, true, false) | 1 |
countFlags(true, true, false, true) | 3 |
countFlags(3 < 10, 42 >= 50, true) | 2 |
countFlags(flag a, flag b, flag c, flag d, flag e, flag f) : integer
Returns the number of true flags among the flags given in parameters.
Example | Result |
countFlags(false, false) | 0 |
countFlags(false, true, false) | 1 |
countFlags(true, true, false, true) | 3 |
countFlags(3 < 10, 42 >= 50, true) | 2 |
countFlags(flag a, flag b, flag c, flag d, flag e, flag f, flag g) : integer
Returns the number of true flags among the flags given in parameters.
Example | Result |
countFlags(false, false) | 0 |
countFlags(false, true, false) | 1 |
countFlags(true, true, false, true) | 3 |
countFlags(3 < 10, 42 >= 50, true) | 2 |
countFlags(flag a, flag b, flag c, flag d, flag e, flag f, flag g, flag h) : integer
Returns the number of true flags among the flags given in parameters.
Example | Result |
countFlags(false, false) | 0 |
countFlags(false, true, false) | 1 |
countFlags(true, true, false, true) | 3 |
countFlags(3 < 10, 42 >= 50, true) | 2 |
condition
condition(flag a, value b, value c) : value
If a is true, returns b. Otherwise returns c.
Example | Result |
condition(3 < 5, 14, 27) | 14 |
condition(3 > 5, 14, 27) | 27 |
createList
createList() : list
Create a new empty list.
Example | Result |
createList() | [] |
createList(integer a, value b) : list
Created a new list containing a times the value b.
Example | Result |
createList(4, 17) | [17, 17, 17, 17] |
createList(5, -2) | [-2, -2, -2, -2, -2] |
createList(3, false) | [false, false, false] |
createListRange
createListRange(integer a) : list
Creates a new list containing all the integers from 1 to a in order. Creates an empty list if a is strictly less than 1.
Example | Result |
createListRange(3) | [1, 2, 3] |
createListRange(5) | [1, 2, 3, 4, 5] |
createListRange(1) | [1] |
createListRange(-2) | [] |
createListRange(integer a, integer b) : list
Creates a new list containing all the integers from a to b in order. Creates an empty list if b is strictly less than a.
Example | Result |
createListRange(3, 6) | [3, 4, 5, 6] |
createListRange(-3, 1) | [-3, -2, -1, 0, 1] |
createListRange(4, 4) | [4] |
createListRange(5, 3) | [] |
createDictionary
createDictionary() : dictionary
Create a new empty dictionary.
Example | Result |
createDictionary() | {} |
clear
clear(list a)
Empty the list a.
[no return value]
Example | Result |
clear([2,3,5]) | [] |
clear(dictionary a)
Empty the dictionary a.
[no return value]
Example | Result |
clear({"foo":3,"bar":5}) | {} |
clone
clone(list a) : list
Duplicates the list a.
Example | Result |
clone([2,3,5]) | [2,3,5] |
clone(dictionary a) : dictionary
Duplicates the dictionary a.
Example | Result |
clone({"foo":3,"bar":5}) | {"foo":3,"bar":5} |
get
get(list a, integer b) : value
Get the value of the list a at index b.
The first position is 1, the last position is count(a).
Example | Result |
get([2,3,5], 2) | 3 |
get(dictionary a, text b) : value
Get the value of the dictionary a at the key b.
Example | Result |
get({"foo":3,"bar":5}, "bar") | 5 |
set
set(list a, integer b, value c)
Stores the value c in the list a at position b.
The first position is 1, the last position is count(a).
[no return value]
Example | Result |
set([2,3,5], 2, 17) | [2,17,5] |
set(dictionary a, text b, value c)
Stores the value c in the dictionary a at the key b.
[no return value]
Example | Result |
set({"foo":3,"bar":5}, "bar", 17) | {"foo":3,"bar":17} |
set({"foo":3}, "qix", 8) | {"foo":3,"qix":8} |
add
add(list a, value b)
Adds the value b at the end of the list a.
[no return value]
Example | Result |
add([2,3,5], 17) | [2,3,5,17] |
add(list a, value b, integer c)
Adds c times the value b at the end of the list a.
[no return value]
Example | Result |
add([2,3,15], 7, 4) | [2,3,15,7,7,7,7] |
addRange
addRange(list a, list b)
Adds all values from the list b at the end of the list a.
[no return value]
Example | Result |
addRange([2,3,5], [8,4]) | [2,3,5,8,4] |
insert
insert(list a, integer b, value c)
Insert element c at position b in the list a.
[no return value]
Example | Result |
insert([2,3,5], 3, 17) | [2,3,17,5] |
insert(list a, integer b, value c, integer d)
Insert d times the element c at position b in the list a.
[no return value]
Example | Result |
insert([2,3,5], 3, 17, 4) | [2,3,17,17,17,17,5] |
removeAt
removeAt(list a, integer b)
Deletes the value from the list a at position b.
The first position is 1, the last position is count(a).
[no return value]
Example | Result |
removeAt([2,3,5], 1) | [3,5] |
removeAll
removeAll(list a, value b)
Delete all occurrences of the element b in the list a.
[no return value]
Example | Result |
removeAll([5,3,5,3,1], 3) | [5,5,1] |
removeAll(["foo","bar","qix","foo","bar","bar"], "bar") | ["foo","qix","foo"] |
removeDuplicates
removeDuplicates(list a)
Removes all duplicates from the a list. The order of the list is preserved by retaining only the first occurrence of each value.
[no return value]
Example | Result |
removeDuplicates([5,3,5,3,1]) | [5,3,1] |
removeDuplicates(["foo","bar","bar","foo","qix","bar"]) | ["foo","bar","qix"] |
removeDuplicates([7,7,7,7]) | [7] |
sum
sum(list a) : decimal
Returns the sum of all integer or decimal elements in the list a.
Example | Result |
sum([2,3.7,5]) | 10.7 |
sum(list a, text b) : decimal
For each dictionary in the list a, get the value at key b. Then returns the sum of all these values.
Example | Result |
sum([{"foo":3},{"foo":4}], 1) | 7.0 |
sort
sort(list a)
Sorts the list a. Works only if all the items in the list are numbers or texts.
[no return value]
Example | Result |
sort([3,2,17,5,2]) | [2,2,3,5,17] |
sort(["Paris","Berlin","London"]) | ["Berlin","London","Paris"] |
sort(list a, text b)
Sorts the list of dictionaries a based on the value at the key b in these dictionaries. Works only if the key value b is a number or text.
[no return value]
Example | Result |
sort([{"foo":3},{"foo":17},{"foo":4}]) | [{"foo":3},{"foo":4},{"foo":17}] |
reverse
reverse(list a)
Reverse the order of the items in the list a.
[no return value]
Example | Result |
reverse([13,21,17,8]) | [8,17,21,13] |
shuffle
shuffle(list a)
Shuffle the a list randomly.
[no return value]
Example | Result |
shuffle([13,21,17,8]) | [21,13,8,17] |
shuffle([18,5,-7,12]) | [12,5,-7,18] |
randIndex
randIndex(list a) : integer
Returns a valid random position for the list a, i.e. an integer number between 1 and the number of elements in the list.
Example | Result |
randIndex([13,21,17,8]) | 3 |
randIndex([13,21,17,8]) | 1 |
isListContentEqual
isListContentEqual(list a, list b) : flag
Returns true if the content of the list a is equal to the content of the list b.
Example | Result |
isListContentEqual([3,21,17], [3,21,17]) | true |
isListContentEqual([3,21,17], [3,17,21]) | false |
isListContentEqual([3,21,17], [12,-7]) | false |
remove
remove(list a, value b)
Removes the first occurrence of the value b from the list a.
[no return value]
Example | Result |
remove([2,5,3,5], 5) | [2,3,5] |
remove([2,3,5], 8) | [2,3,5] |
remove(dictionary a, text b)
Removes the key b from the dictionary a.
[no return value]
Example | Result |
remove({"foo":3,"bar":5}, "foo") | {"bar":5} |
remove({"foo":3,"bar":5}, "qix") | {"foo":3,"bar":5} |
containsKey
containsKey(dictionary a, text b) : flag
Returns true if the dictionary a contains a value at the key b.
Example | Result |
containsKey({"foo":3,"bar":5}, "bar") | true |
containsKey({"foo":3,"bar":5}, "qix") | false |
count
count(list a) : integer
Returns the number of items in the list a.
Example | Result |
count([2,3,5]) | 3 |
count([]) | 0 |
count(dictionary a) : integer
Returns the number of items in the dictionary a.
Example | Result |
count({"foo":3,"bar":5}) | 2 |
count({}) | 0 |
getValues
getValues(dictionary a) : list
Returns the list of values contained in the dictionary a.
Example | Result |
getValues({"foo":3,"bar":5}) | [3,5] |
getKeys
getKeys(dictionary a) : list
Returns the list of keys contained in the dictionary a.
Example | Result |
getKeys({"foo":3,"bar":5}) | ["foo","bar"] |
split
split(text a, text b) : list
Returns a list of texts that contains all the subtexts of the text a separated by the text b.
Example | Result |
split("foo-bar-qix", "-") | ["foo","bar","qix"] |
split("foo--bar", "-") | ["foo","","bar"] |
lerp
lerp(decimal a, decimal b, decimal c) : decimal
Linearly interpolates between a to b by c.
Example | Result |
lerp(2, 4, 0.25) | 2.5 |
lerp(0, 100, 0.62) | 62.0 |
lerp(3, -1, 0.95) | -0.8 |
lerpColor
lerpColor(text a, text b, decimal c) : text
Mix color a with color b using c from color a and (1 - c) from color b.
Example | Result |
lerpColor("#ff0000", "#00ff00", 0.25) | "#bf4000ff" |
lerpColor("#ff0000", "#0000ff", 0.5) | "#800080ff" |
lerpColor("#ff0000", "#0000ff", 0.9) | "#1a00e6ff" |
rgb
rgb(integer a, integer b, integer c) : text
Creates a hexadecimal color from the 3 components red (a), green (b) and blue (c). These 3 components must be between 0 and 255.
Example | Result |
rgb(255, 0, 0) | "#ff0000ff" |
rgb(80, 200, 255) | "#50c8ffff" |
rgb(integer a, integer b, integer c, integer d) : text
Creates a hexadecimal transparent color from the 4 components red (a), green (b), blue (c) and alpha (d).
Example | Result |
rgb(255, 0, 0, 128) | "#ff000080" |
rgb(80, 200, 255, 255) | "#50c8ffff" |
setColorAlpha
setColorAlpha(text a, integer b) : text
Assigns the alpha (transparency) component of color a to the value b (from 0 to 255).
Example | Result |
setColorAlpha("#ff00ffff", 64) | "#ff00ff40" |
setColorAlpha("#ffff0055", 255) | "#ffff00ff" |
randomText
randomText(integer a) : text
Returns a random text of the length a.
Example | Result |
randomText(3) | "llc" |
randomText(12) | "lhg3pcpidj7k" |
distance
distance(text a, text b) : integer
Returns the number of characters to change to transform the text a into the text b.
Example | Result |
distance("Paris", "Parys") | 1 |
distance("Paris", "Parrys") | 2 |
distance("New York", "newyork") | 3 |
isSimilar
isSimilar(text a, text b, integer c) : flag
Returns true if the text a is identical to the text b to c characters.
Example | Result |
isSimilar("Paris", "Parrys", 2) | true |
isSimilar("Paris", "Parrys", 1) | false |
isSimilar("New York", "newyork", 3) | true |
isSimilar("New York", "newyork", 2) | false |
extractText
extractText(text a, text b, integer c) : text
Technical function
Execute a Regex.Match(a, b), then return the value of the group at index c.
See Regex.Match in C# /. NET documentation.
Example | Result |
extractText("NewYorkParis", "New(.*)Paris", 1) | "York" |
extractText("NewNewYorkParisParis", "New(.*)Paris", 1) | "NewYorkParis" |
regexMatch
regexMatch(text a, text b) : flag
Technical function
Returns true if the text a matches the regular expression b.
Example | Result |
regexMatch("NewYork07", "^[a-z]*$") | false |
regexMatch("NewYork07", "^[a-zA-Z0-9]*$") | true |
fromJson
fromJson(text a) : value
Technical function
Converts the JSON text a into a hierarchy of objects.
Example | Result |
fromJson("6") | 6 |
fromJson("\"foobar\"") | "foobar" |
fromJson("[2, 15, 3]") | [2, 15, 3] |
fromJson("{\"foo\":24}") | {"foo":24} |
toJson
toJson(value a) : text
Technical function
Serializes the object hierarchy a into a JSON text.
Example | Result |
toJson(6) | "6" |
toJson("foobar") | "\"foobar\"" |
toJson([2, 15, 3]) | "[2, 15, 3]" |
toJson({"foo":24}) | "{\"foo\":24}" |
escapeURL
escapeURL(text a) : text
Escapes characters in a string to ensure they are URL-friendly.
load
load(media a)
Starts loading the media a.
Does not work with videos.
[no return value]
unload
unload(media a)
Unload the a media from the memory.
Does not work with videos.
[no return value]
isLoaded
isLoaded(media a) : flag
Returns true if the media a is loaded.
Does not work with videos.
keyPressed
keyPressed(text a) : flag
Returns true while the user holds down the key a.
Use the following conventions for parameter a:
• Normal keys: "a", "b", "c" ...
• Number keys: "1", "2", "3", ...
• Keypad keys: "[1]", "[2]", "[3]", "[+]", "[equals]"
• Arrow keys: "up", "down", "left", "right"
• Modifier keys: "right shift", "left shift", "right ctrl", "left ctrl", "right alt", "left alt", "right cmd", "left cmd"
• Mouse Buttons: "mouse 0" (left), "mouse 1" (right), "mouse 2", ...
• Special keys: "backspace", "tab", "return", "escape", "space", "delete", "enter", "insert", "home", "end", "page up", "page down"
• Function keys: "f1", "f2", "f3", ...
keyDown
keyDown(text a) : flag
Returns true if the user starts pressing down the key a.
Use the following conventions for parameter a:
• Normal keys: "a", "b", "c" ...
• Number keys: "1", "2", "3", ...
• Keypad keys: "[1]", "[2]", "[3]", "[+]", "[equals]"
• Arrow keys: "up", "down", "left", "right"
• Modifier keys: "right shift", "left shift", "right ctrl", "left ctrl", "right alt", "left alt", "right cmd", "left cmd"
• Mouse Buttons: "mouse 0" (left), "mouse 1" (right), "mouse 2", ...
• Special keys: "backspace", "tab", "return", "escape", "space", "delete", "enter", "insert", "home", "end", "page up", "page down"
• Function keys: "f1", "f2", "f3", ...
keyUp
keyUp(text a) : flag
Returns true if the user releases the key a.
Use the following conventions for parameter a:
• Normal keys: "a", "b", "c" ...
• Number keys: "1", "2", "3", ...
• Keypad keys: "[1]", "[2]", "[3]", "[+]", "[equals]"
• Arrow keys: "up", "down", "left", "right"
• Modifier keys: "right shift", "left shift", "right ctrl", "left ctrl", "right alt", "left alt", "right cmd", "left cmd"
• Mouse Buttons: "mouse 0" (left), "mouse 1" (right), "mouse 2", ...
• Special keys: "backspace", "tab", "return", "escape", "space", "delete", "enter", "insert", "home", "end", "page up", "page down"
• Function keys: "f1", "f2", "f3", ...
getAxis
getAxis(text a) : decimal
Returns the value of axis a.
Available axes:
• "Mouse X" (mouse horizontal movement)
• "Mouse Y" (mouse vertical movement)
• "Mouse ScrollWheel"
getMouseX
getMouseX() : decimal
Returns the position of the mouse on the horizontal axis. This position is expressed in the coordinate system of the Clickable Zones block, i.e. in the interval [-960, 960] left to right, 0 being at the center of the screen.
getMouseY
getMouseY() : decimal
Returns the position of the mouse on the vertical axis. This position is expressed in the coordinate system of the Clickable Zones block, i.e. in the interval [-540, 540] bottom to top, 0 being at the center of the screen.
createDate
createDate(integer a, integer b, integer c) : text
Creates a date with year a, month b and day c.
Example | Result |
createDate(2024, 04, 23) | "23/04/2024" |
today
today() : text
Creates a date for the current day.
Example | Result |
today() | "29/04/2024" |
getDay
getDay(text a) : integer
Returns the day of the date a as an integer between 1 and 31.
Example | Result |
getDay("23/04/2024") | 23 |
getMonth
getMonth(text a) : integer
Returns the month of the date a as an integer between 1 and 12.
Example | Result |
getMonth("23/04/2024") | 4 |
getYear
getYear(text a) : integer
Returns the year of the date a as an integer.
Example | Result |
getYear("23/04/2024") | 2024 |
addDays
addDays(text a, integer b) : text
Add b day(s) to the date a.
Example | Result |
addDays("23/12/2018", 12) | "04/01/2019" |
addMonths
addMonths(text a, integer b) : text
Add b month(s) to the date a.
Example | Result |
addMonths("23/12/2018", 3) | "23/03/2019" |
addYears
addYears(text a, integer b) : text
Add b year(s) to the date a.
Example | Result |
addYears("23/12/2018", 2) | "23/12/2020" |
dayOfWeek
dayOfWeek(text a) : integer
Return the day of week for the date a, from 1 to 7, from Monday to Sunday.
Example | Result |
dayOfWeek("08/01/2024") | 1 |
dayOfWeek("22/04/2000") | 6 |
dayOfYear
dayOfYear(text a) : integer
Returns the day number of the date a in the full year, from 1 to 366, from January 1 to December 31.
Example | Result |
dayOfYear("08/01/2024") | 8 |
dayOfYear("22/04/2000") | 113 |
isDateBefore
isDateBefore(text a, text b) : flag
Returns true if date a is before date b.
Example | Result |
isDateBefore("08/01/2024", "14/01/2024") | true |
isDateBefore("14/01/2024", "08/01/2024") | false |
isDateAfter
isDateAfter(text a, text b) : flag
Returns true if date a is later than date b.
Example | Result |
isDateAfter("08/01/2024", "14/01/2024") | false |
isDateAfter("14/01/2024", "08/01/2024") | true |
daysBetweenTwoDates
daysBetweenTwoDates(text a, text b) : integer
Returns the number of days between the date a and the date b. If b is earlier than a, the result will be negative.
Example | Result |
daysBetweenTwoDates("08/01/2024", "14/01/2024") | 6 |
daysBetweenTwoDates("08/01/2024", "08/01/2024") | 0 |
daysBetweenTwoDates("14/01/2024", "08/01/2024") | -6 |
formatDate
formatDate(text a) : text
Returns a formatted (displayable) version of the date a, based on the culture of the current language.
Example | Result |
formatDate("08/01/2024") | "08/01/2024" |
formatDate(text a, text b) : text
Formats the date a with the format b. Use character d for days, M for months, and y for years.
Example | Result |
formatDate("08/01/2024", "dd/MM/yyyy") | "08/01/2024" |
formatDate("08/01/2024", "yyyy/MM/dd") | "2024/01/08" |
formatDate("14/01/2024", "MM-dd-yyyy") | "01-14-2024" |
formatDate("14/01/2024", "MM_dd_yyyy") | "01_14_2024" |
resetScores
resetScores()
Resets the score for each skill to zero.
[no return value]
allowSubtitles
allowSubtitles(flag a)
If a is true: allows the learner to display voice subtitles from the options menu.
If a is false: no subtitles will be displayed, even if the user activates the subtitles in the options menu.
[no return value]
clearSavedVariables
clearSavedVariables()
Deletes all saved variables.
[no return value]
resetAllBlocks
resetAllBlocks()
Reset Counter, Sequence and Random blocks, and reset already selected choices in Quiz and Sentence Choice blocks.
[no return value]
isLookAt
isLookAt(decimal a) : flag
Returns true if the 360° view is oriented at the horizontal angle a with a precision of 10 degrees and vertical angle 0 with a precision of 40 degrees.
isLookAt(decimal a, decimal b) : flag
Returns true if the 360° view is oriented at the horizontal angle a and the vertical angle b to with a precision of 10 degrees.
isLookAt(decimal a, decimal b, decimal c) : flag
Returns true if the 360° view is oriented at the horizontal angle a and vertical angle b with a precision of c degrees.
isLookAt(decimal a, decimal b, decimal c, decimal d) : flag
Returns true if the 360° view is oriented at the horizontal angle a with a precision of c degrees and vertical angle b with a precision of d degrees.
allowZonesClick
allowZonesClick(flag a)
If a is false, all areas become non-clickable.
If a is true, all areas that are defined as clickable by Clickable Zones blocks become clickable again.
[no return value]
refreshZones
refreshZones()
Refreshes the status of all zones previously created via Clickable Zones blocks. All their variables will be recalculated: position, color, condition for being clickable, etc. The only exception is the visibility condition, i.e. a zone cannot be hidden or displayed using this function.
[no return value]
showScoreNotification
showScoreNotification(flag a)
This function has no effect if the "In-game score feedback" option of the project is OFF.
If a is true, then each score received will display a small gamified notification.
If a is false, no score notification will be displayed.
[no return value]
setScormScore
setScormScore(decimal a)
Set the score to be reported if this Experience is a SCORM module played on an LMS.
Note: the data are not sent to the LMS via this function.
To force the sending of the data, use the commitGameData function.
[no return value]
setScormProgress
setScormProgress(decimal a)
Set the progression between 0.0 and 1.0 to be reported if this Experience is a SCORM module played on an LMS.
Note: the data are not sent to the LMS via this function.
To force the sending of the data, use the commitGameData function.
[no return value]
setMinMaxScormScore
setMinMaxScormScore(decimal a, decimal b)
Set the min (a) and max (b) values used to calculate the scaled score between 0.0 and 1.0.
The scaled score will be 0 if the raw score is less than or equal to min.
The scaled score will be 1 if the raw score is greater than or equal to max.
[no return value]
terminateScorm
terminateScorm()
Forces the end of the SCORM session (FinalizeSession) if this Experience is a SCORM module played on an LMS.
[no return value]
addScormInteraction
addScormInteraction(value a)
If this Experience is a SCORM module played on an LMS, saves a SCORM interaction with the a value.
[no return value]
set360Speed
set360Speed(decimal a, decimal b)
Set the rotation movements sensitivity for 360° sceneries : a for the horizontal axis and b for the vertical axis.
The default value is 1 for each axis. So for example, using set360Speed(2, 0.5) will set the rotation to be twice as fast for the horizontal movement and half as fast for the vertical movement.
[no return value]
allowSkip
allowSkip(flag a)
If a is true: allow the learner to skip in-game replies by clicking on subtitles or pressing the space bar.
If a is false: prevents the learner from skipping the replies.
[no return value]
resetBadges
resetBadges()
Deletes all badges earned by the learner for this Experience.
[no return value]
showProgressBar
showProgressBar(flag a)
If a is true: Displays progress bar.
If a is false: Hide progress bar.
[no return value]
getSkillNames
getSkillNames() : list
Get the list of names of the skills used in this scenario. Returns a list of texts.
getSkillScores
getSkillScores() : list
Get the list of scores by skill used in this scenario. Returns a list of integer.
getSkillMinScores
getSkillMinScores() : list
Retrieves the list of minimum scores per skill used in this scenario (as defined in the "Skills evaluation" page). Returns a list of integers. If no minimum score is defined, this function will return 0 as default value.
getSkillMaxScores
getSkillMaxScores() : list
Retrieves the list of maximum scores per skill used in this scenario (as defined in the "Skills evaluation" page). Returns a list of integers. If no maximum score is defined, this function will return 100 as default value.
hasBadge
hasBadge(badge a) : flag
Returns true if the badge a has been earned by the learner.
flagListToHexa
flagListToHexa(list a) : text
Returns the hexadecimal number (text) resulting from the conversion of the binary number a (sequence of 0 and 1 represented by a list of flags false or true).
Example | Result |
flagListToHexa([true,false,true,true,true,false,false,true]) | "B9" |
hexaToFlagList
hexaToFlagList(text a) : list
Returns the binary number (sequence of 0 and 1 represented by a list of flags false or true) resulting from the conversion of the hexadecimal number a.
Example | Result |
hexaToFlagList("B9") | [true,false,true,true,true,false,false,true] |
copyToClipboard
copyToClipboard(text a)
Copy the text a to the clipboard of the user's machine.
Does not work in Web or SCORM export.
[no return value]
allowMultipleExecByFrame
allowMultipleExecByFrame(flag a)
Technical function
Allows multiple executions of the same block during a frame. Allows to quickly execute complex algorithms with many passages in the same blocks.
[no return value]
sendDataToWebPage
sendDataToWebPage(text a, text b)
Technical function. Works only if the module is played in a web browser (SCORM or simple Web export).
Call the OnReceiveDataFromVTS(key, value) JavaScript function, in the index.html file of the exported module, with a for the key parameter and b for the value parameter. You are free to implement the content of this JavaScript function according to your needs.
[no return value]
getDataFromWebPage
getDataFromWebPage(text a) : text
Technical function. Works only if the module is played in a web browser (SCORM or simple Web export).
Call the OnSendDataToVTS(key) JavaScript function, in the index.html file of the exported module, with a for the key parameter. You are free to implement the content of this JavaScript function to return the desired value.
moveCharacter
moveCharacter(integer a, integer b)
Moves character number a (in the project's character list) to location number b (in the scenery's character list) in 1 second. (BETA)
[no return value]
moveCharacter(integer a, integer b, decimal c)
Moves character number a (in the project's character list) to location number b (in the scenery's character list) in c second.(BETA)
[no return value]
moveCharacter(integer a, integer b, decimal c, decimal d)
Moves character number a (in the project character list) to location number b (in the scenery's character list) in c seconds, after a d second delay. (BETA)
[no return value]
walkTo
walkTo(integer a, integer b)
Moves character number a (in the project's character list) to location number b (will walk toward this position and rotation) (BETA)
[no return value]
walkTo(integer a, integer b, flag c)
Moves character number a (in the project's character list) to location number b (will walk toward this position. Rotation will also be applied if c is true) (BETA)
[no return value]
turnTo
turnTo(integer a, integer b)
Turns character number a (in the project's character list) to look at the location number b (in Scenery characters slots). (BETA)
[no return value]
moveMediaSlot
moveMediaSlot(integer a, integer b)
Moves media slot number a (in the scenery's media slot list) to location number b in 1 second. (BETA)
[no return value]
moveMediaSlot(integer a, integer b, decimal c)
Moves media slot number a (in the scenery's media slot list) to location number b in c seconds. (BETA)
[no return value]
moveMediaSlot(integer a, integer b, decimal c, decimal d)
Moves media slot number a (in the scenery's media slot list) to location number b in c seconds, after a d second delay. (BETA)
[no return value]
pauseCountdown
pauseCountdown(flag a)
If a is true: pause the active Countdown block.
If a is false: unpause the active Countdown block.
[no return value]
- ${ child.title }