Advertisement
Inksaver

MenuTest

Jun 8th, 2023 (edited)
725
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.86 KB | None | 0 0
  1. version = 20230602.1700
  2. menu = require "lib.menu"
  3. --[[
  4. https://pastebin.com/Tb52qX9z
  5. ]]
  6. local function getTest()
  7.     local line, test, age, height, likesLua  = 1, "", 0, 0, false
  8.     line = menu.clear()
  9.    
  10.     --getString(prompt, withTitle, minValue, maxValue, row, fg, bg)
  11.     test, line = menu.getString("Type your name ", true, 2, 10, line, colors.green, colors.black)
  12.     line = line + 1
  13.     --age, line = menu.getInteger("Type a number 5 to 99 default 50", 5, 99, line, colors.yellow, colors.black, 50)
  14.     age, line = menu.getInteger("Type a number 5 to 99 default 50", 5, 99, nil, colors.pink, nil, 50)
  15.     menu.colourPrint("You chose ".. age..", line="..line, colors.red, colors.black)
  16.    
  17.     age, line = menu.getInteger({"Type your age","Between 5 and 99 "}, 5, 99, line, colors.yellow, colors.black)
  18.     line = line + 1
  19.    
  20.     height, line = menu.getFloat("Type your height", 0.5, 2.1, line, colors.cyan, colors.black)
  21.     line = line + 1
  22.    
  23.     likesLua, line = menu.getBool("Do you like Lua?(y/n)", line, colors.blue, colors.black)
  24.     line = line + 1
  25. end
  26.  
  27. local function menuTest()
  28.     local choice, modifier = 0, ""
  29.     line = menu.clear()
  30.  
  31.     options = {"white", "red", "blue", "green", "yellow", "cyan", "magenta", "purple", "pink"}
  32.     --choice, modifier = menu.new("Choose your colour", options)
  33.     local pp =
  34.     {
  35.         prompt = colors.yellow,
  36.         itemColours = {colors.white, colors.red, colors.blue, colors.green, colors.yellow, colors.cyan, colors.magenta, colors.purple, colors.pink},
  37.         menuPrompt = colors.lime
  38.     }
  39.     --[[local pp =
  40.     {
  41.         prompt = colors.green,
  42.         itemColours = {colors.white, colors.red, ... one for each item},
  43.         menuPrompt = colors.yellow
  44.     }
  45.     choice, modifier = menu.menu or menu.new("Choose your option", options, pp)]]
  46.     choice, modifier = menu.menu("Choose your colour", options, pp)
  47.     if choice ~= nil then
  48.         local colour = colors[options[choice]]
  49.         menu.colourPrint("You chose ".. options[choice], colour, colors.black)
  50.     else
  51.         print("you chose "..modifier)
  52.     end
  53. end
  54.  
  55. local function colourDisplay()
  56.     line = menu.clear()
  57.     --print(text, fg, bg, width) write(text, fg, bg, width)
  58.     menu.colourPrint("red on black",      colors.red,       colors.black)
  59.     menu.colourPrint("purple on black",   colors.purple,    colors.black)
  60.     menu.colourPrint("magenta on black",  colors.magenta,   colors.black)
  61.     menu.colourPrint("pink on black",     colors.pink,      colors.black)
  62.    
  63.     menu.colourPrint("green on black",    colors.green,     colors.black)
  64.     menu.colourPrint("lime on black",     colors.lime,      colors.black)
  65.     menu.colourPrint("yellow on black",   colors.yellow,    colors.black)
  66.     menu.colourPrint("orange on black",   colors.orange,    colors.black)
  67.     menu.colourPrint("brown on black",    colors.brown,     colors.black)
  68.    
  69.     menu.colourPrint("blue on black",     colors.blue,      colors.black)
  70.     menu.colourPrint("cyan on black",     colors.cyan,      colors.black)
  71.     menu.colourPrint("lightBlue on black ENTER",colors.lightBlue, colors.black)
  72.    
  73.     read()
  74.     line = menu.clear()
  75.     menu.colourPrint("white on black",     colors.white,     colors.black)
  76.     menu.colourPrint("lightGray on black", colors.lightGray, colors.black)
  77.     menu.colourPrint("gray on black",      colors.gray,      colors.black)
  78.     menu.colourPrint("black on white",     colors.black,     colors.white)
  79.     menu.colourPrint("black on lightGray", colors.black,     colors.lightGray)
  80.     menu.colourPrint("black on gray ENTER",colors.black,     colors.gray)
  81.    
  82.     read()
  83.     line = menu.clear()
  84.     menu.colourPrint("black on red",      colors.black,       colors.red)
  85.     menu.colourPrint("black on purple",   colors.black,    colors.purple)
  86.     menu.colourPrint("black on magenta",  colors.black,   colors.magenta)
  87.     menu.colourPrint("black on pink",     colors.black,      colors.pink)
  88.    
  89.     menu.colourPrint("black on green",    colors.black,     colors.green)
  90.     menu.colourPrint("black on lime",     colors.black,      colors.lime)
  91.     menu.colourPrint("black on yellow",   colors.black,    colors.yellow)
  92.     menu.colourPrint("black on orange",   colors.black,    colors.orange)
  93.     menu.colourPrint("black on brown",    colors.black,     colors.brown)
  94.    
  95.     menu.colourPrint("black on blue",     colors.black,      colors.blue)
  96.     menu.colourPrint("black on cyan",     colors.black,      colors.cyan)
  97.     menu.colourPrint("black on lightBlue ENTER",colors.black, colors.lightBlue)
  98.     read()
  99.     line = menu.clear()
  100. end
  101.  
  102. local function printText()
  103.     line = menu.clear()
  104.     --[[
  105.     local text = '~brown~Thank ~red~you ~brown~for playing this adventure'
  106.     line = menu.colourPrint(line, text, true, true)
  107.     local textTable = {'~pink~and for ~blue~testing the ~lime~colours','~red~Coded by Inksaver','~green~If you did not make it this time','~yellow~Please try again!'}
  108.     for _,text in ipairs(textTable) do
  109.         line = menu.colourPrint(line, text, true, true)
  110.     end]]
  111. text = [[                ~lightGray~MINING:~white~
  112. Can be used in over-world or nether.  
  113. Create a pre-formatted 33 x 33 blocks  
  114. mine at chosen level.~brown~                
  115. Ladders and stairs up/down~blue~    
  116. Bubble lift and safe drop to water.~lightGray~    
  117. Strip resources from abandoned mines.~yellow~  
  118. Faster version of 33x33 mine pattern  
  119. using corridor and rectangle functions.~gray~
  120. Mine bottom layer to bedrock not worth
  121. the time and fuel.
  122. ]]
  123.     line = menu.colourText(line, text, true)
  124.     term.setCursorPos(1, line + 1)
  125.     read()
  126. text = [[
  127. FORESTRY:
  128. Fell Tree can be used in Nether as well
  129. for cutting any size tree / branches
  130. Create a simple 16 single tree farm
  131. or 4 double size (Dark oak or any type)
  132. suitable for turtle harvesting.
  133. Automatic treefarm can be created and
  134. managed with dedicated automatic turtle.
  135. Natural forest can be harvested and
  136. replanted. (Must be walled off)
  137. ]]
  138.     line = menu.clear()
  139.     line = menu.colourText(line, text, true)
  140.     term.setCursorPos(1, line+1)
  141. end
  142.  
  143. local function main()
  144.     --printText()
  145.     --read()
  146.     getTest()
  147.     read()
  148.     menuTest()
  149.     read()
  150.     colourDisplay()
  151. end
  152.  
  153. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement