SHOW:
|
|
- or go back to the newest paste.
1 | - | local inet = require("internet") |
1 | + | local inet = require("internet") |
2 | - | |
2 | + | |
3 | - | --make a request to the API server |
3 | + | --make a request to the API server |
4 | - | local req = inet.request("https://api.mcsrvstat.us/1/TheGeekShackATM3Remix.nn.pe") |
4 | + | local req = inet.request("https://api.mcsrvstat.us/1/TheGeekShackATM3Remix.nn.pe") |
5 | - | |
5 | + | |
6 | - | --some variables to fill, we really only need testout and resp |
6 | + | --some variables to fill, we really only need testout and resp |
7 | - | local resp = "" |
7 | + | local resp = "" |
8 | - | local newtest = 0 |
8 | + | local newtest = 0 |
9 | - | |
9 | + | |
10 | - | --for each line in request response. append to a text line |
10 | + | --for each line in request response. append to a text line |
11 | - | for line in req do |
11 | + | for line in req do |
12 | - | resp = resp .. line .. "\n" |
12 | + | resp = resp .. line .. "\n" |
13 | end | |
14 | - | |
14 | + | |
15 | - | |
15 | + | |
16 | - | --get a substring, from response, starting at where online occurs +7, and finishing 2 characters later |
16 | + | --get a substring, from response, starting at where online occurs +7, and finishing 2 characters later |
17 | - | --testout = string.sub(resp,string.find(resp,"online")+7,string.find(resp,"online")+9) |
17 | + | --testout = string.sub(resp,string.find(resp,"online")+7,string.find(resp,"online")+9) |
18 | - | |
18 | + | |
19 | - | |
19 | + | |
20 | - | newtest = string.match(resp,"online..(%d)") |
20 | + | newtest = string.match(resp,"online..(%d)") |
21 | - | |
21 | + | |
22 | - | |
22 | + | |
23 | - | --this is the full text.. spammy |
23 | + | --this is the full text.. spammy |
24 | - | --print(resp) |
24 | + | --print(resp) |
25 | - | |
25 | + | |
26 | - | --print("online count" .. testout) |
26 | + | --print("online count" .. testout) |
27 | - | print("Online Count: " .. newtest) |
27 | + | print("Online Count: " .. newtest) |
28 | - | --convert to number |
28 | + | --convert to number |
29 | - | newtest = tonumber(newtest) |
29 | + | newtest = tonumber(newtest) |
30 | - | |
30 | + | |
31 | - | --test logic for machine on/off |
31 | + | --test logic for machine on/off |
32 | - | if newtest <= 3 then |
32 | + | if newtest <= 3 then |
33 | - | print("not many players on, LAG THE FUCKERS!") |
33 | + | print("not many players on, LAG THE FUCKERS!") |
34 | - | else |
34 | + | else |
35 | - | print("better be nice") |
35 | + | print("better be nice") |
36 | end |