Forum Discussion
JesseWu
4 hours agoCommunity Member
// Get the text variable "dataEntry1" and the boolean variable "ifConditionMet"
var player = GetPlayer();
var dataEntry1 = player.GetVar("dataEntry1");
var ifConditionMet = player.GetVar("ifConditionMet");
// Clean the value of dataEntry1, allowing only numbers and decimal points
dataEntry1 = dataEntry1.replace(/[^0-9.,]/g, '');
// Replace comma with a dot if present
dataEntry1 = dataEntry1.replace(',', '.');
// Check if the cleaned value is a valid number
if (isNaN(dataEntry1) || dataEntry1 === '') {
alert("Please enter a valid number.");
} else {
// Convert the cleaned text variable to a number
var numberVar = parseFloat(dataEntry1);
// Check if the number is within the expected range
if (numberVar >= 10 && numberVar <= 13) {
ifConditionMet = true;
} else {
ifConditionMet = false;
}
// Set the boolean variable "ifConditionMet" in Storyline
player.SetVar("ifConditionMet", ifConditionMet);
}
something like this?