Advertisement
Guest User

os

a guest
Jan 21st, 2020
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.53 KB | None | 0 0
  1. pri = peripheral.find("printer")
  2.  
  3.  
  4. if fs.isDir("home") then
  5. else fs.makeDir("home")
  6. end
  7. local stan = 1
  8. local prog = 1
  9. local br = 0
  10. local x10, y10 = term.getSize()
  11. --shell.setDir("home
  12.  
  13. function event(event)
  14. local event, f, s, t, fo, fi = os.pullEvent(event)
  15. if event == "key" then
  16.   if f == 200 then
  17.     return "up"
  18.     end
  19.   if f == 208 then
  20.     return "down"
  21.     end
  22.   if f == 28 then
  23.     return "enter"
  24.     end
  25.   if f == 29 then
  26.     return "ctrl"
  27.   end  
  28. end
  29. end    
  30.  
  31.  
  32. function printerCheck(y5)
  33.  
  34. if pri.getPaperLevel() < 2 then
  35. print("Not enough paper")
  36. return false
  37. else
  38. if pri.getInkLevel() < 2 then
  39. print("Not enough Ink")
  40. return false
  41. else
  42. local x,y = pri.getPageSize()
  43. if y5 == 21 then
  44. pri.endPage()
  45. if pri.newPage() then
  46.  else
  47.  print("Check printer")
  48.  end
  49. end
  50. return   true
  51. end
  52. end
  53.  
  54. end
  55.  
  56.  function linia(lin,x,y)
  57. term.setCursorPos(x,y)
  58. pri.setCursorPos(x,y)
  59. term.setTextColor(colors.white)
  60. term.write(lin)
  61. h.writeLine(lin)
  62. pri.write(lin)
  63.  
  64. end
  65.  
  66. function dalej(y)
  67. term.setCursorPos(1,y)
  68. term.setTextColor(colors.yellow)
  69. term.write("By wpisac wiecej kliknij Enter")
  70. term.setCursorPos(1,y+1)
  71. term.write("By contynuowac kliknij Ctrl")
  72. term.setTextColor(colors.white)
  73. local elo = event("key")
  74. term.setCursorPos(1,y)
  75. term.write("                               ")
  76. term.setCursorPos(1,y+1)
  77. term.write("                               ")
  78. if elo =="ctrl" then
  79. return true
  80. else
  81. return false
  82. end
  83. end
  84.  
  85.  
  86.  
  87.  
  88. function create_file()
  89. local name = typ("File name")
  90. shell.setDir("home")
  91. fs.makeDir("home/history")
  92. shell.setDir("home/history")
  93. if fs.exists(name) then
  94. term.write("Error")
  95. return 1
  96. else
  97. pri.newPage()
  98. h = fs.open("home/history/" .. name,"w")
  99. term.clear()
  100. if printerCheck() then
  101. linia(name,1,1)
  102. linia("Umowa kupna",1,2)
  103. linia(typ("Nick osoby kupujacej"),1,3)
  104. linia("Kupuje:",1,4)
  105. local y4 = 5
  106. repeat
  107. linia(typ("Produkty"),1,y4)
  108. y4 = y4+1
  109. until dalej(y4)
  110. linia("Placi:",1,y4)
  111. y4 = y4 +1
  112. repeat
  113. linia(typ("Zaplata"),1,y4)
  114. y4 = y4+1
  115. until dalej(y4)
  116. linia("Sprzedajacy:",1,y4)
  117. linia(typ("Nick osoby sprzedajacej"),13,y4)
  118. linia("UnPaid",1,y4+1)
  119. pri.endPage()
  120. h.writeLine("Paid")
  121. local Golf = os.clock()
  122. h.writeLine(math.ceil(math.abs(math.tan(os.time())*1000000)))
  123. else
  124. br = 1
  125. end
  126. end
  127. prog = 1
  128. term.clear()
  129. end
  130.  
  131.  
  132.  
  133. function typ(text)
  134. term.setCursorPos(1,y10-1)
  135. term.write("                                                 ")
  136. term.setCursorPos(1,y10-1)
  137. term.setCursorBlink(true)
  138. term.setTextColor(colors.yellow)
  139. term.write(text .. ">")
  140. term.setTextColor(colors.white)
  141. return read()
  142. end
  143.    
  144.  
  145. function decition()
  146. if prog == 1 then
  147. local ky = event()
  148. print(ky)
  149. term.clear()
  150.   if ky == "up" then
  151.    if stan == 1 then
  152.    
  153.    else
  154.    stan = stan-1
  155.    end
  156.   end
  157.   if ky == "down" then
  158.     if stan == 3 then
  159.    
  160.     else
  161.     stan = stan+1
  162.     end
  163.    end
  164.   if ky == "enter" then
  165.     prog = (stan + 1)
  166.     end
  167.   end  
  168.   dispay()
  169.  
  170. end
  171.  
  172.  
  173. function menu(x,y,op,s,text)
  174. if op == s then
  175. term.setCursorPos((x-((string.len(text)/2)-1)),y)
  176. term.setTextColor(colors.yellow)
  177. term.write(">")
  178. else
  179. term.setTextColor(colors.white)
  180. term.setCursorPos((x-(string.len(text)/2)+2),y)
  181. end
  182. term.write(text)
  183. if op == s then term.write("<") end
  184. end
  185.  
  186. function dispay()
  187. if prog == 1 then
  188. local x, y = term.getSize()
  189. menu((x/2)-3,7,stan,1,"Umowa")
  190. menu((x/2)-3,8,stan,2,"Konta")
  191. menu((x/2)-3,9,stan,3,"Histori")
  192. end
  193. if prog == 2 then
  194. term.clear()
  195. create_file()
  196. end
  197. end
  198.  
  199.  repeat
  200.  decition(prog)
  201.  sleep(0.1)
  202.  
  203.  
  204.  until terminated
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement