Advertisement
Guest User

os

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