Advertisement
Muzze77

WorkShop

May 29th, 2016
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.44 KB | None | 0 0
  1. shell.run("clear")
  2. mon = peripheral.wrap("right")
  3. printer = peripheral.wrap("left")
  4. term.setBackgroundColor(colors.black)
  5. term.setTextColor(colors.white)
  6. function beginn()
  7. if fs.exists("jobsFile") == false then
  8. jobs = {}
  9. jobs[1] = {Name = "Muster", Job = "Unterstuetzen", CArt = "UU-Matter", CSize = "Stack / Jahr", PW = "dontDel"}
  10.    cFile = fs.open("jobsFile","w")
  11.    cFile.write(textutils.serialize(jobs))
  12.    cFile.close()
  13. else
  14.    grFile = fs.open("jobsFile","r")
  15.    jobs = textutils.unserialize(grFile.readAll())
  16.    grFile.close()
  17. end
  18. beginn1()
  19. end
  20. gx , gy = term.getSize()
  21. gmx, gmy = mon.getSize()
  22.  
  23. function save()
  24. shell.run("delete jobsFile")
  25. qsFile = fs.open("jobsFile","w")
  26. qsFile.write(textutils.serialize(jobs))
  27. qsFile.close()
  28.  
  29.  
  30. end
  31. function delJob()
  32. shell.run("clear")
  33. for jb = 1 , table.maxn(jobs),1 do
  34.   print("[" .. jb .. "] " .. jobs[jb].Name)
  35. end
  36.   print("Zum loeschen zahl ausweahlen")
  37.   num = io.read()
  38.   if num > table.maxn(jobs) then
  39.       print("Kein Jobeintrag vorhanden unter dieser Nummer")
  40.       sleep(2)
  41.       beginn()
  42.   else
  43.   print("Bitte Password zum loeschen eingeben")
  44.   delpw = io.read()
  45.     if delpw == jobs[num].PW then
  46.       table.remove(jobs,num)
  47.       print("Job geloescht")
  48.       save()
  49.     else
  50.       print("Password wurde falsch eingegben")
  51.       sleep(2)
  52.       beginn()
  53.     end
  54.   end
  55.  
  56. end
  57.  
  58.  
  59. function newJob()
  60. shell.run("clear")
  61. term.setCursorPos(2,2)
  62. print("Bitte Namen eingeben")
  63. term.setCursorPos(2,3)
  64. name = io.read()
  65. shell.run("clear")
  66. term.setCursorPos(2,2)
  67. print("Bitte Auftrag eingeben")
  68. term.setCursorPos(2,3)
  69. job = io.read()
  70. shell.run("clear")
  71. term.setCursorPos(2,2)
  72. print("Bitte Bezahlungsart eingeben")
  73. term.setCursorPos(2,3)
  74. cur = io.read()
  75. shell.run("clear")
  76. term.setCursorPos(2,2)
  77. print("Bitte Anzahl eingeben")
  78. term.setCursorPos(2,3)
  79. csize = io.read()
  80. shell.run("clear")
  81. term.setCursorPos(2,2)
  82. print("Bitte Password eingeben.")
  83. print("Wird zum Loeschen benoetigt")
  84. term.setCursorPos(2,4)
  85. pw = io.read()
  86. term.setCursorPos(2,2)
  87. print("Sind Sie sich mit den Daten sicher ? [Y/N]")
  88. evt, key2 = os.pullEvent("char")
  89. key2 = string.lower(key2)
  90. if key2 == "y" then
  91. table.insert(jobs, {Name = name, Job = job, CArt = cur, CSize = csize, PW = pw})
  92. save()
  93. print("Daten gespeichert")
  94. sleep(0.5)
  95.  
  96. elseif key2 == "n" then
  97. print("Daten NICHT gespeichert")
  98. beginn()
  99. else
  100. print("Daten nicht gespeichert")
  101. beginn()
  102. end
  103.  
  104.  
  105. end
  106.  
  107.  
  108.  
  109. function beginn1()
  110.  
  111. shell.run("clear")
  112. term.setCursorPos(gx/2 - 15,2)
  113. print("Willkommen bei Muzze77 JobOMat")
  114. term.setCursorPos(1,4)
  115. print("Bitte eine Aktion waehlen")
  116. print("[N] Um neuen Job zu erstellen")
  117. print("[D] Um Job zu loeschen")
  118. print("[E] Um Job anzunehmen")
  119. evt, key = os.pullEvent("char")
  120. key = string.lower(key)
  121. if key == "n" then
  122. newJob()
  123. elseif key == "d" then
  124. delJob()
  125. elseif key == "e" then
  126.  
  127. end
  128. end
  129.  
  130. function listMonJobs()
  131. v = 1
  132. while endvar ~= 0 do
  133. mon.clear()
  134. mon.setCursorPos(2,2)
  135. if v == table.maxn(jobs) + 1 then
  136. v = 1
  137. end
  138. mon.write("Job Nr        : " .. v)
  139. mon.setCursorPos(2,3)
  140. mon.write("Auftraggeber  : " .. jobs[v].Name)
  141. mon.setCursorPos(2,4)
  142. mon.write("Auftrag       : " .. jobs[v].Job)
  143. mon.setCursorPos(2,5)    
  144. mon.write("Bezahlungsart : " .. jobs[v].CArt)
  145. mon.setCursorPos(2,6)
  146. mon.write("Bezahlung     : " .. jobs[v].CSize)
  147. v = v + 1
  148. evt, side, x , y = os.pullEvent("monitor_touch")
  149.  
  150. end
  151.  
  152. end
  153.  
  154. while true do
  155. parallel.waitForAny(beginn,listMonJobs)
  156. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement