Guest User

door

a guest
Mar 23rd, 2015
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.91 KB | None | 0 0
  1. rednet.open("back")
  2. term.clear()
  3. term.setCursorPos(1, 1)
  4.  
  5. local function readCommand()
  6.     local command = read()
  7.     return command
  8. end
  9.  
  10. local function processCommand(command)
  11.     if command:lower() == "/help" then
  12.         term.clear()
  13.         term.setCursorPos(1, 1)
  14.         term.setTextColor(colors.red)
  15.         print("List o' Commands:")
  16.         term.setTextColor(colors.cyan)
  17.         print("/door -- Opens/Closes Castle Door")
  18.         print("/help -- List o' Commands (Obviously)")
  19.         term.setTextColor(colors.red)
  20.         print("Press any key to return to prompt")
  21.         os.pullEvent("key")
  22. else if command:lower() == "/door" then
  23. rednet.broadcast("door")
  24. print("Door Command executed")
  25.  
  26.  
  27.     else
  28.         rednet.broadcast(command)
  29.     end
  30. end
  31. end
  32.  
  33. while true do
  34.     term.clear()
  35.     term.setCursorPos(1, 1)
  36.     term.setTextColor(colors.red)
  37.     print("Command: (ex: /help)")
  38.     write("> ")
  39.     local command = readCommand()
  40.     processCommand(command)
  41. end
  42.  
  43. pocketCommands()
Advertisement
Add Comment
Please, Sign In to add comment