Advertisement
antonsavov

Untitled

Dec 17th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. -- clones a vocab by number (row and column) to the position of a provided player name
  2. --
  3. --
  4.  
  5. VOCAB_WIDTH = 27
  6. VOCAB_HEIGHT = 19
  7. NUMBER_OF_VOCAB = 10
  8.  
  9. local ox,oy,oz = commands.getBlockPosition()
  10.  
  11. --return a list of all players in the game world as player objects
  12. local function getAllPos(selector)
  13. local result, message = commands.tp("@a["..selector.."]","~ ~ ~")
  14. local names = {}
  15. if result == true then
  16. for i,result in ipairs(message) do
  17. local wordpattern = "[^, ]+"
  18. local numberpattern = "[%-% ]%d+[%.]%d+"
  19. local words,numbers = {},{}
  20.  
  21. for word in string.gmatch(result, wordpattern) do
  22. table.insert(words,word)
  23. end
  24.  
  25. for number in string.gmatch(result, numberpattern) do table.insert(numbers,number) end
  26.  
  27. local coords = {
  28. x = math.floor(numbers[1]),
  29. y = math.floor(numbers[2]),
  30. z = math.floor(numbers[3])
  31. }
  32. local name = words[2]
  33. table.insert(names,newPlayerData(name,coords.x,coords.y,coords.z))
  34. --print("Player Found - getAllPos")
  35. end
  36. end
  37. return names
  38. end
  39.  
  40. --buildzone and vocabzone creation
  41. vocabSet = makeVocabZones(NUMBER_OF_VOCAB,VOCAB_WIDTH)
  42.  
  43.  
  44. --a multi builder which uses the vocab constructor to create sets of vocab
  45. local function makeVocabZones(quant,w)
  46. local x,y,z = ox,oy,oz+6
  47. local result = {}
  48. local namecount = 1
  49. for i=0,quant-1 do
  50. for k=0,3 do
  51. local zpos = i-4
  52. local ypos = k
  53. if i == 0 then
  54. print("vocab at X")
  55. print(x-(2*w)-6)
  56. print("and Z")
  57. print(z+((w+1)*zpos))
  58. end
  59. local nextVocab = newVocabZone(x-(2*w)-6,y+(ypos*(VOCAB_HEIGHT+3)),z+((w+1)*zpos),w,REWARDS[namecount] or DEFAULT_REWARD,VOCAB_NAMES[namecount] or DEFAULT_NAME)
  60. table.insert(result,nextVocab)
  61. namecount = namecount +1
  62. end
  63. end
  64. return result
  65. end
  66.  
  67. --vocab constructor. Enforces some data structure
  68. function newVocabZone(x,y,z,w,reward,name)
  69. local nvz = {}
  70. nvz.x ,nvz.y ,nvz.z ,nvz.w = x,y,z,w
  71.  
  72. nvz.cx = nvz.x - nvz.w - 2
  73. nvz.cy = nvz.y
  74. nvz.cz = nvz.z
  75. nvz.name = name
  76. nvz.reward = reward
  77.  
  78. return nvz
  79.  
  80. end
  81.  
  82.  
  83.  
  84. -- this function does the cloning to a position
  85. function cloneVocab(position,row,col)
  86.  
  87. commands.clone(vocab.cx,vocab.cy,vocab.cz,vocab.cx+vocab.w,vocab.cy+VOCAB_HEIGHT,vocab.cz+vocab.w,position.x-math.floor(vocab.w/2),position.y-1,position.z-math.floor(vocab.w/2),"masked")
  88.  
  89. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement