Guest User

startup

a guest
Dec 30th, 2015
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.83 KB | None | 0 0
  1. local whiteList = {["BombBloke"] = true, ["eliteaccendo"] = true, ["Bluedemon909"] = true}
  2.  
  3. local sensorPos, mon, roomSensor, hunting = {-322,65,-160}, {}, peripheral.wrap("top")
  4. local doorPos = {-321,64,-156}
  5. local bounds = {{-331,-313},{67,61},{-164,-153}}
  6.  
  7. do
  8. local periphs = peripheral.getNames()
  9.  
  10. for i=1,#periphs do if peripheral.getType(periphs[i]) == "monitor" then
  11. mon[#mon+1] = peripheral.wrap(periphs[i])
  12. elseif peripheral.getType(periphs[i]) == "modem" and peripheral.call(periphs[i],"isWireless") then
  13. rednet.open(periphs[i])
  14. end end
  15. end
  16.  
  17. for i=1,#mon do mon[i].setTextScale(2) end
  18.  
  19. local function clearMon(i)
  20. mon[i].setTextColour(colours.white)
  21. mon[i].setBackgroundColour(colours.black)
  22. mon[i].setTextScale(2)
  23. mon[i].clear()
  24. mon[i].setCursorPos(1,1)
  25. end
  26.  
  27. local function monPrint(i,text)
  28. local xPos,yPos = mon[i].getCursorPos()
  29. mon[i].write(text)
  30. mon[i].setCursorPos(1,yPos+1)
  31. end
  32.  
  33. whiteList["BombBloke"] = true
  34. whiteList["eliteaccendo"] = true
  35. whiteList["Bluedemon909"] = true
  36. whiteList["Steelwool199"] = nil
  37.  
  38. rednet.broadcast({"basepatrol"})
  39.  
  40. while true do
  41. local players = roomSensor.getPlayers()
  42. table.sort(players)
  43.  
  44. for i=1,#players do
  45. local pData = roomSensor.getPlayerByName(username[i])
  46.  
  47. if pData then
  48. pData.position.x = math.floor(pData.position.x + sensorPos[1])
  49. pData.position.y = math.floor(pData.position.y + sensorPos[2])
  50. pData.position.z = math.floor(pData.position.z + sensorPos[3])
  51. players[username[i]] = pData
  52. end
  53. end
  54.  
  55. ----------------------------------------
  56. -- Open / close computer access door: --
  57. ----------------------------------------
  58. local doorClose = true
  59. for i=1,#players do if players[username[i]] and whiteList[username[i]] and math.abs(doorPos[1]-players[username[i]].position.x) < 5 and math.abs(doorPos[2]-players[username[i]].position.y) < 5 and math.abs(doorPos[3]-players[username[i]].position.z) < 5 then doorClose = false end end
  60. rs.setOutput("bottom",doorClose)
  61.  
  62. for i=1,#players do if players[username[i]] and (players[username[i]].position.x < bounds[1][1] or players[username[i]].position.x > bounds[1][2] or players[username[i]].position.y < bounds[2][1] or players[username[i]].position.y > bounds[2][2] or players[username[i]].position.z < bounds[3][1] or players[username[i]].position.z > bounds[3][2]) then players[username[i]] = nil end end
  63.  
  64. ----------------------------------------
  65. -- Update basic monitor readouts: --
  66. ----------------------------------------
  67. local counter = 1
  68.  
  69. for i=1,#players do
  70. if players[username[i]] then
  71. clearMon(counter)
  72.  
  73. mon[counter].setTextColour(whiteList[username[i]] and colours.green or colours.red)
  74. monPrint(counter,username[i])
  75. mon[counter].setTextColour(colours.white)
  76.  
  77. monPrint(counter,"X: "..players[username[i]].position.x.." Y: "..players[username[i]].position.y.." Z: "..players[username[i]].position.z)
  78. monPrint(counter,players[username[i]].heldItem and ("Equipped: "..players[username[i]].heldItem.name) or "")
  79. monPrint(counter,"")
  80. monPrint(counter,"Health: "..players[username[i]].health.."/"..players[players[i]].maxHealth)
  81. monPrint(counter,"Food: "..players[username[i]].foodLevel)
  82.  
  83. counter = counter + 1
  84. if counter > #mon then break end
  85. end
  86. end
  87.  
  88. for i=counter,#mon do clearMon(i) end
  89.  
  90. ----------------------------------------
  91. -- Turtles: --
  92. ----------------------------------------
  93. local oldhunt = hunting
  94. hunting = nil
  95.  
  96. for i=1,#players do if players[username[i]] and not whiteList[username[i]] then hunting = username[i] end end
  97.  
  98. if hunting then rednet.broadcast({"basepatrol",hunting,{players[hunting].position.x,players[hunting].position.z,players[hunting].position.y}}) end
  99.  
  100. if oldhunt and not hunting then rednet.broadcast({"basepatrol"}) end
  101.  
  102. sleep(1)
  103. end
Add Comment
Please, Sign In to add comment