Advertisement
IAmCiel_

Untitled

Feb 26th, 2025 (edited)
351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.42 KB | None | 0 0
  1. local doorSide = "bottom"  -- Change to where the redstone signal is sent
  2. local resetTime = 5 * 60  -- Time in seconds before terminal resets
  3. local idleTime = 120  -- Time in seconds before auto-reset due to inactivity
  4. local loggedIn = false
  5. local username = "admin"
  6. local password = "password"
  7. local options = {"Open Door", "Close Door", "Check Access Logs", "Logout"}
  8. local selectedOption = nil
  9.  
  10. -- Function to generate corrupted logs
  11. local function generateCorruptData()
  12.     local chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*"
  13.     local data = "DATA CORRUPTED\n"
  14.     for i = 1, 10 do
  15.         local line = ""
  16.         for j = 1, math.random(10, 25) do
  17.             line = line .. chars:sub(math.random(1, #chars), math.random(1, #chars))
  18.         end
  19.         data = data .. line .. "\n"
  20.     end
  21.     return data
  22. end
  23.  
  24. -- Function to pulse a bundled cable signal
  25. local function pulseBundledSignal(color)
  26.     for i = 1, 8 do
  27.         redstone.setBundledOutput(doorSide, color)
  28.         sleep(0.2)
  29.         redstone.setBundledOutput(doorSide, 0)
  30.         sleep(0.2)
  31.     end
  32. end
  33.  
  34. -- Function to draw the login screen
  35. local function drawLoginScreen()
  36.     term.clear()
  37.     term.setCursorPos(1, 1)
  38.     print("== SECURE TERMINAL LOGIN ==")
  39.     term.setCursorPos(1, 3)
  40.     write("Username: ")
  41.     local inputUsername = read()
  42.     term.setCursorPos(1, 4)
  43.     write("Password: ")
  44.     local inputPassword = read("*")
  45.  
  46.     if inputUsername == username and inputPassword == password then
  47.         loggedIn = true
  48.         print("Login successful!")
  49.         sleep(1)
  50.     else
  51.         print("Login failed. Access denied.")
  52.         sleep(2)
  53.     end
  54. end
  55.  
  56. -- Function to draw the main menu
  57. local function drawMenu()
  58.     term.clear()
  59.     term.setCursorPos(1, 1)
  60.     print("== SECURE TERMINAL MENU ==")
  61.     for i, option in ipairs(options) do
  62.         if selectedOption == i then
  63.             term.setTextColor(colors.yellow)
  64.             term.setBackgroundColor(colors.gray)
  65.         else
  66.             term.setTextColor(colors.white)
  67.             term.setBackgroundColor(colors.black)
  68.         end
  69.         term.setCursorPos(2, i + 2)
  70.         term.clearLine()
  71.         term.write(option)
  72.     end
  73.     term.setTextColor(colors.white)
  74.     term.setBackgroundColor(colors.black)
  75. end
  76.  
  77. -- Function to handle mouse input for menu selection
  78. local function handleMouseInput()
  79.     while true do
  80.         local event, button, x, y = os.pullEvent("mouse_click")
  81.         if button == 1 then -- Left click
  82.             local optionIndex = y - 2
  83.             if optionIndex >= 1 and optionIndex <= #options then
  84.                 selectedOption = optionIndex
  85.                 drawMenu()
  86.                 return
  87.             end
  88.         end
  89.     end
  90. end
  91.  
  92. -- Function to handle menu selection
  93. local function handleMenuSelection()
  94.     while loggedIn do
  95.         drawMenu()
  96.         handleMouseInput()
  97.         if selectedOption == 1 then
  98.             term.clear()
  99.             print("Are you sure you want to open the door? (y/n)")
  100.             local confirm = read():lower()
  101.             if confirm == "y" then
  102.                 print("Opening Door...")
  103.                 pulseBundledSignal(colors.green)
  104.             end
  105.             drawMenu()
  106.         elseif selectedOption == 2 then
  107.             term.clear()
  108.             print("Are you sure you want to close the door? (y/n)")
  109.             local confirm = read():lower()
  110.             if confirm == "y" then
  111.                 print("Closing Door...")
  112.                 pulseBundledSignal(colors.red)
  113.             end
  114.             drawMenu()
  115.         elseif selectedOption == 3 then
  116.             term.clear()
  117.             print("Retrieving logs...")
  118.             sleep(1)
  119.             print(generateCorruptData())
  120.             sleep(4)
  121.             drawMenu()
  122.         elseif selectedOption == 4 then
  123.             term.clear()
  124.             print("Logging Out...")
  125.             sleep(1)
  126.             loggedIn = false
  127.         end
  128.         selectedOption = nil
  129.     end
  130. end
  131.  
  132. -- Function to reset the terminal after X minutes
  133. local function resetTimer()
  134.     sleep(resetTime)
  135.     loggedIn = false
  136.     print("System reset. Login required again.")
  137. end
  138.  
  139. -- Main execution
  140. while true do
  141.     if not loggedIn then
  142.         drawLoginScreen()
  143.         if loggedIn then
  144.             parallel.waitForAny(handleMenuSelection, resetTimer)
  145.         else
  146.             sleep(5)
  147.         end
  148.     else
  149.         handleMenuSelection()
  150.     end
  151. end
  152.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement