Highbeam

simple gui example 1

Oct 28th, 2018
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. local component = require("component")
  2. local gpu = component.gpu
  3. local gui = require("gui")
  4.  
  5. local prgName = "Gui-lib v"
  6. local version = gui.Version()
  7.  
  8. function exitButtonCallback(guiID, id)
  9. local result = gui.getYesNo("", "Do you really want to exit?", "")
  10. if result == true then
  11. gui.exit()
  12. end
  13. gui.displayGui(myGui)
  14. end
  15.  
  16. myGui = gui.newGui(2, 2, 78, 23, true)
  17. exitbutton = gui.newButton(myGui, "center", 21, "exit", exitButtonCallback)
  18.  
  19. label1 = gui.newLabel(myGui, 2, 1, "A label")
  20. label2 = gui.newLabel(myGui, 2, 3, "A colored label", 0xFF0000, 0xFFFF00)
  21.  
  22. frame = gui.newFrame(myGui, 2, 5, 40, 6, "A frame")
  23.  
  24. checkbox1 = gui.newCheckbox(myGui, 3, 7, false)
  25. cbLabel1 = gui.newLabel(myGui, 7, 7, "Checkbox")
  26.  
  27. checkbox2 = gui.newCheckbox(myGui, 3, 8, true)
  28. cbLabel2 = gui.newLabel(myGui, 7, 8, "Second checkbox")
  29.  
  30. text = gui.newText(myGui, 2, 12, 25, "Text input")
  31.  
  32. progress = gui.newProgress(myGui, 2, 16, 35, 100, 0, nil, true)
  33.  
  34. list = gui.newList(myGui, 50, 3, 25, 10, {"Entry 1", "Entry two", "Number 3", "44444"}, nil, "A List")
  35.  
  36. vprogress1 = gui.newVProgress(myGui, 44, 3, 10, 100, 0, nil)
  37. vprogress2 = gui.newVProgress(myGui, 46, 3, 10, 100, 0, nil, 1)
  38.  
  39. radioframe = gui.newFrame(myGui, 48, 14, 25, 6)
  40.  
  41. radio1 = gui.newRadio(myGui, 50, 15)
  42. radio2 = gui.newRadio(myGui, 50, 16)
  43. radio3 = gui.newRadio(myGui, 50, 17)
  44. radio4 = gui.newRadio(myGui, 50, 18)
  45.  
  46. radioLabel1 = gui.newLabel(myGui, 54, 15, "Radio button 1")
  47. radioLabel2 = gui.newLabel(myGui, 54, 16, "Radio button 2")
  48. radioLabel3 = gui.newLabel(myGui, 54, 17, "Radio button 3")
  49. radioLabel4 = gui.newLabel(myGui, 54, 18, "Radio button 4")
  50.  
  51. hline = gui.newHLine(myGui, 5, 20, 40)
  52.  
  53. gui.clearScreen()
  54. gui.setTop(prgName .. version)
  55.  
  56. local counter = 0
  57. while true do
  58. gui.runGui(myGui)
  59. counter = counter + 1
  60. if counter <= 100 then
  61. gui.setValue(myGui, progress, counter)
  62. gui.setValue(myGui, vprogress1, counter)
  63. gui.setValue(myGui, vprogress2, counter)
  64. end
  65. if counter > 110 then
  66. counter = 0
  67. end
  68. end
Add Comment
Please, Sign In to add comment