Advertisement
Sir_Popsilots

testing3

Aug 2nd, 2021 (edited)
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.20 KB | None | 0 0
  1. print()
  2. local exitPressed = false
  3. local function DrawExit()
  4.     term.setCursorPos(17,1)
  5.     term.setBackgroundColor(colors.red)
  6.     term.setTextColor(colors.black)
  7.     print(" ")
  8.     term.setBackgroundColor(colors.black)
  9.     term.setTextColor(1)
  10. end
  11.  
  12. local function findWhichButton(x,y)
  13.     if (y == 5) and x == 2 then
  14.         return 0
  15.     elseif y==5 and (x==5 or x==6) then
  16.         return -3
  17.     elseif (y==3) and (10<x and x<16) then
  18.         return 10
  19.     elseif y==1 and x == 17 then
  20.         return -1
  21.     elseif x==2 or x==4 or x==6 then
  22.         if y==2 then
  23.             return x/2
  24.         elseif y==3 then
  25.             return x/2 + 3
  26.         elseif y==4 then
  27.             return x/2 + 6
  28.         end
  29.     end
  30.     return -2
  31. end
  32.  
  33. local function DrawBackSpace()
  34.    
  35. end
  36.  
  37. local function useKeyPad()
  38.     local Num = 0
  39.     print()
  40.     for i = 1 ,9 do
  41.         write("|")
  42.         term.setTextColor(colors.lightBlue)
  43.         write(i)
  44.         term.setTextColor(1)
  45.         if i%3==0 then write("|\n") end
  46.     end
  47.     write("|")
  48.     term.setTextColor(colors.lightBlue)
  49.     write(0)
  50.     term.setTextColor(1)
  51.     write("|[")
  52.     term.setTextColor(colors.orange)
  53.     write("<<")
  54.     term.setTextColor(1)
  55.     write("]")
  56.     term.setCursorPos(10,3)
  57.     write("[")
  58.     term.setTextColor(colors.lime)
  59.     write("Enter")
  60.     term.setTextColor(1)
  61.     write("]")
  62.     DrawExit()
  63.     local i = 0
  64.     repeat
  65.         local event, button, x, y = os.pullEvent("mouse_click")
  66.         local Button = findWhichButton(x,y)
  67.         if Button == 0 and i ~= 0 then
  68.             Num = Num * 10
  69.             i = i + 1
  70.         elseif Button == 10 then
  71.             i = 5
  72.         elseif Button == -2 then
  73.         elseif Button == -1 then
  74.             i = 5
  75.             exitPressed = true
  76.         elseif Button == -3 then
  77.             if i~=0 then
  78.                 Num = (Num - (Num%10))/10
  79.                 i = i - 1
  80.             end
  81.         else
  82.             Num = Num*10 + Button
  83.             i = i + 1
  84.         end
  85.         term.setCursorPos(1,1)
  86.         term.clearLine(0)
  87.         write(Num)
  88.         DrawExit()
  89.     until i > 3
  90.     return Num
  91. end
  92.  
  93. local a = useKeyPad()
  94. shell.execute("clear")
  95. print(a)
  96.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement