Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI('lib/utils')
- os.loadAPI('lib/json')
- --- Checks if given player is in a buildzone
- -- Uses a playerdata object and the buildzone selector
- -- @param player A playerdata object from newPlayerData()
- -- @param buildzone A buildzone object to get the selector from
- -- @return result True if the player is in the buildzone
- function checkForPlayers(_box)
- local result,message = commands.testfor('@a['.._box.selector..']')
- if result == true then
- local names = {}
- for i,entry in ipairs(message) do
- local name = string.sub(entry, 7, -1)
- print(name)
- --[[
- --debug.log("starting message decoding: "..result)
- local wordpattern = "[^, ]+"
- local numberpattern = "[%-% ]%d+[%.]%d+"
- local words,numbers = {},{}
- --debug.log("finding words: "..result)
- for word in string.gmatch(result, wordpattern) do
- table.insert(words,word)
- end
- --debug.log("finding numbers: "..result)
- for number in string.gmatch(result, numberpattern) do
- table.insert(numbers,number)
- end
- local coords = {
- x = math.floor(numbers[1]),
- y = math.floor(numbers[2]),
- z = math.floor(numbers[3])
- }
- local name = words[2]
- --debug.log("inserting into names list: "..name)
- --]]
- table.insert(names,name)
- end
- return names
- end
- --debug.log("getAllPos completed")
- return nil
- end
- local ox,oy,oz = commands.getBlockPosition()
- local bb = utils.box(ox-19,oy,oz-19,39,3,39)
- while true do
- print(json.encode(checkForPlayers(bb)))
- print(json.encode(checkForPlayers(bb)[2]))
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement