Advertisement
antonsavov

Untitled

Jan 19th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. os.loadAPI('lib/utils')
  2. os.loadAPI('lib/json')
  3.  
  4. --- Checks if given player is in a buildzone
  5. -- Uses a playerdata object and the buildzone selector
  6. -- @param player A playerdata object from newPlayerData()
  7. -- @param buildzone A buildzone object to get the selector from
  8. -- @return result True if the player is in the buildzone
  9. function checkForPlayers(_box)
  10. local result,message = commands.testfor('@a['.._box.selector..']')
  11.  
  12. if result == true then
  13. local names = {}
  14. for i,entry in ipairs(message) do
  15. local name = string.sub(entry, 7, -1)
  16. print(name)
  17. --[[
  18. --debug.log("starting message decoding: "..result)
  19. local wordpattern = "[^, ]+"
  20. local numberpattern = "[%-% ]%d+[%.]%d+"
  21. local words,numbers = {},{}
  22. --debug.log("finding words: "..result)
  23. for word in string.gmatch(result, wordpattern) do
  24. table.insert(words,word)
  25. end
  26. --debug.log("finding numbers: "..result)
  27. for number in string.gmatch(result, numberpattern) do
  28. table.insert(numbers,number)
  29. end
  30.  
  31. local coords = {
  32. x = math.floor(numbers[1]),
  33. y = math.floor(numbers[2]),
  34. z = math.floor(numbers[3])
  35. }
  36. local name = words[2]
  37. --debug.log("inserting into names list: "..name)
  38. --]]
  39. table.insert(names,name)
  40. end
  41. return names
  42. end
  43. --debug.log("getAllPos completed")
  44. return nil
  45. end
  46.  
  47. local ox,oy,oz = commands.getBlockPosition()
  48.  
  49. local bb = utils.box(ox-19,oy,oz-19,39,3,39)
  50.  
  51. while true do
  52. print(json.encode(checkForPlayers(bb)))
  53. print(json.encode(checkForPlayers(bb)[2]))
  54. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement