Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PLAYER_DETECTOR_SIDE = "RIGHT"
- CHAT_BOX_SIDE = "LEFT"
- INCIDENT_DIMENSION = "minecraft:overworld"
- INCIDENT_POS = {x=0, y=0, z=0}
- INCIDENT_RADIUS = 10
- function euclideanDistance(pos1, pos2)
- return math.sqrt((pos2.x - pos1.x)^2 + (pos2.y - pos1.y)^2 + (pos2.z - pos1.z)^2)
- end
- playerDetector = peripheral.wrap(PLAYER_DETECTOR_SIDE)
- chatBox = peripheral.wrap(CHAT_BOX_SIDE)
- if playerDetector == nil or chatBox == nil then
- error('ERROR - Invalid peripheral sides.')
- end
- while(true)
- do
- onlinePlayers = playerDetector.getOnlinePlayers()
- for playerIndex = 1, #onlinePlayers do
- local playerName = onlinePlayers[playerIndex]
- local playerPos = playerDetector.getPlayerPos(playerName)
- if playerPos ~= nil and playerPos.dimension == INCIDENT_DIMENSION then
- if euclideanDistance(playerPos, INCIDENT_POS) <= INCIDENT_RADIUS then
- chatBox.sendMessageToPlayer("You are now entering a radiation area. Please put on a Hazmat suit.", playerName, "WARNING")
- end
- end
- end
- sleep(5)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement