Advertisement
Le_JuiceBOX

[App] rename.lua

Mar 29th, 2024 (edited)
826
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.97 KB | None | 0 0
  1. -- 987DVwt4
  2. local Terminal = require("/terminal").new()
  3.  
  4. local active = false
  5. local showColorsWindow = false
  6. local showChanged = false
  7.  
  8. function Main()
  9.     active = true
  10.     ShowMainPage()
  11. end
  12.  
  13. function ShowMainPage()
  14.     showChanged = false
  15.     while true do
  16.         local n = os.getComputerLabel() or ""
  17.         Terminal:reset()
  18.         Terminal:displayHeader({
  19.             "Turtle Renamer:",
  20.             "Use '"..Terminal.replaceSymbol.."' in your entry to color text.",
  21.             "Enter '/c' to see a list of color ids.",
  22.             "",
  23.             "Name: '"..n.."'",
  24.             "ID: "..os.getComputerID().."",
  25.             "",
  26.         })
  27.         local text = Terminal:prompt("Enter name:")
  28.         if text == "/c" then
  29.             ShowColorsPage()
  30.         else
  31.             text = Terminal:mcColorize(text or "Turtle")
  32.             local success = Terminal:promptConf("\nAre you sure you want '"..text.."'?",true)
  33.             if success then
  34.                 shell.run("label set \""..text.."\"")
  35.                 sleep(0.5)  
  36.                 Terminal:reset()
  37.                 break
  38.             end
  39.         end
  40.     end
  41. end
  42.  
  43. function ShowColorsPage()
  44.     Terminal:cancelPrompt()
  45.     showChanged = false
  46.     Terminal:reset()
  47.     Terminal:displayColumn(1,21,
  48.         {
  49.             "0 - Black",
  50.             "2 - Dark Green",
  51.             "4 - Dark Red",
  52.             "6 - Gold",
  53.             "8 - Dark Grey",
  54.             "a - Green",
  55.             "c - Red",
  56.             "e - Yellow",
  57.             "k - OBFUSCATE",
  58.             "m - STRIKE-THROUGH",
  59.             "o - ITALIC",
  60.         }, {
  61.             "1 - Dark Blue",
  62.             "3 - Dark Aqua",
  63.             "5 - Dark Purple",
  64.             "7 - Grey",
  65.             "9 - Blue",
  66.             "b - Aqua",
  67.             "d - Light Purple",
  68.             "f - White",
  69.             "l - BOLD",
  70.             "n - UNDERLINE",
  71.             "r - RESET",
  72.         }
  73.     )
  74.     Terminal:pressAnyKeyToContinue();
  75. end
  76.  
  77. Main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement