Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local whiteList = {["BombBloke"] = true, ["eliteaccendo"] = true, ["Bluedemon909"] = true}
- local sensorPos, mon, roomSensor, hunting = {-332,76,-841}, {}
- local doorPos = {-320,78,-830}
- local bounds = {{-349,-321},{78,84},{-864,-817}}
- do
- local periphs = peripheral.getNames()
- for i=1,#periphs do if peripheral.getType(periphs[i]) == "monitor" then
- mon[#mon+1] = peripheral.wrap(periphs[i])
- elseif peripheral.getType(periphs[i]) == "openperipheral_sensor" then
- roomSensor = peripheral.wrap(periphs[i])
- elseif peripheral.getType(periphs[i]) == "modem" and peripheral.call(periphs[i],"isWireless") then
- rednet.open(periphs[i])
- end end
- end
- for i=1,3 do mon[i].setTextScale(2) end
- local function clearMon(i)
- mon[i].setTextColour(colours.white)
- mon[i].setBackgroundColour(colours.black)
- mon[i].setTextScale(2)
- mon[i].clear()
- mon[i].setCursorPos(1,1)
- end
- local function monPrint(i,text)
- local xPos,yPos = mon[i].getCursorPos()
- mon[i].write(text)
- mon[i].setCursorPos(1,yPos+1)
- end
- whiteList["BombBloke"] = true
- whiteList["eliteaccendo"] = true
- whiteList["Bluedemon909"] = true
- whiteList["Steelwool199"] = nil
- rednet.broadcast({"basepatrol"})
- while true do
- local players = roomSensor.getPlayerNames()
- table.sort(players)
- for i=1,#players do
- local pData = roomSensor.getPlayerData(players[i])
- if pData then
- pData.position.x = math.floor(pData.position.x + sensorPos[1])
- pData.position.y = math.floor(pData.position.y + sensorPos[2])
- pData.position.z = math.floor(pData.position.z + sensorPos[3])
- players[players[i]] = pData
- end
- end
- ----------------------------------------
- -- Open / close computer access door: --
- ----------------------------------------
- local doorClose = true
- for i=1,#players do if players[players[i]] and whiteList[players[i]] and math.abs(doorPos[1]-players[players[i]].position.x) < 5 and math.abs(doorPos[2]-players[players[i]].position.y) < 5 and math.abs(doorPos[3]-players[players[i]].position.z) < 5 then doorClose = false end end
- rs.setOutput("left",doorClose)
- for i=1,#players do if players[players[i]] and (players[players[i]].position.x < bounds[1][1] or players[players[i]].position.x > bounds[1][2] or players[players[i]].position.y < bounds[2][1] or players[players[i]].position.y > bounds[2][2] or players[players[i]].position.z < bounds[3][1] or players[players[i]].position.z > bounds[3][2]) then players[players[i]] = nil end end
- ----------------------------------------
- -- Update basic monitor readouts: --
- ----------------------------------------
- local counter = 1
- for i=1,#players do
- if players[players[i]] then
- clearMon(counter)
- mon[counter].setTextColour(whiteList[players[i]] and colours.green or colours.red)
- monPrint(counter,players[i])
- mon[counter].setTextColour(colours.white)
- monPrint(counter,"X: "..players[players[i]].position.x.." Y: "..players[players[i]].position.y.." Z: "..players[players[i]].position.z)
- monPrint(counter,players[players[i]].heldItem and ("Equipped: "..players[players[i]].heldItem.name) or "")
- monPrint(counter,"")
- monPrint(counter,"Health: "..players[players[i]].health.."/"..players[players[i]].maxHealth)
- monPrint(counter,"Food: "..players[players[i]].foodLevel)
- counter = counter + 1
- if counter > #mon then break end
- end
- end
- for i=counter,#mon do clearMon(i) end
- ----------------------------------------
- -- Turtles: --
- ----------------------------------------
- local oldhunt = hunting
- hunting = nil
- for i=1,#players do if players[players[i]] and not whiteList[players[i]] then hunting = players[i] end end
- if hunting then rednet.broadcast({"basepatrol",hunting,{players[hunting].position.x,players[hunting].position.z,players[hunting].position.y}}) end
- if oldhunt and not hunting then rednet.broadcast({"basepatrol"}) end
- sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement