Advertisement
Guest User

moon

a guest
Jan 19th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.88 KB | None | 0 0
  1. local function printUsage()
  2.     print( "Usages:" )
  3.     print( "moon <location>" )
  4.     print( "or" )
  5.     print( "moon moon" )
  6. end
  7.  
  8. local tArgs = { ... }
  9. if #tArgs ~= 1 then
  10.     printUsage()
  11.     return
  12. end
  13.  
  14. if not http then
  15.     print( "Requires http API" )
  16.     print( "Set enableAPI_http to 1 in mod_ComputerCraft.cfg" )
  17.     return
  18. end
  19.  
  20. local url = "http://blink.lazytechsupport.co.uk:5000/moon/"
  21. local sLoc = tArgs[1]
  22. if sLoc ~= "help" then
  23.    
  24.     -- write( "Blinking " )
  25.     local sPage = http.get(url .. sLoc)
  26.        
  27.     if sPage then
  28.         term.clear()
  29.         term.setCursorPos(1,1)
  30.         for i = 1,26 do
  31.             term.setCursorPos(1,i)
  32.             term.write(sPage.readLine())
  33.            
  34. --            sleep(2)
  35.         end
  36.     else
  37.         print( "Failed to fetch data." )
  38.     end
  39.    sPage.close()
  40.    
  41. else
  42.     printUsage()
  43.     return
  44. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement