DevByPowerPoint

Kidnapped | ELHC 442

Nov 22nd, 2023 (edited)
396
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 1.82 KB | Source Code | 0 0
  1. /*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.*/
  2.  
  3. // Get the Storyline player
  4. var player = GetPlayer();
  5.  
  6. // Get the text string variable from Storyline 360
  7. var sendText = player.GetVar("Send_Text");
  8.  
  9. // Convert the text to lowercase for case-insensitive matching
  10. var lowercaseText = sendText.toLowerCase();
  11.  
  12. // Initialize the score and Location variable
  13. var score = 0;
  14. var locationPresent = false;
  15.  
  16. // Check for the presence of specific words and update the score and Location variable
  17. if (lowercaseText.includes("french") || lowercaseText.includes("frenchmen") || lowercaseText.includes("france") || lowercaseText.includes("marseille")) {
  18.     score += 1;
  19. }
  20.  
  21. if (lowercaseText.includes("accordion")) {
  22.     score += 1;
  23. }
  24.  
  25. if (lowercaseText.includes("level crossing") || lowercaseText.includes("train")) {
  26.     score += 1;
  27. }
  28.  
  29. if (lowercaseText.includes("harbour") || lowercaseText.includes("harbor") || lowercaseText.includes("sea") || lowercaseText.includes("seagull") || lowercaseText.includes("seagulls") || lowercaseText.includes("port")) {
  30.     score += 1;
  31. }
  32.  
  33. if (lowercaseText.includes("ferry") || lowercaseText.includes("boat") || lowercaseText.includes("ship")) {
  34.     score += 1;
  35.     locationPresent = true;
  36. }
  37.  
  38. // If none of the keywords is present, set the score to 0
  39. if (score === 0) {
  40.     score = 0;
  41. }
  42.  
  43. // Set the score and Location variables in Storyline
  44. player.SetVar("Message_Score", score);
  45. player.SetVar("Current_Location", locationPresent);
  46.  
Add Comment
Please, Sign In to add comment