Advertisement
Guest User

Untitled

a guest
Apr 8th, 2020
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.66 KB | None | 0 0
  1. local component = require("component")
  2. local side = require("sides")
  3. local rs = component.block_refinedstorage_interface
  4. local internet = require("internet")
  5.  
  6. local itemList = rs.getItems()
  7. local patternList = rs.getPatterns()
  8. local fluidList = rs.getFluids()
  9. local currentTasks = rs.getTasks()
  10.  
  11.  
  12.  
  13. function split(string, delim)
  14.     local result = {};
  15.     for match in (string..delim):gmatch("(.-)"..delim) do
  16.         table.insert(result,match)
  17.     end
  18.     return result;
  19. end
  20.  
  21. --Post Data to Web API
  22. function postWeb(data,url)
  23.     local handle = internet.request(url, "
  24.    {
  25.        "name" : data.name,
  26.        "size" : data.size,
  27.        "mod"  : data.mod,
  28.        "description" : data.summary
  29.    }", {}, "POST")
  30.     local result = ""
  31.     for chunk in handle do result = result..chunk end
  32.     -- Print the body of the HTTP response
  33.     -- print(result)
  34.  
  35.     -- Grab the metatable for the handle. This contains the
  36.     -- internal HTTPRequest object.end
  37.     local mt = getmetatable(handle)
  38.  
  39. end
  40.  
  41.  
  42. --Get Data From Web API
  43. function getWeb(data,url)
  44.     local handle = internet.request(url, "", {}, "GET")
  45.     local result = ""
  46.     for chunk in handle do result = result..chunk end
  47.  
  48.     local mt = getmetatable(handle)
  49. end
  50.  
  51.  
  52.  
  53.  
  54. function postItems(rsItems)
  55.     local table = {}
  56.     for k,v in ipairs(rsItems) do
  57.         table[1] = v.name
  58.         table[2] = v.size
  59.         table[3] = "Hello Word"
  60.         table[4] = split(v.name)
  61.     end
  62.  
  63.     return table
  64. end
  65.    
  66.  
  67.  
  68. --Call Functions Here
  69. --(Main Function Area)
  70.  
  71. --Post new data to web API
  72. local result = postItems(itemList)
  73. sendToWeb(result,"https://seanwdoran.tech/api/create")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement