Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Instructions Example
- // by MissEshock2002
- // This script, from https://ss.deviatenow.com, is protected by this licence:
- // CC0
- setInfos(9, "Instructions Example",
- "Instructions Example for showing text on many pages with previous, next, and exit buttons",
- "MissEshock2002",
- "v1.0", 0x222222, "en", ["example", "tutorial"]);
- def clamp = { value, min, max ->
- return Math.max(min, Math.min(max, value))
- }
- def showInstructions = { List textList,
- String prevButton = "<-", String nextButton = "->", String exitButton = "Exit", // default buttons
- boolean hideButtons = false ->
- // show a list item for item with prev, next, exit buttons
- int pageIndex = 0
- while (true) {
- List menuButtons
- if (hideButtons) { // show only possible buttons
- menuButtons = [prevButton, nextButton]
- if (pageIndex == 0) menuButtons = [nextButton]
- else if (pageIndex == (textList.size() - 1)) menuButtons = [prevButton]
- menuButtons += exitButton
- } else { // show all buttons
- menuButtons = [prevButton, nextButton, exitButton]
- }
- int sel = getSelectedValue(textList[pageIndex], menuButtons)
- if (menuButtons[sel] == prevButton)
- pageIndex--
- else if (menuButtons[sel] == nextButton)
- pageIndex++
- else if (menuButtons[sel] == exitButton)
- break
- // clamp pageIndex between 0 and length of the textList - 1:
- pageIndex = clamp(pageIndex, 0, (textList.size() - 1))
- }
- }
- int randomValue = getRandom(2) // random 0 or 1
- List instructions = ["Instructions text 1",
- String.format("Instructions text 2: randomValue = %s", randomValue),
- "Instructions text 3: " +
- ((randomValue == 0) ? "Text A" : "Text B") // must be in brackets!
- ]
- boolean endLoop = false
- while (!endLoop) { // loop repeats till endLoop = true
- showInstructions(instructions, "<- Previous", "Next ->", "Exit Instructions")
- // works with any list:
- List numbers = (0..2) // list = 0, 1, 2
- showInstructions(numbers)
- if (!getBoolean("Repeat?")) endLoop = true
- }
- show("- End of Script -")
Add Comment
Please, Sign In to add comment