Advertisement
Guest User

os

a guest
Sep 2nd, 2014
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.77 KB | None | 0 0
  1. monitor = peripheral.wrap("right")
  2. m = peripheral.wrap("right")
  3. function button(xb,yb,cb,ct,t)
  4. m.setCursorPos(xb,yb)
  5. m.setBackgroundColor(cb)
  6. m.setTextColor(ct)
  7. m.write(t)
  8. end
  9. function click(xmin,xmax,ymin,ymax)
  10.  if event=="monitor_touch" and xPos>=xmin and xPos<=xmax and yPos>=ymin and yPos<=ymax  then
  11.    return true
  12.  else
  13.    return false
  14.  end
  15. end
  16. function bar()
  17. button(1,16,colors.lime,colors.black,"  (!)  ")
  18. button(8,16,colors.green,colors.black,"         []         ")
  19. button(28,16,colors.lime,colors.black,"</>")
  20. button(31,16,colors.yellow,colors.white,"Lua")
  21. end
  22.  
  23. function clearDesk()
  24. menu = 0
  25. m.setBackgroundColor(colors.black)
  26. m.clear()
  27. m.setTextScale(2.5)
  28. m.setTextColor(colors.white)
  29. desk = paintutils.loadImage("desk")
  30. paintutils.drawImage(desk,8,2)
  31. button(33,3,colors.red,colors.white,"<")
  32. button(33,4,colors.brown,colors.white,"<")
  33. bar()
  34. end
  35.  
  36. clearDesk()
  37. os.startTimer(0.5)
  38. function shutDown()
  39. m.setCursorPos(13,12)
  40. m.setBackgroundColor(colors.green)
  41. m.setTextColor(colors.black)
  42. m.write("Shutdown?")
  43. m.setCursorPos(13,13)
  44. m.write(" ")
  45. m.setBackgroundColor(colors.lime)
  46. m.write("Yes")
  47. m.setBackgroundColor(colors.green)
  48. m.write("  ")
  49. m.setBackgroundColor(colors.lime)
  50. m.write("No")
  51. m.setBackgroundColor(colors.green)
  52. m.write(" ")
  53. end
  54. function editCode()
  55. m.setCursorPos(13,12)
  56. m.setBackgroundColor(colors.green)
  57. m.setTextColor(colors.black)
  58. m.write("Edit Code?")
  59. m.setCursorPos(13,13)
  60. m.write(".         ")
  61. m.setBackgroundColor(colors.lime)
  62. m.setCursorPos(14,13)
  63. m.write("Yes")
  64. m.setCursorPos(20,13)
  65. m.write("No")
  66. end
  67. function nether()
  68. m.setBackgroundColor(colors.red)
  69. m.setCursorPos(26,3)
  70. m.setTextColor(colors.white)
  71. m.write(">       ")
  72. m.setBackgroundColor(colors.orange)
  73. m.setCursorPos(27,3)
  74. m.write("ON")
  75. m.setCursorPos(30,3)
  76. m.write("OFF")
  77. end
  78. function spawner()
  79. button(26,4,colors.brown,colors.white,">       ")
  80. button(27,4,colors.purple,colors.white,"ON")
  81. button(30,4,colors.purple,colors.white,"OFF")
  82. end
  83.  
  84. while true do
  85.   event, side, xPos, yPos = os.pullEvent()
  86.   if click(8,27,16,16) then
  87.     clearDesk()
  88.   end
  89.  
  90.   if click(1,7,16,16) and menu ~= 2 then
  91.     menu = 1
  92.     shutDown()
  93.   end
  94.  
  95.   if menu == 1 and click(13,15,13,13) then
  96.       os.shutdown()
  97.     elseif menu == 1 and click(18,19,13,13) then
  98.       clearDesk()
  99.   end
  100.  
  101.   if click(28,30,16,16) and menu ~= 1 then
  102.     menu = 2
  103.     editCode()  
  104.   end
  105.    
  106.   if menu==2 and click(14,16,13,13) then
  107.       monitor.setBackgroundColor(colors.black)
  108.       monitor.setTextColor(colors.lime)
  109.       monitor.clear()
  110.       monitor.setCursorPos(10,6)
  111.       monitor.write("Reboot after")
  112.       monitor.setCursorPos(12,7)
  113.       monitor.write("editing!")
  114.       shell.run("code")  
  115.    elseif menu == 2 and click(20,21,13,13) then
  116.       clearDesk()
  117.   end
  118.  
  119.   if menu==0 and click(30,33,16,16) then
  120.     monitor.clear()
  121.     monitor.setCursorPos(11,6)
  122.     monitor.setTextColor(colors.yellow)
  123.     monitor.setBackgroundColor(colors.black)
  124.     monitor.write("Now in Lua")
  125.     shell.run("dolua")
  126.   end
  127.  
  128.   if menu==0 and click(33,33,3,3) then
  129.     menu=3
  130.     nether()
  131.   end
  132.  
  133.   if menu==3 and click(27,28,3,3) then
  134.       rs.setBundledOutput("back",colors.white)
  135.     elseif menu==3 and click(30,32,3,3) then
  136.       rs.setBundledOutput("back",0)
  137.     elseif menu==3 and click(26,26,3,3) then
  138.       clearDesk()
  139.   end
  140.  
  141.   if menu==0 and click(33,33,4,4) then
  142.     menu=4
  143.     spawner()
  144.   end
  145.  
  146.   if menu==4 and click(30,32,4,4) then
  147.     rs.setBundledOutput("back",colors.orange)
  148.   elseif click(26,26,4,4) then
  149.     clearDesk()
  150.   end
  151.   if event=="timer" then
  152.    clock=textutils.formatTime(os.time(),true)
  153.    m.setCursorPos(28,1)
  154.    m.setTextColor(colors.green)
  155.    m.setBackgroundColor(colors.black)
  156.    m.write(clock)
  157.    os.startTimer(0.5)
  158.   end
  159. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement