Advertisement
antonsavov

Untitled

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