Advertisement
TitanChase

ControlPanel.lua

Nov 8th, 2016
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.23 KB | None | 0 0
  1. local file = fs.open("computers", "r")
  2. local selectedId
  3.  
  4. term.setTextColor(colors.blue)
  5. textutils.slowPrint("===Control Panel System===")
  6. textutils.slowPrint("=====By DiscworldZA=======")
  7.  
  8. term.setTextColor(colors.red)
  9. textutils.slowPrint("Reading IDs..")
  10. local ids = {}
  11. local names = {}
  12. local line
  13. i = 1
  14. repeat
  15.     line = file.readLine()
  16.     ids[i] = line
  17.     line = file.readLine()
  18.     names[i] = line
  19.     i = i + 1
  20. until line == "" or line == nil
  21. for j = 1,#ids, 1 do
  22.     print(ids[j] .. " " .. names[j])
  23. end
  24.  
  25. term.setTextColor(colors.white)
  26. write("Select Computer: ")
  27. selectedId = read()
  28. while true do
  29.     term.clear()
  30.     term.setCursorPos(1, 1)
  31.     print("===Menu===")
  32.     print("1. Start")
  33.     print("2. Stop")
  34.     print("3. Command")
  35.     command = read()
  36.  
  37.     if command == "Start" or command == "1" then
  38.         write("Enter Program to Start:")
  39.         program = read()
  40.         shell.run("send " .. selectedId .. " fg " .. program)
  41.     end
  42.  
  43.     if command == "Stop" or command == "2" then
  44.         write("Enter Program to Stop:")
  45.         program = read()
  46.         shell.run("send " .. selectedId .. " exit " .. program)
  47.     end
  48.  
  49.         if command == "Command" or command == "3" then
  50.         write("Enter Command:")
  51.         program = read()
  52.         shell.run("send " .. selectedId .. " " .. program)
  53.     end
  54. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement