Advertisement
taylantz

MC - CC eva

May 23rd, 2013
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.07 KB | None | 0 0
  1. s = shell
  2. t = term
  3. c = colors
  4. m = math
  5.  
  6. local function mittig(vtext, y)
  7.     w, h = t.getSize()
  8.     mitte = m.floor((w/2) - (string.len(vtext)/2))
  9.     t.setCursorPos(mitte, y)
  10.     t.write(vtext)
  11. end
  12.  
  13. local function pruefeXY( x, y )
  14.     if x < 0 then x = 0 end
  15.     if x > 2 then x = 2 end
  16.     if y < 0 then y = 0 end
  17.     if y > 2 then y = 2 end
  18.     return x, y
  19. end
  20.  
  21. local function zeigeCode( vcode )
  22.     mittig("| [ ] [ ] [ ] [ ] |", 9)
  23.     for codeLaenge = 1, string.len(vcode), 1 do
  24.         t.setTextColor(c.lightBlue)
  25.         t.setCursorPos((w/2)-(13/2)+((codeLaenge-1)*4), 9)
  26.         t.write(string.sub(vcode, codeLaenge, codeLaenge))
  27.     end
  28.     t.setTextColor(c.lightGray)
  29. end
  30.  
  31. local function pinPad()
  32.     x = 0
  33.     y = 0
  34.     w, h = t.getSize()
  35.     code = ""
  36.  
  37.     t.setTextColor(c.lightGray)
  38.     mittig("[    PASSWORT!    ]", 3)
  39.     mittig("| --------------- |", 4)
  40.     mittig("| [1]   [2]   [3] |", 5)
  41.     mittig("| [4]   [5]   [6] |", 6)
  42.     mittig("| [7]   [8]   [9] |", 7)
  43.     mittig("| --------------- |", 8)
  44.     mittig("| [ ] [ ] [ ] [ ] |", 9)
  45.     mittig("| --------------- |", 10)
  46.     mittig("| [    ENTER    ] |", 11)
  47.     while true do
  48.         ereignis, parameter = os.pullEvent("key")
  49.         if ereignis == "key" then
  50.             t.setCursorPos((w/2)-(15/2)+(x*6), 5 + y)
  51.             t.write("[" .. math.floor((y*3) + (x+1)) .. "]")
  52.             if parameter == 200 then -- Hoch
  53.                 y = y - 1
  54.             end
  55.             if parameter == 208 then -- Runter
  56.                 y = y + 1
  57.             end
  58.             if parameter == 203 then -- Links
  59.                 x = x - 1
  60.             end
  61.             if parameter == 205 then -- Rechts
  62.                 x = x + 1
  63.             end
  64.             x, y = pruefeXY(x,y) -- Rechnung für Zahl = (y*3) + (x+1)
  65.             t.setCursorPos((w/2)-(15/2)+(x*6), 5 + y)
  66.             t.setTextColor(c.magenta)
  67.             t.write("[" .. math.floor((y*3) + (x+1)) .. "]")
  68.             t.setTextColor(c.lightGray)
  69.             if parameter == 57 then
  70.                 if string.len(code) < 4 then
  71.                     code = code .. (y*3) + (x+1)
  72.                     zeigeCode(code)
  73.                 end
  74.             end
  75.             if parameter == 14 then
  76.                 if string.len(code) >= 1 then
  77.                     code = string.sub(code, 1, string.len(code) - 1)
  78.                     zeigeCode(code)
  79.                 end
  80.             end
  81.             if parameter == 28 then
  82.                 if code == "4253" then
  83.                     t.clear()
  84.                     t.setTextColor(c.lime)
  85.                     mittig("ACCESS GRANTED", 3)
  86.                     t.setCursorPos(1, 5)
  87.                     break
  88.                 end
  89.             end
  90.         end
  91.     end
  92. end
  93.  
  94. local function ladeBalken(w)
  95.     balkenFarbe = {16384,2,16,32,32}
  96.     for prozent = 0, 100, 1 do
  97.         t.setTextColor(m.floor(balkenFarbe[m.floor(prozent/25)+1]))
  98.         t.setCursorPos((w/2)-12, 8)
  99.         lbalken = "["
  100.         for gleichzeichen = 0, prozent/5, 1 do
  101.             lbalken = lbalken .. "="
  102.         end
  103.         lbalken = lbalken .. ">"
  104.         for leerzeichen = 0, 22-string.len(lbalken), 1 do
  105.             lbalken = lbalken .. " "
  106.         end
  107.         lbalken = lbalken .. "]"
  108.         t.write(lbalken)
  109.         t.setCursorPos((w/2)-2, 9)
  110.         t.write(prozent.." %")
  111.         sleep(0.02)
  112.     end
  113.     t.setTextColor(c.white)
  114.     t.setCursorPos(1, 9)
  115.     t.clearLine()
  116.     t.setCursorPos(1, 8)
  117.     t.clearLine()
  118.     t.setCursorPos((w/2)-6, 8)
  119.     t.write("WILLKOMMEN!")
  120.     sleep(1.5)
  121. end
  122.  
  123. local function startBildschirm()
  124.     t.clear()
  125.     w, h = t.getSize()
  126.     t.setCursorPos((w/2)-8, 5)
  127.     t.setTextColor(c.green)
  128.     t.write("Starte EVA v0.7a")
  129.     ladeBalken(w)
  130. end
  131.  
  132. startBildschirm()
  133. pinPad()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement