Guest User

guiold

a guest
Aug 28th, 2020
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.46 KB | None | 0 0
  1. --os.pullEvent = os.pullEventRaw
  2. ret1, ret2 = nil, nil --return for parallel functions
  3.  
  4. textStart = 11
  5. localver = "0.2"
  6. remotevercheck = http.get("http://infaknox.space/version")
  7. remotever = remotevercheck.readAll()
  8. function drawHeader()
  9.   -- Blue
  10.     term.setTextColor(colors.blue)
  11.     term.setCursorPos(3, 2)        term.write("O")
  12.     term.setCursorPos(4,3)         term.write("O")
  13.   -- Orange
  14.     term.setTextColor(colors.orange)
  15.     term.setCursorPos(3, 3)        term.write("@")
  16.   -- Text
  17.     term.setCursorPos(4, 2)        term.write("InfaKnox Systems.")
  18.     term.setCursorPos(33, 3)       term.write("discord.gg/R7edKN5")
  19.   -- Version Information
  20.     term.setCursorPos(40, 2)       term.write("Version: ")
  21.     term.setCursorPos(15, 19)      term.write("http://InfaKnox.Space")
  22.   -- term.setBackgroundColor(colors.black)
  23.   if remotever == localver then
  24.     term.setTextColor(colors.lime)
  25.     else
  26.     term.setTextColor(colors.red)
  27.     end
  28.     term.setCursorPos(48, 2)        term.write("0.2")
  29.     term.setTextColor(colors.white)
  30.     term.setBackgroundColor(colors.black)
  31.    
  32.    
  33. end
  34.  
  35. function drawButtons()
  36.     term.setBackgroundColor(colors.lightGray)
  37.     term.setCursorPos(3, textStart)        term.write("  ")
  38.     term.setCursorPos(3, textStart + 2)    term.write("  ")
  39.     term.setCursorPos(3, textStart + 4)    term.write("  ")
  40.     term.setCursorPos(3, textStart + 6)    term.write("  ")
  41.  
  42.     term.setCursorPos(48, textStart)    term.write("  ")
  43.     term.setCursorPos(48, textStart + 2)    term.write("  ")
  44.     term.setCursorPos(48, textStart + 4)    term.write("  ")
  45.     term.setCursorPos(48, textStart + 6)    term.write("  ")
  46.  
  47.     term.setBackgroundColor(colors.black)
  48. end
  49.  
  50. function drawButton(button, text)
  51.     local x, y
  52. --    if button == 1 then    x = 6        y = textStart        end
  53.     if button == 1 then    x = 6        y = textStart term.setBackgroundColor(colors.lightGray) term.setCursorPos(3, textStart)        term.write("  ") term.setBackgroundColor(colors.black)     end
  54.     if button == 2 then    x = 6        y = textStart + 2 term.setBackgroundColor(colors.lightGray) term.setCursorPos(3, textStart)        term.write("  ")   term.setBackgroundColor(colors.black)   end
  55.     if button == 3 then    x = 6        y = textStart + 4 term.setBackgroundColor(colors.lightGray) term.setCursorPos(3, textStart)        term.write("  ")   term.setBackgroundColor(colors.black)   end
  56.     if button == 4 then    x = 6        y = textStart + 6 term.setBackgroundColor(colors.lightGray) term.setCursorPos(3, textStart)        term.write("  ")   term.setBackgroundColor(colors.black)   end
  57.  
  58.     if button == 5 then    x = 47 - #text    y = textStart        end
  59.     if button == 6 then    x = 47 - #text    y = textStart + 2    end
  60.     if button == 7 then    x = 47 - #text    y = textStart + 4    end
  61.     if button == 8 then    x = 47 - #text    y = textStart + 6    end
  62.  
  63.     term.setCursorPos(x, y)
  64.     term.write(text)
  65. end
  66.  
  67. function drawError(error)
  68.     -- Outer Triangle
  69.     term.setBackgroundColor(colors.red)
  70.     term.setCursorPos(12, textStart)            term.write(" ")
  71.     term.setCursorPos(11, textStart + 1)        term.write(" ")
  72.     term.setCursorPos(10, textStart + 2)        term.write(" ")
  73.     term.setCursorPos(9, textStart + 3)            term.write(" ")
  74.     term.setCursorPos(8, textStart + 4)            term.write(" ")
  75.     term.setCursorPos(7, textStart + 5)            term.write(" ")
  76.     term.setCursorPos(6, textStart + 6)            term.write("             ")
  77.  
  78.     term.setCursorPos(13, textStart + 1)        term.write(" ")
  79.     term.setCursorPos(14, textStart + 2)        term.write(" ")
  80.     term.setCursorPos(15, textStart + 3)        term.write(" ")
  81.     term.setCursorPos(16, textStart + 4)        term.write(" ")
  82.     term.setCursorPos(17, textStart + 5)        term.write(" ")
  83.  
  84.     -- Inner Triangle
  85.     term.setBackgroundColor(colors.white)
  86.     term.setCursorPos(12, textStart + 1)        term.write(" ")
  87.     term.setCursorPos(11, textStart + 2)        term.write("   ")
  88.     term.setCursorPos(10, textStart + 3)        term.write("     ")
  89.     term.setCursorPos(9, textStart + 4)            term.write("       ")
  90.     term.setCursorPos(8, textStart + 5)            term.write("         ")
  91.  
  92.     -- !
  93.     term.setBackgroundColor(colors.black)
  94.     term.setCursorPos(12, textStart + 2)        term.write(" ")
  95.     term.setCursorPos(12, textStart + 3)        term.write(" ")
  96.     term.setCursorPos(12, textStart + 5)        term.write(" ")
  97.  
  98.     -- Text
  99.     term.setBackgroundColor(colors.black)
  100.     term.setCursorPos(20, textStart)            term.write(error)
  101.  
  102.     term.setBackgroundColor(colors.black)
  103. end
  104.  
  105. function center(y, sText)
  106.     local w, h = term.getSize()
  107.     x = math.max(math.floor((w - #sText) / 2), 0)
  108.     term.setCursorPos(x, y)
  109.     print(sText)
  110.     return x
  111. end
  112.  
  113. function waitForMouse()
  114.     while true do
  115.         local event, p1, p2, p3 = os.pullEvent("mouse_click")
  116.         if p1 == 1 then
  117.             ret1, ret2 = p2, p3
  118.             return p2, p3
  119.         end
  120.     end
  121. end
  122.  
  123. function waitForButton()
  124.     while true do
  125.         local mx, my = waitForMouse()
  126.         if my == textStart and mx >= 3 and mx <= 4 then            ret1 = 1    return 1    end
  127.         if my == textStart + 2 and mx >= 3 and mx <= 4 then        ret1 = 2    return 2    end
  128.         if my == textStart + 4 and mx >= 3 and mx <= 4 then        ret1 = 3    return 3    end
  129.         if my == textStart + 6 and mx >= 3 and mx <= 4 then        ret1 = 4    return 4    end
  130.  
  131.         if my == textStart and mx >= 48 and mx <= 49 then        ret1 = 5    return 5    end
  132.         if my == textStart + 2 and mx >= 48 and mx <= 49 then        ret1 = 6    return 6    end
  133.         if my == textStart + 4 and mx >= 48 and mx <= 49 then        ret1 = 7    return 7    end
  134.         if my == textStart + 6 and mx >= 48 and mx <= 49 then        ret1 = 8    return 8    end
  135.     end
  136. end
  137.  
  138. function waitForChar()
  139.     while true do
  140.         local event, p1 = os.pullEvent("char")
  141.         ret1 = p1
  142.         return p1
  143.     end
  144. end
  145.  
  146. function waitForKey()
  147.     while true do
  148.         local event, p1 = os.pullEvent("key")
  149.         ret1 = p1
  150.         return p1
  151.     end
  152. end
  153.  
  154. function waitForEnter()
  155.     while true do
  156.         local p1 = waitForKey()
  157.         if p1 == 28 then
  158.             return
  159.         end
  160.     end
  161. end
  162.  
  163. function waitForDisk()
  164.     while true do
  165.         local event, p1 = os.pullEvent("disk")
  166.         return
  167.     end
  168. end
Add Comment
Please, Sign In to add comment