SHOW:
|
|
- or go back to the newest paste.
1 | local discordUri = "" | |
2 | local epoch = math.floor(os.epoch("utc") / 1000) + (3600 * tonumber("13")) | |
3 | local t = os.date("!*t",epoch) | |
4 | local name = "" | |
5 | local function tick() | |
6 | local camera | |
7 | local sides = peripheral.getNames() | |
8 | ||
9 | for key,side in pairs(sides) do | |
10 | if peripheral.getType(side) == "warpdriveCamera" then | |
11 | print("Camera found on " .. side) | |
12 | camera = peripheral.wrap(side) | |
13 | end | |
14 | end | |
15 | if camera == nil or camera.isInterfaced() == nil then | |
16 | os.reboot() | |
17 | end | |
18 | ||
19 | while true do | |
20 | ||
21 | local delay = 0 | |
22 | local count | |
23 | local oldText = "" | |
24 | repeat | |
25 | count = camera.getResultsCount() | |
26 | os.sleep(0.1) | |
27 | delay = delay + 1 | |
28 | until (count ~= nil and count ~= -1) or delay > 10 | |
29 | ||
30 | if count ~= nil and count > 0 then | |
31 | for i=0, count-1 do | |
32 | success, type, name, x, y, z, vx, vy, vz = camera.getResult(i) | |
33 | x = math.floor(x * 10) / 10 | |
34 | y = math.floor(y * 10) / 10 | |
35 | z = math.floor(z * 10) / 10 | |
36 | if success then | |
37 | - | if type == "warpdrive:block" then |
37 | + | if type == "minecraft:player" then |
38 | player = "".. name .." @ (" .. x .. " " .. y .. " " .. z .. ")" | |
39 | if fs.exists(name) then | |
40 | local f = fs.open(name,"r") | |
41 | oldText = f.readAll() | |
42 | f.close() | |
43 | end | |
44 | if string.match(oldText, x) and string.match(oldText, z) then | |
45 | print(name.." No Movement.") | |
46 | ||
47 | else | |
48 | local f2 = fs.open(name,"w") | |
49 | f2.write("\n".. name .." @ " .. x .. " " .. y .. " " .. z .. " Date: " ..t.day .. "/" .. t.month .. "/" .. t.year .. " Time: " .. t.hour .. ":" .. t.min .. ":" .. t.sec) | |
50 | - | print(name.." Detected.") |
50 | + | print(name.." Has Been Detected.") |
51 | - | http.post(discordUri, "{\"content\":\""..name.." has been detected. Date: " ..t.day .. "/" .. t.month .. "/" .. t.year .. " Time: " .. t.hour .. ":" .. t.min .. ":" .. t.sec.."\"}",{['content-type']="application/json"}) |
51 | + | http.post(discordUri, "{\"content\":\""..name.." has been detected @ " .. x .. " " .. y .. " " .. z .. " Date: " ..t.day .. "/" .. t.month .. "/" .. t.year .. " Time: " .. t.hour .. ":" .. t.min .. ":" .. t.sec.."\"}",{['content-type']="application/json"}) |
52 | f2.close() | |
53 | end | |
54 | sleep(5) | |
55 | else | |
56 | end | |
57 | end | |
58 | end | |
59 | end | |
60 | end | |
61 | end | |
62 | local function wait_for_q() | |
63 | os.pullEvent("peripheral_detach") fs.delete("startup") | |
64 | if name == "" then | |
65 | name = "unknown player" | |
66 | http.post(discordUri, "{\"content\":\""..name.." Attempted to access computer Date: " ..t.day .. "/" .. t.month .. "/" .. t.year .. " Time: " .. t.hour .. ":" .. t.min .. ":" .. t.sec.."\"}",{['content-type']="application/json"}) | |
67 | for _, f in pairs(fs.list("/")) do | |
68 | if not fs.isReadOnly(f) then | |
69 | fs.delete(f) | |
70 | end | |
71 | end | |
72 | end | |
73 | end | |
74 | parallel.waitForAny(tick, wait_for_q) |