Advertisement
Forgotten_Boy

cx4 - ComputerCraft Cloud Chest

Jul 4th, 2015
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function Chest(chest)
  2.     chestID = chest
  3. end
  4.  
  5. function Target(chest)
  6.     if (not chestID) then
  7.         error("A Cloud Chest has not been specified yet.  First call Chest(id) where the id is your cx4 Chest key.")
  8.     end
  9.     return chestID
  10. end
  11.  
  12. function Set(location, data)
  13.     if (not chestID) then
  14.         error("A Cloud Chest has not been specified yet.  First call Chest(id) where the id is your cx4 Chest key.")
  15.     end
  16.     url = "http://boomtree.com/guid/" .. chestID .. ".cc?location=" .. location
  17.     local ret = http.post(url, data)
  18.     print(ret.readAll())
  19. end
  20.  
  21. function Get(location)
  22.     url = "http://boomtree.com/guid/" .. chestID .. ".cc?location="..location
  23.     loop = true
  24.     http.request(url)
  25.  
  26.     event, returnurl, response = os.pullEvent()
  27.     while loop == true do
  28.         if event == "http_success" then
  29.             return response.readAll()
  30.         else
  31.             print("The request failed.")
  32.             return
  33.         end
  34.     end
  35. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement