Advertisement
Wyvern67

EnderPouchManager: Pocket script

Jul 17th, 2015
389
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.11 KB | None | 0 0
  1. function set(channel, data)
  2.     -- Function originally coded by ilgazzi
  3.     data = tostring(data)
  4.     url = "http://craft-a-cloud.mooo.com/upload.php?name="..channel.."&data="..data
  5.     encoded=textutils.urlEncode(url)
  6.     http.request(url)
  7.     local i=0
  8.     while get(channel) ~= data do
  9.         if i >= 20 then
  10.             return false
  11.         end
  12.         sleep(0.25)
  13.         i = i+1
  14.     end
  15.     return true
  16. end
  17.  
  18. function get(channel)
  19.     -- Function originally coded by ilgazzi
  20.     url = "http://craft-a-cloud.mooo.com/download.php?name="..channel
  21.     encoded=textutils.urlEncode(url)
  22.     response = ""
  23.     while response == "" do
  24.         http.request(url)
  25.         event, returnurl, response = os.pullEvent("http_success")
  26.         response = response.readAll()
  27.     end
  28.     return response
  29. end
  30.  
  31. while true do
  32.     print("Orders:")
  33.     command = io.read()
  34.     if command == "help" then
  35.         print("store <item> <qty>")
  36.         print("get <item> <qty>")
  37.         print("charge <item>")
  38.     else
  39.         set("action", command)
  40.         while true do
  41.             sleep(0.5)
  42.             answer = get("return")
  43.             if answer == "nil" then
  44.                 sleep(1)
  45.             else
  46.                 print(tostring(answer))
  47.                 set("return", "nil")
  48.                 break
  49.             end
  50.         end
  51.     end
  52. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement