Advertisement
antonsavov

Untitled

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