Advertisement
natie3

RadarServer

Nov 24th, 2019
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.38 KB | None | 0 0
  1. radar = peripheral.wrap("bottom")
  2. chat = peripheral.wrap("top")
  3. modem = peripheral.wrap("right")
  4.  
  5. areas = {
  6.   { 11, 21, 6, 6, 0, 5, "secret" },
  7.   { 6, 13, 0, 3, -18, -14, "spawner" },
  8.   { -7, 6, 6, 12, -26, -19, "machine_room" },
  9.   { -3, 3, 13, 13, 34, 37, "flight_door" },
  10.   { 10, 15, 6, 6, -10, 0, "nether_portal" }
  11. }
  12.  
  13. function within(value, first, second)
  14.   return first <= value and value <= second
  15. end
  16.  
  17. function getArea(player)
  18.   for i, area in pairs(areas) do
  19.     if within(player.x, area[1], area[2]) and within(player.y, area[3], area[4]) and within(player.z, area[5], area[6]) then
  20.       return area[7]
  21.     end
  22.   end
  23.  
  24.   return ""
  25. end
  26.  
  27. while true do
  28.   _, user, command = os.pullEvent("command")
  29.   players = radar.getPlayers()
  30.   for index, player in pairs(players) do
  31.     print(player.name)
  32.     if player.name == "HosterCEO" and command[1] == "martijn" then
  33.       chat.tell(user, player.x .. " " .. player.y .. " " .. player.z)
  34.     end
  35.     if player.name == user then
  36.       if command[1] == "pos" then
  37.         chat.tell(user, player.x .. " " .. player.y .. " " .. player.z)
  38.       elseif command[1] == "open" or command[1] == "close" then
  39.          local area = getArea(player)
  40.          if area ~= "" then
  41.            modem.transmit(5,6, area .. "_" .. command[1])
  42.          end
  43.          --chat.tell(user, "area: " .. getArea(player))
  44.       end
  45.     end
  46.   end
  47. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement