Advertisement
PolskiWisnia

Device Manager

Aug 9th, 2023 (edited)
845
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.47 KB | None | 0 0
  1. -- Microcraft NextUI Device Manager --
  2.  
  3. local function aw(...) return write(...) end
  4. local function p(...) return print(...) end
  5. local function s(...) return sleep(...) end
  6. local function tw(...) return term.write(...) end
  7. local function scp(...) return term.setCursorPos(...) end
  8. local function sbc(...) return term.setBackgroundColor(...) end
  9. local function stc(...) return term.setTextColor(...) end
  10. local function tc(...) return term.clear(...) end
  11. local function tcl(...) return term.clearLine(...) end
  12. local function r(...) return shell.run(...) end
  13. local function sp(...) return textutils.slowPrint(...) end
  14. local function sw(...) return textutils.slowWrite(...) end
  15. local function fse(...) return fs.exists(...) end
  16. local function pul(...) return paintutils.loadImage(...) end
  17. local function pud(...) return paintutils.drawImage(...) end
  18. local function pfb(...) return paintutils.drawFilledBox(...) end
  19. local function su(...) return os.shutdown(...) end
  20. local function re(...) return os.reboot(...) end
  21. local function pdp(...) return paintutils.drawPixel(...) end
  22.  
  23. w, h = term.getSize()
  24.  
  25. function nilToBrak(str)
  26.     if str == nil then str = "Brak" end
  27.     return str
  28. end
  29.  
  30. function mysz()
  31.     local event, button, x, y = os.pullEvent("mouse_click")
  32.     klik = {x, y, button}
  33.     return klik
  34. end
  35.  
  36. function findPeripherals()
  37.     peripherals = {}
  38.    
  39.     peripherals[1] = nilToBrak(peripheral.getType("top"))
  40.     peripherals[2] = nilToBrak(peripheral.getType("bottom"))
  41.     peripherals[3] = nilToBrak(peripheral.getType("left"))
  42.     peripherals[4] = nilToBrak(peripheral.getType("right"))
  43.     peripherals[5] = nilToBrak(peripheral.getType("front"))
  44.     peripherals[6] = nilToBrak(peripheral.getType("back"))
  45.  
  46.     return peripherals
  47. end
  48.  
  49. function devMgr()
  50. pfb(1,1,w,1,colors.blue)
  51. stc(colors.white)
  52. scp(1,1)
  53. p("NextUI Device Manager")
  54. pdp(w,1,colors.red)
  55. stc(colors.white)
  56. scp(w,1)
  57. p("X")
  58. pfb(1,2,w,h,colors.black)
  59. scp(1,2)
  60. stc(colors.white)
  61. p("NextUI Compatible PC")
  62. local char1 = "\149"
  63. p(char1)
  64. p(char1)
  65. local char2 = "\131"
  66. for i = 5,14 do
  67.     scp(1,i)
  68.     p(char1)
  69. end
  70.  
  71. peripheralsFound = findPeripherals()
  72.  
  73. scp(2,5)
  74. p(char2,"Top ", peripheralsFound[1])
  75. scp(2,7)
  76. p(char2, "Bottom", peripherals[2])
  77. scp(2,9)
  78. p(char2, "Left", peripherals[3])
  79. scp(2,11)
  80. p(char2, "Right", peripherals[4])
  81. scp(2,13)
  82. p(char2, "Front", peripherals[5])
  83. scp(2,15)
  84. p(char2, "Back", peripherals[6])
  85.  
  86. while true do
  87. klik = mysz()
  88.  
  89. if klik[1] == w and klik[2] == 1 then break end
  90. end
  91.  
  92. end
  93.  
  94. devMgr()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement