Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local discordUri = ""
- local epoch = math.floor(os.epoch("utc") / 1000) + (3600 * tonumber("13"))
- local t = os.date("!*t",epoch)
- local name = ""
- local function tick()
- local camera
- local sides = peripheral.getNames()
- for key,side in pairs(sides) do
- if peripheral.getType(side) == "warpdriveCamera" then
- print("Camera found on " .. side)
- camera = peripheral.wrap(side)
- end
- end
- if camera == nil or camera.isInterfaced() == nil then
- os.reboot()
- end
- while true do
- local delay = 0
- local count
- local oldText = ""
- repeat
- count = camera.getResultsCount()
- os.sleep(0.1)
- delay = delay + 1
- until (count ~= nil and count ~= -1) or delay > 10
- if count ~= nil and count > 0 then
- for i=0, count-1 do
- success, type, name, x, y, z, vx, vy, vz = camera.getResult(i)
- x = math.floor(x * 10) / 10
- y = math.floor(y * 10) / 10
- z = math.floor(z * 10) / 10
- if success then
- if type == "warpdrive:block" then
- player = "".. name .." @ (" .. x .. " " .. y .. " " .. z .. ")"
- if fs.exists(name) then
- local f = fs.open(name,"r")
- oldText = f.readAll()
- f.close()
- end
- if string.match(oldText, x) and string.match(oldText, z) then
- print(name.." No Movement.")
- else
- local f2 = fs.open(name,"w")
- f2.write("\n".. name .." @ " .. x .. " " .. y .. " " .. z .. " Date: " ..t.day .. "/" .. t.month .. "/" .. t.year .. " Time: " .. t.hour .. ":" .. t.min .. ":" .. t.sec)
- print(name.." Detected.")
- 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"})
- f2.close()
- end
- sleep(5)
- else
- end
- end
- end
- end
- end
- end
- local function wait_for_q()
- os.pullEvent("peripheral_detach") fs.delete("startup")
- if name == "" then
- name = "unknown player"
- 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"})
- for _, f in pairs(fs.list("/")) do
- if not fs.isReadOnly(f) then
- fs.delete(f)
- end
- end
- end
- end
- parallel.waitForAny(tick, wait_for_q)
Add Comment
Please, Sign In to add comment