KedrikFeeD

startup.lua

Feb 12th, 2025 (edited)
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.64 KB | Gaming | 0 0
  1. local player = require("player")
  2. player.playStartup()
  3.  
  4. peripheral.find("modem", rednet.open)
  5.  
  6. local basalt = require("modules/basalt")
  7. local bgColor = colors.lightBlue
  8. basalt.setTheme("BaseFrameBG", bgColor)
  9. basalt.setTheme("InputText", colors.white)
  10.  
  11. local main = basalt.createFrame()
  12. local titleText = main:addLabel()
  13. titleText
  14.     :setBackground(bgColor)
  15.     :setText("MinerOS")
  16.     :setFontSize(2)
  17. local x, y = titleText:getSize()
  18. local tx, ty = term.getSize()
  19.  
  20. local titlePosX = math.floor(tx / 2 - x / 2) + 1
  21. local titlePosY = math.floor(ty / 2 - y / 2)
  22. titleText:setPosition(
  23.     titlePosX,
  24.     titlePosY
  25. )
  26.  
  27.  
  28. local password = main:addInput()
  29. password
  30.     :setInputType("password")
  31.     :setDefaultText("password")
  32.     :setSize(x, 1)
  33. local px, py = password.getSize()
  34. password
  35.     :setPosition(
  36.         math.floor(tx / 2 - px / 2) + 1,
  37.         math.floor(ty / 2 + y / 2)
  38.     )
  39.    
  40. local hint = main
  41.     :addLabel()
  42.     :setPosition(
  43.         math.floor(tx / 2 - px / 2) + 1,
  44.         math.floor(ty / 2 + y / 2) + 1
  45.     )
  46.     :hide()
  47.  
  48. local pMessager = main:addProgram()
  49. pMessager:setSize(tx,ty)
  50. pMessager:execute("messager.lua")
  51. pMessager:setVisible(false)
  52. function startMessager()
  53.     pMessager:setVisible(true)
  54. end
  55.  
  56. password
  57.     :onLoseFocus(function(self)
  58.         if self:getValue() == "stoneblock" then
  59.             startMessager()
  60.         else
  61.             hint
  62.                 :setText("Incorrect password")
  63.                 :setBackground(bgColor)
  64.                 :setForeground(colors.red)
  65.                 :show()
  66.         end
  67.         passValue = ""
  68.         self:setValue("")
  69.     end)
  70.  
  71. basalt.autoUpdate()
Add Comment
Please, Sign In to add comment