Created
June 2, 2017 14:54
-
-
Save revodavid/feab4dd718124caede88f147e5e8ffa4 to your computer and use it in GitHub Desktop.
Function to detect when a Minecraft player is standing in a hole. (Required miner package.)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| findMyId <- function() { | |
| # Requires https://github.com/ROpenSciLabs/miner | |
| # dig a hole one block deep and stand in it to be found | |
| # returns the IDs of players standing in a hole | |
| ids <- getPlayerIds() | |
| holehiders <- NULL | |
| for (id in ids) { | |
| pos <- getPlayerPos(id, tile=TRUE) | |
| surround <- getBlocks(pos[1]-1,pos[2],pos[3]-1, pos[1]+1, pos[2], pos[3]+1)[,1,] | |
| inhole <- all(c(surround[1,2],surround[2,1],surround[2,3], surround[3,2])!=0) | |
| if(inhole) holehiders <- c(holehiders,id) | |
| } | |
| holehiders | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment