MissEshock2002

SexScripts Instructions Example

Aug 2nd, 2020
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 2.28 KB | None | 0 0
  1. // Instructions Example
  2. // by MissEshock2002
  3.  
  4. // This script, from https://ss.deviatenow.com, is protected by this licence:
  5. // CC0
  6.  
  7. setInfos(9, "Instructions Example",
  8.         "Instructions Example for showing text on many pages with previous, next, and exit buttons",
  9.         "MissEshock2002",
  10.         "v1.0", 0x222222, "en", ["example", "tutorial"]);
  11.  
  12. def clamp = { value, min, max ->
  13.     return Math.max(min, Math.min(max, value))
  14. }
  15.  
  16. def showInstructions = { List textList,
  17.                          String prevButton = "<-", String nextButton = "->", String exitButton = "Exit", // default buttons
  18.                          boolean hideButtons = false ->
  19.     // show a list item for item with prev, next, exit buttons
  20.  
  21.     int pageIndex = 0
  22.     while (true) {
  23.         List menuButtons
  24.         if (hideButtons) { // show only possible buttons
  25.             menuButtons = [prevButton, nextButton]
  26.             if (pageIndex == 0) menuButtons = [nextButton]
  27.             else if (pageIndex == (textList.size() - 1)) menuButtons = [prevButton]
  28.             menuButtons += exitButton
  29.         } else { // show all buttons
  30.             menuButtons = [prevButton, nextButton, exitButton]
  31.         }
  32.  
  33.         int sel = getSelectedValue(textList[pageIndex], menuButtons)
  34.         if (menuButtons[sel] == prevButton)
  35.             pageIndex--
  36.         else if (menuButtons[sel] == nextButton)
  37.             pageIndex++
  38.         else if (menuButtons[sel] == exitButton)
  39.             break
  40.  
  41.         // clamp pageIndex between 0 and length of the textList - 1:
  42.         pageIndex = clamp(pageIndex, 0, (textList.size() - 1))
  43.     }
  44. }
  45.  
  46. int randomValue = getRandom(2) // random 0 or 1
  47. List instructions = ["Instructions text 1",
  48.                      String.format("Instructions text 2: randomValue = %s", randomValue),
  49.                      "Instructions text 3: " +
  50.                              ((randomValue == 0) ? "Text A" : "Text B") // must be in brackets!
  51. ]
  52.  
  53. boolean endLoop = false
  54. while (!endLoop) { // loop repeats till endLoop = true
  55.  
  56.     showInstructions(instructions, "<- Previous", "Next ->", "Exit Instructions")
  57.  
  58.     // works with any list:
  59.     List numbers = (0..2) // list = 0, 1, 2
  60.     showInstructions(numbers)
  61.  
  62.     if (!getBoolean("Repeat?")) endLoop = true
  63. }
  64.  
  65. show("- End of Script -")
Add Comment
Please, Sign In to add comment