pepeknamornik

Pastebin downloader

May 11th, 2015
337
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.98 KB | None | 0 0
  1. local function prc(text, y)
  2.   local w = term.getSize()
  3.   local _, cy = term.getCursorPos()
  4.   term.setCursorPos(math.ceil((w-#text)/2), y or cy)
  5.   write(text)
  6. end
  7.  
  8. function pastebin ()
  9.         local f=fs.open("system/.core/colors","r")
  10.         local cnt=f.readAll()
  11.         f.close()
  12.         local nastaveni=textutils.unserialize(cnt)
  13. local nastaveni=textutils.unserialize(cnt)
  14. term.setBackgroundColor(colors.white)
  15. term.clear ()
  16. term.setBackgroundColor(nastaveni.barva)
  17. term.setCursorPos(1,1)
  18. print "                                                   "
  19. term.setTextColor(colors.white)
  20. prc ("Pastebin Manager", 1)
  21. term.setTextColor(colors.black)
  22. term.setBackgroundColor(colors.lightBlue)
  23. term.setCursorPos(5,4)
  24. print "- Run "
  25. term.setCursorPos(5,6)
  26. print "- Get "
  27. term.setCursorPos(5,8)
  28. print "- Put "
  29. term.setBackgroundColor(colors.red)
  30. term.setCursorPos(51, 1)
  31. print " "
  32. term.setTextColor(colors.white)
  33. term.setCursorPos(51, 1)
  34. print "*"
  35. term.setTextColor(colors.black)
  36. term.setBackgroundColor(colors.white)
  37.  
  38. while true do
  39. local event, button, x, y = os.pullEventRaw()
  40. if event == "mouse_click" then
  41. if x >= 5 and x <= 10 and y == 4 and button == 1 then
  42. spustit ()
  43. elseif x >= 5 and x <= 10 and y == 6 and button == 1 then
  44. ulozit ()
  45. elseif x >= 5 and x <= 10 and y == 8 and button == 1 then
  46. nahrat ()
  47. elseif x == 51 and y == 1 and button == 1 then
  48. plocha ()
  49. end
  50. end
  51. end
  52. end
  53.  
  54. function spustit ()
  55. term.setCursorPos(4,12)
  56. print "enter the code"
  57. term.setCursorPos(4,13)
  58. term.setBackgroundColor(colors.lightBlue)
  59. print "          "
  60. term.setCursorPos(4,13)
  61. kod1 = io.read ()
  62. if kod1 == "" then
  63. pastebin ()
  64. else
  65. shell.run ("pastebin run",kod1)
  66. plocha ()
  67. end
  68.  
  69. while true do
  70. if x == 51 and y == 1 and button == 1 then
  71. plocha ()
  72. end
  73. end
  74. end
  75.  
  76. function ulozit ()
  77. term.setCursorPos(4,12)
  78. print "enter the code"
  79. term.setCursorPos(4,13)
  80. term.setBackgroundColor(colors.lightBlue)
  81. print "          "
  82. term.setCursorPos(4,13)
  83. kod1 = io.read ()
  84. if kod1 == "" then
  85. pastebin ()
  86. else
  87. term.setBackgroundColor(colors.white)
  88. term.setCursorPos(4,12)
  89. print "Name:  |Path: /system/downloads/.."
  90. print "                                     "
  91. end
  92. term.setCursorPos(4,13)
  93. term.setBackgroundColor(colors.lightBlue)
  94. print "          "
  95. term.setCursorPos(4,13)
  96. kod2 = io.read ()
  97. if kod2 == "" then
  98. pastebin ()
  99. else
  100. shell.run ("pastebin get",kod1,"/system/downloads/"..kod2)
  101. prohlizec ()
  102. end
  103. while true do
  104. if x == 51 and y == 1 and button == 1 then
  105. plocha ()
  106. end
  107. end
  108. end
  109.  
  110. function nahrat ()
  111. term.setCursorPos(4,12)
  112. print "enter the path"
  113. term.setCursorPos(4,13)
  114. term.setBackgroundColor(colors.lightBlue)
  115. print "          "
  116. term.setCursorPos(4,13)
  117. kod1 = io.read ()
  118. if kod1 == "" then
  119. pastebin ()
  120. else
  121. shell.run ("pastebin put",kod1)
  122. end
  123. pokr = io.read ()
  124. if pokr == "" then
  125. plocha ()
  126. else
  127. plocha ()
  128. end
  129. while true do
  130. if x == 51 and y == 1 and button == 1 then
  131. plocha ()
  132. end
  133. end
  134. end
  135.  
  136. function plocha ()
  137. shell.run ("/system/desktop")
  138. end
  139.  
  140. pastebin ()
Add Comment
Please, Sign In to add comment