Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if component.isAvailable("internet") then
- os.execute(pastebin get -f 3wMMSbNv pass.lua)
- end
- local tArgs ={...}
- local nologArg =tArgs[1]
- local component = require("component")
- local term = require("term")
- local computer = require("computer")
- local event = require("event")
- local sides = require("sides")
- local gpu = component.gpu
- title = "<|MCEMA|>"
- local colors = { blue = 0x4286F4, purple = 0xB673d6, red = 0xC14141, green = 0xDA841, black = 0x000000, white = 0xFFFFFF, grey = 0x47494C, lightGrey = 0xBBBBBB}
- local rs = component.redstone
- local cb = computer.beep
- local dist = 3
- local pt = 0
- local t = computer.uptime
- local sensors = {}
- local allowedPlayers = {"tomte55", "FisKtryne"}
- local mobs = {"Zombie", "Spider", "Creeper", "Skeleton", "Skeleton Horse", "Ancient Golem", "Enderman", "Bliss", "Bat", "Cow", "Pig", "Sheep", "Wolf", "Chicken"}
- local mobs_checked = {}
- local passing = "NULL"
- local line_string = "----------------------------------------------------------------------------------------------------------------------------------------------------------------"
- local count = 1
- local opened = 0
- local logged = 0
- local time = os.time()*1000/60/60-6000
- local day = time/24000
- local door = 0
- local x, y = gpu.maxResolution()
- if x > 80 then
- if y > 25 then
- gpu.setResolution(80, 25)
- end
- end
- local w, h = gpu.getResolution()
- if gpu.getDepth() > 1 then
- color = true
- end
- if color then
- gpu.setBackground(colors.grey)
- end
- function line()
- if color then
- gpu.setForeground(colors.blue)
- end
- print(string.sub(line_string, 1, w))
- if color then
- gpu.setForeground(colors.white)
- end
- end
- function bind_sensors()
- sensors = {}
- count = 1
- for address, _ in component.list("motion") do
- table.insert(sensors, address)
- address = string.sub(address, 1, 8)
- sensor = "Sensor " .. count .. " - " .. address
- term.setCursor(math.floor(w/2-string.len(tostring(sensor))/2+1), count+1)
- print(sensor)
- count = count+1
- end
- if #sensors == 0 then
- count = 2
- term.setCursor(math.floor(w/2-string.len("Error no sensors")/2+1), 2)
- if color then
- gpu.setForeground(colors.red)
- end
- term.write("Error no sensors")
- if color then
- gpu.setForeground(colors.white)
- end
- end
- term.setCursor(1, 1)
- line()
- term.setCursor(math.floor(w/2-string.len(title)/2+1), 1)
- if color then
- gpu.setForeground(colors.red)
- end
- print(title)
- if color then
- gpu.setForeground(colors.green)
- end
- term.setCursor(1, count+1)
- line()
- term.setCursor(1, count+2)
- end
- function detect()
- term.write("")
- local _,address,xdist,_,ydist,name = term.pull("motion")
- door = 0
- if xdist < dist and xdist > -dist and ydist > -dist and ydist < dist then
- for i=1, #sensors do
- door = door + 1
- if address == sensors[i] then
- passing = name
- log()
- for j=1, #allowedPlayers do
- if name == allowedPlayers[j] then
- open()
- end
- end
- end
- end
- end
- end
- function log()
- if passing ~= nologArg then
- for i=1, #mobs do
- if passing ~= mobs[i] then
- table.insert(mobs_checked, passing)
- end
- end
- if #mobs_checked == #mobs then
- mobs_checked = {}
- logged = logged + 1
- if opened < 1 then
- line()
- end
- log_text = "User: " .. passing .. " | " .. "Time: " .. os.date("%I:%M %p") .. " | " .. "Day: " .. math.floor(day)
- local x, y = term.getCursor()
- term.setCursor(math.floor(w/2-string.len(tostring(log_text))/2+1), y)
- print(log_text)
- line()
- opened = opened + 1
- end
- end
- end
- function open()
- rs.setOutput(sides.top, 15)
- os.sleep(2)
- rs.setOutput(sides.top, 0)
- end
- term.clear()
- bind_sensors()
- while true do
- detect()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement