View difference between Paste ID: SvqjqZBh and EiQshFuK
SHOW: | | - or go back to the newest paste.
1-
-- Libraries
1+
-- Libraries
2-
local component = require("component")
2+
local component = require("component")
3-
3+
4-
local internet = require("internet")
4+
local internet = require("internet")
5-
5+
6-
-- Get Addresses
6+
-- Get Addresses
7-
local names = component.list()
7+
local names = component.list()
8-
8+
9-
9+
10-
-- Get Invent Controllers
10+
-- Get Invent Controllers
11-
local invents = {}
11+
local invents = {}
12-
local count = 0
12+
local count = 0
13-
13+
14-
for i in names do
14+
for i in names do
15-
  if component.type(i) == "inventory_controller" then
15+
  if component.type(i) == "inventory_controller" then
16-
16+
17-
    -- Make key and value
17+
    -- Make key and value
18-
    key = "Inv" .. count
18+
    key = "Inv" .. count
19-
    value = i
19+
    value = i
20-
    
20+
    
21-
    -- Key and value export
21+
    -- Key and value export
22-
    invents[key] = value
22+
    invents[key] = value
23-
    
23+
    
24-
    -- Debug
24+
    -- Debug
25-
    --print(key .. " = " .. value)
25+
    --print(key .. " = " .. value)
26-
    
26+
    
27-
    -- Update count
27+
    -- Update count
28-
    count = count + 1
28+
    count = count + 1
29-
  end
29+
  end
30
end
31-
31+
32-
-- Grab size
32+
-- Grab size
33-
local itemCount = ""
33+
local itemCount = ""
34-
local itemName = ""
34+
local itemName = ""
35-
local dataArray = {}
35+
local dataArray = {}
36-
local port = 1001
36+
local port = 1001
37-
local a = ""
37+
local a = ""
38-
local b = ""
38+
local b = ""
39-
39+
40-
for k,v in pairs(invents) do
40+
for k,v in pairs(invents) do
41-
  
41+
  
42-
  controller = component.proxy(v)
42+
  controller = component.proxy(v)
43-
43+
44-
  data = controller.getStackInSlot(3, 1)
44+
  data = controller.getStackInSlot(3, 1)
45-
45+
46-
  for key,value in pairs(data) do
46+
  for key,value in pairs(data) do
47-
    
47+
    
48-
    if key == "name" then
48+
    if key == "name" then
49-
      itemName = value
49+
      itemName = value
50-
      a,b = string.match(itemName, '(.*):(.*)')
50+
      a,b = string.match(itemName, '(.*):(.*)')
51-
      itemName = b
51+
      itemName = b
52-
      
52+
      
53-
    end
53+
    end
54-
54+
55-
    if key == "size" then
55+
    if key == "size" then
56-
      itemCount = value
56+
      itemCount = value
57-
      
57+
      
58-
    end
58+
    end
59-
    
59+
    
60-
    if itemCount ~= "" and itemName ~= "" then
60+
    if itemCount ~= "" and itemName ~= "" then
61-
      stringSend = "https://stark-stream-56750.herokuapp.com/update?" .. itemName .. "=" .. math.floor(itemCount) .. "#"
61+
      stringSend = "http://86.7.146.45:4920/update?" .. itemName .. "=" .. math.floor(itemCount) .. "#"
62-
      
62+
      
63-
      -- Print and Send
63+
      -- Print and Send
64-
      print(stringSend)
64+
      print(stringSend)
65-
      if pcall(internet.request(stringSend)) then
65+
66-
        print("all good")
66+
	  if pcall(internet.request(stringSend)) then
67-
      else
67+
		print("all epic")
68-
        print("not good")
68+
	  else
69-
      end
69+
		print("oh no")
70-
      
70+
	  end
71-
      
71+
      os.sleep(0.5)
72-
72+
	  os.sleep(0.5)      
73-
      -- Reset
73+
      
74-
      itemName = ""
74+
75-
      itemCount = ""
75+
      -- Reset
76-
    end
76+
      itemName = ""
77-
77+
      itemCount = ""
78-
  end
78+
    end
79
80
  end
81
end