Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- radar = peripheral.wrap("bottom")
- chat = peripheral.wrap("top")
- modem = peripheral.wrap("right")
- areas = {
- { 11, 21, 6, 6, 0, 5, "secret" },
- { 6, 13, 0, 3, -18, -14, "spawner" },
- { -7, 6, 6, 12, -26, -19, "machine_room" },
- { -3, 3, 13, 13, 34, 37, "flight_door" },
- { 10, 15, 6, 6, -10, 0, "nether_portal" }
- }
- function within(value, first, second)
- return first <= value and value <= second
- end
- function getArea(player)
- for i, area in pairs(areas) do
- 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
- return area[7]
- end
- end
- return ""
- end
- while true do
- _, user, command = os.pullEvent("command")
- players = radar.getPlayers()
- for index, player in pairs(players) do
- print(player.name)
- if player.name == "HosterCEO" and command[1] == "martijn" then
- chat.tell(user, player.x .. " " .. player.y .. " " .. player.z)
- end
- if player.name == user then
- if command[1] == "pos" then
- chat.tell(user, player.x .. " " .. player.y .. " " .. player.z)
- elseif command[1] == "open" or command[1] == "close" then
- local area = getArea(player)
- if area ~= "" then
- modem.transmit(5,6, area .. "_" .. command[1])
- end
- --chat.tell(user, "area: " .. getArea(player))
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement