Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*This code takes the content of the text entry field ('Send_Text'), splits it into individual words and adds 1 to 'Message_Score' for every keyword that is present. Unless the final location is stated ("Ferry" or "Ship" or "Boat") the 'Current_Location' variables remains set to FALSE. But if one of these words is present, 'Current_Location' is set to TRUE. A score of 3+ and TRUE location is required to pass.*/
- // Get the Storyline player
- var player = GetPlayer();
- // Get the text string variable from Storyline 360
- var sendText = player.GetVar("Send_Text");
- // Convert the text to lowercase for case-insensitive matching
- var lowercaseText = sendText.toLowerCase();
- // Initialize the score and Location variable
- var score = 0;
- var locationPresent = false;
- // Check for the presence of specific words and update the score and Location variable
- if (lowercaseText.includes("french") || lowercaseText.includes("frenchmen") || lowercaseText.includes("france") || lowercaseText.includes("marseille")) {
- score += 1;
- }
- if (lowercaseText.includes("accordion")) {
- score += 1;
- }
- if (lowercaseText.includes("level crossing") || lowercaseText.includes("train")) {
- score += 1;
- }
- if (lowercaseText.includes("harbour") || lowercaseText.includes("harbor") || lowercaseText.includes("sea") || lowercaseText.includes("seagull") || lowercaseText.includes("seagulls") || lowercaseText.includes("port")) {
- score += 1;
- }
- if (lowercaseText.includes("ferry") || lowercaseText.includes("boat") || lowercaseText.includes("ship")) {
- score += 1;
- locationPresent = true;
- }
- // If none of the keywords is present, set the score to 0
- if (score === 0) {
- score = 0;
- }
- // Set the score and Location variables in Storyline
- player.SetVar("Message_Score", score);
- player.SetVar("Current_Location", locationPresent);
Add Comment
Please, Sign In to add comment