Advertisement
Enderlein

TwilightPortal

Jun 22nd, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.27 KB | None | 0 0
  1. local function isempty(s)
  2.     return (s == nil or s == "")
  3. end
  4.  
  5. local function help()
  6.     print("Use:")
  7.     print("TwilightPortal [command] (time)")
  8.     print("")
  9.     print("command - Can be either \"open\" or \"close\" to open or close the portal")
  10.     print("")
  11.     print("time - Optional. This is the amount of time (in seconds) that you want the command to run for")
  12.     print("")
  13. end
  14.  
  15. args = {...}
  16.  
  17. command = args[1]
  18. time = tonumber(args[2])
  19.  
  20. if command == "help" then
  21.     help()
  22. end
  23.  
  24.  
  25. if command == "close" then
  26.     redstone.setOutput("back", true)
  27.  
  28.     if not isempty(time) then
  29.         print(string.format("Twilight Portal is closed for %02d seconds", time))
  30.         sleep(time)
  31.         redstone.setOutput("back", false)
  32.     end
  33.  
  34. else
  35.    
  36.     if command == "open" then
  37.         redstone.setOutput("back", false)
  38.  
  39.         if not isempty(time) then
  40.             print(string.format("Twilight Portal is open for %02d seconds", time))
  41.             sleep(time)
  42.             redstone.setOutput("back", true)
  43.         end
  44.  
  45.     end
  46.  
  47. end
  48.  
  49. if command ~= "open" and command ~= "close" and command ~= "help" then
  50.     print("ERROR: The first arg has to be either \"open\" or \"close\" ")
  51.     print("")
  52.     print("For help, do \"TwilightPortal help\" ")
  53. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement