Advertisement
Guest User

desktop

a guest
Mar 25th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.21 KB | None | 0 0
  1. -------------------------
  2. --       Functions     --
  3. -------------------------
  4. function centerText(text)
  5.   x,y = term.getSize()
  6.   x2,y2 = term.getCursorPos()
  7.   term.setCursorPos(math.ceil((x/2) - (text:len() / 2)), y2)
  8.   write(text)
  9. end
  10.  
  11. function w()
  12.   term.clear()
  13.   term.setCursorPos(1,6)
  14.   centerText("Light")
  15.   print("\n")
  16.   centerText(" Hangar")
  17.   print("\n")
  18.   centerText(" Generator")
  19.   print("\n")
  20.   centerText("Alarm")
  21.   print("\n")
  22.   centerText(" Sign Out")
  23. end
  24.  
  25. function clear()
  26.   term.clear()
  27.   term.setCursorPos(1,1)
  28.   term.setBackgroundColor(colors.white)
  29.   term.setTextColor(colors.black)
  30. end
  31.  
  32. function click()
  33.   event, p1, x, y = os.pullEvent(mouse_click)
  34. end
  35. -------------------------
  36. --       Desktop       --
  37. -------------------------
  38. while true do
  39.   clear()
  40.   w()
  41.   click()
  42.  
  43.   if y == 6 then
  44.     shell.run("light")
  45.     y = 0
  46.     x = 0
  47.   end
  48.  
  49.   if y == 8 then
  50.     shell.run("hangar")
  51.     y = 0
  52.     x = 0
  53.   end
  54.  
  55.   if y == 10 then
  56.     shell.run("generator")
  57.     y = 0
  58.     x = 0
  59.   end
  60.  
  61.   if y == 12 then
  62.     shell.run("alarm")
  63.     y = 0
  64.     x = 0
  65.   end
  66.  
  67.   if y == 14 then
  68.   shell.run("start")
  69.   y = 0
  70.   x = 0
  71.   end
  72. end
  73. -------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement