Advertisement
PrinceOfCookies

new .command

Jul 22nd, 2024 (edited)
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.80 KB | None | 0 0
  1. local cosUtils = require("apis/cosUtils.lua")
  2.  
  3. local monitor = cosUtils.isMonitorHere()
  4.  
  5. local function takeInput(device)
  6.     while true do
  7.         device.write("> ")
  8.  
  9.         local input = read()
  10.  
  11.         if input == "back" then
  12.             device.clear()
  13.             shell.run("/2/.menu")
  14.             break
  15.         end
  16.  
  17.         shell.run(input)
  18.     end
  19. end
  20.  
  21. local function cmdPrompt(device)
  22.     device.settextcolor(colors.white)
  23.     device.clear()
  24.     device.setCursorPos(1, 1)
  25.  
  26.     if device.setTextScale then
  27.         device.setTextScale(0.5)
  28.     end
  29.  
  30.     device.write("Welcome to COS CMD Prompt")
  31.     device.setCursorPos(1, 2)
  32.     device.write("To return to the main menu, type 'back'")
  33.     device.setCursorPos(1, 3)
  34.     device.write("===================================================")
  35.     device.setCursorPos(1, 4)
  36.  
  37.     takeInput(device)
  38. end
  39.  
  40. cmdPrompt(monitor and monitor or term)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement