Advertisement
Guest User

ConstellationsDB count quarry output

a guest
Feb 1st, 2022
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.87 KB | None | 0 0
  1. namespace = ""
  2. write_key = ""
  3. input_direction = "left"
  4. output_direction = "right"
  5.  
  6. chest_a = peripheral.wrap("left")
  7.  
  8. local char_to_hex = function(c)
  9.     return string.format("%%%02X", string.byte(c))
  10. end
  11.  
  12. function urlencode(url)
  13.     if url == nil then
  14.       return
  15.     end
  16.     url = url:gsub("\n", "\r\n")
  17.     url = url:gsub("([^%w ])", char_to_hex)
  18.     url = url:gsub(" ", "+")
  19.     return url
  20. end
  21.  
  22. while 1 do
  23.     for slot, item in pairs(chest_a.list()) do
  24.         print(("%d x %s in slot %d"):format(item.count, item.name, slot))
  25.         chest_a.pushItems(output_direction, slot)
  26.  
  27.         log = urlencode("Found " .. item.count .. " blocks of " .. item.name)
  28.  
  29.         http.request("https://api.constellations.tech/v2/" .. namespace .. "?key=" .. write_key .. "&tag=" .. item.name .. "&value=" .. item.count .. "&log=" .. log)
  30.     end
  31.     os.sleep(10)
  32. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement