Advertisement
jamawie

Tastatur reloaded

Jun 5th, 2016
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.42 KB | None | 0 0
  1. wait = true
  2. idred = 8955
  3.  
  4. function start()
  5. term.clear()
  6. term.setTextColor(colors.cyan)
  7. term.setCursorPos(1,1)
  8. print("Word Programm")
  9. term.setTextColor(colors.white)
  10. term.setCursorPos(15,1)
  11. print("by")
  12. term.setCursorPos(18,1)
  13. term.setTextColor(colors.blue)
  14. print("Nike622000")
  15. term.setCursorPos(1,2)
  16. term.setTextColor(colors.white)
  17. print("Einfach mit der Tastatur schreiben: ")
  18. term.setCursorPos(1,3)
  19. term.setTextColor(colors.red)
  20. print("Entf")
  21. term.setCursorPos(6,3)
  22. term.setTextColor(colors.white)
  23. print("druecken um alles zu loeschen!")
  24. xPos = 4
  25. yPos = 7
  26. xMax,yMax = term.getSize()
  27. end
  28.  
  29. function main()
  30. while true do
  31. rednet.open("back")
  32. --print("Nachrichten werden empfangen!")
  33. id,message = rednet.receive()
  34. print(id)
  35. print(message)
  36. if id == idred and message == "Tastatur start" then
  37.  
  38. wait = false
  39.  
  40. i = 0
  41.  
  42.  
  43. start()
  44. g=1
  45. for l = 7,yMax-3 do
  46.     term.setTextColor(colors.white)
  47.     term.setCursorPos(1,l)
  48.         if g < 10 then
  49.         print("0"..g..":")
  50.         else
  51.         print(g..":")
  52.         end
  53.     g=g+1
  54. end
  55. senden = true
  56. Beschreibungkomplett = " "
  57. while senden do
  58. Eingabe = ""
  59. Eingabe2 = ""
  60. if yPos == yMax-2 then
  61. term.setCursorPos(1,yMax-1)
  62. term.setTextColor(colors.red)
  63. print("Maximale Textlaenge erreicht!")
  64. sleep(2)
  65. term.setCursorPos(1,yMax-1)
  66. print("                             ")
  67. term.setCursorPos(1,yMax-1)
  68. term.setTextColor(colors.red)
  69. print("Datei wird gesendet!")
  70. rednet.send(idred,"Tastatur stopp")
  71. senden = false
  72. sleep(2)
  73. rednet.send(idred,"Nachricht wird übermittelt")
  74. sleep(1)
  75. rednet.send(idred,Beschreibungkomplett)
  76. sleep(1)
  77. rednet.send(idred,"Nachricht wurde übermittelt")
  78. start()
  79. os.reboot()
  80. end
  81.  
  82. if xPos == xMax-1 then
  83. yPos = yPos+1
  84. xPos = 4
  85. Eingabe2 = "<E>"
  86. end
  87.  
  88. if i == 16 then
  89. i = 0
  90. end
  91. if i == -1 then
  92. i = 15
  93. end
  94.  
  95. farbe = 2^i
  96. term.setCursorPos(1,4)
  97. term.setTextColor(colors.white)
  98. print("Farbe mit den Pfeiltasten aendern (hoch/runter): ")
  99. term.setTextColor(farbe)
  100. print("momentane Farbe")
  101. event,key,x,y = os.pullEvent("key")
  102.  
  103. if farbechange == 1 then
  104. Beschreibungkomplett = Beschreibungkomplett.."("..farbe..")"
  105. farbechange = 0
  106. end
  107.  
  108. g=1
  109. for l = 7,yMax-3 do
  110.     term.setTextColor(colors.white)
  111.     term.setCursorPos(1,l)
  112.     if l == yPos then
  113.         term.setTextColor(colors.red)
  114.         if g < 10 then
  115.         print("0"..g..":")
  116.         else
  117.         print(g..":")
  118.         end
  119.     else
  120.         term.setTextColor(colors.white)
  121.         if g < 10 then
  122.         print("0"..g..":")
  123.         else
  124.         print(g..":")
  125.         end
  126.     end
  127. g=g+1
  128. end
  129.  
  130. term.setCursorPos(xPos,yPos)
  131. term.setTextColor(farbe)
  132.  
  133. if key == 211 then
  134. start()
  135. g=1
  136. for l = 7,yMax-3 do
  137.     term.setTextColor(colors.white)
  138.     term.setCursorPos(1,l)
  139.         if g < 10 then
  140.         print("0"..g..":")
  141.         else
  142.         print(g..":")
  143.         end
  144.     g=g+1
  145. end
  146. Beschreibungkomplett = " "
  147. end
  148.  
  149. if key == 2 or key == 79 then
  150. print("1")
  151. xPos=xPos+1
  152. Eingabe = "1"
  153. end
  154.  
  155. if key == 3 or key == 80 then
  156. print("2")
  157. xPos=xPos+1
  158. Eingabe = "2"
  159. end
  160.  
  161. if key == 4 or key == 81 then
  162. print("3")
  163. xPos=xPos+1
  164. Eingabe = "3"
  165. end
  166.  
  167. if key == 5 or key == 75 then
  168. print("4")
  169. xPos=xPos+1
  170. Eingabe = "4"
  171. end
  172.  
  173. if key == 6 or key == 76 then
  174. print("5")
  175. xPos=xPos+1
  176. Eingabe = "5"
  177. end
  178.  
  179. if key == 7 or key == 77 then
  180. print("6")
  181. xPos=xPos+1
  182. Eingabe = "6"
  183. end
  184.  
  185. if key == 8 or key == 71 then
  186. print("7")
  187. xPos=xPos+1
  188. Eingabe = "7"
  189. end
  190.  
  191. if key == 9 or key == 72 then
  192. print("8")
  193. xPos=xPos+1
  194. Eingabe = "8"
  195. end
  196.  
  197. if key == 10 or key == 73 then
  198. print("9")
  199. xPos=xPos+1
  200. Eingabe = "9"
  201. end
  202.  
  203. if key == 11 or key == 82 then
  204. print("0")
  205. xPos=xPos+1
  206. Eingabe = "0"
  207. end
  208.  
  209. if key == 16 then
  210. print("Q")
  211. xPos=xPos+1
  212. Eingabe = "Q"
  213. end
  214.  
  215. if key == 17 then
  216. print("W")
  217. xPos=xPos+1
  218. Eingabe = "W"
  219. end
  220.  
  221. if key == 18 then
  222. print("E")
  223. xPos=xPos+1
  224. Eingabe = "E"
  225. end
  226.  
  227. if key == 19 then
  228. print("R")
  229. xPos=xPos+1
  230. Eingabe = "R"
  231. end
  232.  
  233. if key == 20 then
  234. print("T")
  235. xPos=xPos+1
  236. Eingabe = "T"
  237. end
  238.  
  239. if key == 44 then
  240. print("Z")
  241. xPos=xPos+1
  242. Eingabe = "Z"
  243. end
  244.  
  245. if key == 22 then
  246. print("U")
  247. xPos=xPos+1
  248. Eingabe = "U"
  249. end
  250.  
  251. if key == 23 then
  252. print("I")
  253. xPos=xPos+1
  254. Eingabe = "I"
  255. end
  256.  
  257. if key == 24 then
  258. print("O")
  259. xPos=xPos+1
  260. Eingabe = "O"
  261. end
  262.  
  263. if key == 25 then
  264. print("P")
  265. xPos=xPos+1
  266. Eingabe = "P"
  267. end
  268.  
  269. if key == 28 then
  270. xPos = 4
  271. yPos = yPos+1
  272. Eingabe = "<E>"
  273. end
  274.  
  275. if key == 30 then
  276. print("A")
  277. xPos=xPos+1
  278. Eingabe = "A"
  279. end
  280.  
  281. if key == 31 then
  282. print("S")
  283. xPos=xPos+1
  284. Eingabe = "S"
  285. end
  286.  
  287. if key == 32 then
  288. print("D")
  289. xPos=xPos+1
  290. Eingabe = "D"
  291. end
  292.  
  293. if key == 33 then
  294. print("F")
  295. xPos=xPos+1
  296. Eingabe = "F"
  297. end
  298.  
  299. if key == 34 then
  300. print("G")
  301. xPos=xPos+1
  302. Eingabe = "G"
  303. end
  304.  
  305. if key == 35 then
  306. print("H")
  307. xPos=xPos+1
  308. Eingabe = "H"
  309. end
  310.  
  311. if key == 36 then
  312. print("J")
  313. xPos=xPos+1
  314. Eingabe = "J"
  315. end
  316.  
  317. if key == 37 then
  318. print("K")
  319. xPos=xPos+1
  320. Eingabe = "K"
  321. end
  322.  
  323. if key == 38 then
  324. print("L")
  325. xPos=xPos+1
  326. Eingabe = "L"
  327. end
  328.  
  329. if key == 21 then
  330. print("Y")
  331. xPos=xPos+1
  332. Eingabe = "Y"
  333. end
  334.  
  335. if key == 45 then
  336. print("X")
  337. xPos=xPos+1
  338. Eingabe = "X"
  339. end
  340.  
  341. if key == 46 then
  342. print("C")
  343. xPos=xPos+1
  344. Eingabe = "C"
  345. end
  346.  
  347. if key == 47 then
  348. print("V")
  349. xPos=xPos+1
  350. Eingabe = "V"
  351. end
  352.  
  353. if key == 48 then
  354. print("B")
  355. xPos=xPos+1
  356. Eingabe = "B"
  357. end
  358.  
  359. if key == 49 then
  360. print("N")
  361. xPos=xPos+1
  362. Eingabe = "N"
  363. end
  364.  
  365. if key == 50 then
  366. print("M")
  367. xPos=xPos+1
  368. Eingabe = "M"
  369. end
  370.  
  371. if key == 57 then
  372. print(" ")
  373. xPos=xPos+1
  374. Eingabe = " "
  375. end
  376.  
  377. if key == 52 then
  378. print(".")
  379. xPos=xPos+1
  380. Eingabe = "."
  381. end
  382.  
  383. if key == 200 then
  384. i = i+1
  385. Beschreibungkomplett = Beschreibungkomplett.."("..farbe..")"
  386. farbchange = 1
  387. end
  388.  
  389. if key == 208 then
  390. i = i-1
  391. farbchange = 1
  392. end
  393.  
  394. if key == 29 then
  395. term.setCursorPos(1,yMax-1)
  396. term.setTextColor(colors.red)
  397. print("Datei wird gesendet!")
  398. rednet.send(8955,"Tastatur stopp")
  399. senden = false
  400. sleep(2)
  401. rednet.send(8955,"Nachricht wird übermittelt")
  402. sleep(1)
  403. rednet.send(8955,Beschreibungkomplett)
  404. sleep(1)
  405. rednet.send(8955,"Nachricht wurde übermittelt")
  406. start()
  407. os.reboot()
  408. end
  409.  
  410.  
  411. Beschreibungfarbe = tostring(farbe)
  412. Beschreibungkomplett = Beschreibungkomplett..Eingabe2..Eingabe
  413. term.setCursorPos(10,10)
  414.  
  415. end
  416. end
  417. end
  418. end
  419.  
  420. function wait()
  421.     waitPosition = 0
  422.     waitX, waitY = term.getSize()
  423.     while true do
  424.         if wait==true then
  425.             for i=0,2 do
  426.                 if i==waitPosition then
  427.                     term.setTextColor(colors.cyan)
  428.                 else
  429.                     term.setTextColor(colors.white)
  430.                 end
  431.                 term.setCursorPos(math.floor((waitX-6)/2)+(waitPosition*3),math.floor(waitY/2))
  432.                 term.write("o")
  433.             end
  434.         end
  435.         sleep(1)
  436.     end
  437. end
  438.  
  439. parallel.waitForAny(main, wait)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement