Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function tlen(tabl)
- local count = 0
- for _ in pairs(tabl) do
- count = count+1
- end
- return count
- end
- function getEnts(tabl)
- entArr = {}
- for i,v in pairs(tabl) do
- ent = string.sub(i,0,3)
- if ent ~= "Cow" and ent ~= "Bat" and ent ~= "Ske" and ent ~= "Cre" and ent ~= "Zom" and ent ~= "Sli" and ent ~= "Spi" and ent ~= "End" then
- table.insert(entArr, i)
- end
- end
- return entArr
- end
- function getXYZ(tabl, entName)
- retXYZ = {}
- retXYZ["x"] = math.floor(tabl[entName]["Position"]["X"])
- retXYZ["y"] = math.floor(tabl[entName]["Position"]["Y"])
- retXYZ["z"] = math.floor(tabl[entName]["Position"]["Z"])
- return retXYZ
- end
- function colorOn(col, side)
- rs.setBundledOutput(side, colors.combine(rs.getBundledOutput(side),col))
- end
- function colorOff(col, side)
- rs.setBundledOutput(side, colors.subtract(rs.getBundledOutput(side),col))
- end
- monitor = peripheral.wrap("top")
- monitor.clear()
- monitor.setCursorPos(1,1)
- monitor.setTextScale(1)
- os.loadAPI("ocs/apis/sensor")
- mySensor = sensor.wrap("right")
- alarmIsOn = false
- while true do
- --if true then
- tgts = mySensor.getTargets()
- ents = getEnts(tgts)
- maxX, maxY = monitor.getSize()
- currentY = 1
- monitor.clear()
- for pos = 1, #ents do
- monitor.setCursorPos(1, currentY)
- entXYZ = getXYZ(tgts, ents[pos])
- monitor.write(ents[pos].." X: "..entXYZ["x"].." Y: "..entXYZ["y"].." Z: "..entXYZ["z"])
- currentY = currentY+1
- end
- if #ents == 1 and tgts["arbarr3"] then
- ownerPos = getXYZ(tgts, "arbarr3")
- local ownerX = ownerPos["x"]
- local ownerY = ownerPos["y"]
- local ownerZ = ownerPos["z"]
- if (ownerX >= -2 and ownerX <= 0) and (ownerY == -2 or ownerY == -3) and (ownerZ >= -1 and ownerZ <= 1) then
- if redstone.getBundledOutput("back") ~= colors.white then
- colorOn(colors.white, "back")
- end
- else
- if redstone.getBundledOutput("back") == colors.white then
- colorOff(colors.white, "back")
- end
- end
- colorOff(colors.red, "back")
- alarmIsOn = false
- elseif #ents > 0 then
- monitor.setCursorPos(1, maxY)
- monitor.setTextColor(colors.red)
- monitor.write("You are in arbarr3's house. Please leave.")
- monitor.setTextColor(colors.white)
- alarmIsOn = true
- colorOn(colors.red, "back")
- else
- colorOff(colors.red, "back")
- end
- end
- print(textutils.serialize(mySensor.getTargets()))
Advertisement
Add Comment
Please, Sign In to add comment