MarsP4ste

selectMainProgram

Jun 19th, 2021 (edited)
225
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local term = require("term")
  2. local gpu = term.gpu()
  3. local event = require("event")
  4. local shell = require("shell")
  5. local sizeX, sizeY = term.getViewport()
  6. local dBack = 0x365991
  7.  
  8.  
  9. --functions
  10.  
  11. function clearScreen()
  12.   setBack(dBack)
  13.   term.clear()
  14.   setCursor(1,1)
  15. end
  16.  
  17. function setBack(color)
  18.   gpu.setBackground(color, false)
  19. end
  20.  
  21. function setCursor(x,y)
  22.   term.setCursor(x,y)
  23. end
  24.  
  25. function printLine()
  26.   local i = sizeX
  27.   local s = ""
  28.   while i > 0 do    
  29.     s = s.."-"
  30.     i = i - 1
  31.   end
  32.   print(s)
  33. end
  34.  
  35. function selectAction()
  36.   setBack(dBack)
  37.   clearScreen()
  38.   local t1 = "What do you want to do?"
  39.   local l1 = string.len(t1)/2
  40.   setCursor(sizeX/2-l1,1)
  41.   print(t1)
  42.   printLine()
  43.   local li = "------------      ------------"
  44.   local b1 = "|  manage  |      |  create  |"
  45.   local b2 = "| transaction |"
  46.   local li2 ="---------------"
  47.   local l2 = string.len(b2)/2
  48.   local l1 = string.len(b1)/2
  49.   local x = sizeX/2-l1
  50.   setCursor(x,sizeY/2-1)
  51.   print(li)
  52.   setCursor(x,sizeY/2)
  53.   print(b1)
  54.   setCursor(x,sizeY/2+1)
  55.   print(li)
  56.   setCursor(sizeX/2-l2,sizeY/2+4)
  57.   print(li2)
  58.   setCursor(sizeX/2-l2,sizeY/2+5)
  59.   print(b2)
  60.   setCursor(sizeX/2-l2,sizeY/2+6)
  61.   print(li2)
  62.   while true do
  63.     local _,_,x,y,_,n = event.pull("touch")
  64.     --print(x,y)
  65.     --os.sleep(4)
  66.     if x >= 25 and x <= 36 and y >= 11 and y <= 13 then
  67.       --shell.execute("/home/manageAccount.lua")
  68.       shell.execute("/home/wip.lua")
  69.       break
  70.     elseif x >= 43 and x <= 55 and y >= 11 and y <= 13 then
  71.       shell.execute("/home/createAccount.lua")
  72.       break
  73.     elseif x >= 21 and x <= 48 and y >= 16 and y <= 18 then
  74.       shell.execute("/home/doTransaction.lua")
  75.       break
  76.     end
  77.   end
  78. end
  79.  
  80.  
  81. selectAction()
RAW Paste Data