Advertisement
antonsavov

Untitled

Jan 2nd, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.55 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. -- PLAYER = "quantx"
  6. POSITION = {
  7. x = 18,
  8. y = 57,
  9. z = -30
  10. }
  11. ROW = 1 --the number of the row for the wanted vocab. First is 1, not 0
  12. COL = 7 --the number of the column for the wanted vocab. First is 1, not 0
  13.  
  14. VOCAB_WIDTH = 27
  15. VOCAB_HEIGHT = 19
  16. NUMBER_OF_VOCAB = 10
  17.  
  18. FIRSTVOCAB= { --this is at ~-4 ~ ~-4 from the corner of the shape zone of the vocab that is closest to zero
  19. x=-60,
  20. y=57,
  21. z=-107
  22. }
  23.  
  24. --DEFAULT_REWARD = 'minecraft:emerald 2 0 {display:{Name:"Emerald",Lore:[Trade this to the villager for wool]}}'
  25. --DEFAULT_NAME = 'default-vocab'
  26.  
  27. --local ox,oy,oz = commands.getBlockPosition()
  28.  
  29. --return a list of all players in the game world as player objects
  30. --[==[
  31. local function getPlayePos(name)
  32. local result, message = commands.tp("@a[name="..name.."]","~ ~ ~")
  33. local names = {}
  34.  
  35. if result == true then
  36. for i,result in ipairs(message) do
  37. local wordpattern = "[^, ]+"
  38. local numberpattern = "[%-% ]%d+[%.]%d+"
  39. local words,numbers = {},{}
  40.  
  41. for word in string.gmatch(result, wordpattern) do
  42. table.insert(words,word)
  43. end
  44.  
  45. for number in string.gmatch(result, numberpattern) do table.insert(numbers,number) end
  46.  
  47. local coords = {
  48. x = math.floor(numbers[1]),
  49. y = math.floor(numbers[2]),
  50. z = math.floor(numbers[3])
  51. }
  52. local name = words[2]
  53. table.insert(names,newPlayerData(name,coords.x,coords.y,coords.z))
  54. --print("Player Found - getAllPos")
  55. end
  56. end
  57. local position = {
  58. x = names[0].x,
  59. y = names[0].y,
  60. z = names[0].z
  61. }
  62. return position
  63. end
  64. --]==]
  65.  
  66. --[==[
  67. --constructor for player object so that data structure is consistant
  68. function newPlayerData(name,x,y,z)
  69. local p = {
  70. name = name,
  71. x=x,
  72. y=y,
  73. z=z
  74. }
  75. return p
  76. end
  77. --]==]
  78.  
  79. --a multi builder which uses the vocab constructor to create sets of vocab
  80. function makeVocabZones(quant,w)
  81. local x,y,z = FIRSTVOCAB.x, FIRSTVOCAB.y, FIRSTVOCAB.z
  82. local result = {}
  83. local namecount = 1
  84. for i=0,quant-1 do
  85. for k=0,3 do
  86. local zpos = i
  87. local ypos = k
  88. if i == -1 then
  89. print("vocab at X")
  90. print(x)
  91. print("and Z")
  92. print(z)
  93. end
  94. local nextVocab = newVocabZone(x,y+(ypos*(VOCAB_HEIGHT+3)),z+((w+1)*zpos),w ) --,REWARDS[namecount] or DEFAULT_REWARD,VOCAB_NAMES[namecount] or DEFAULT_NAME)
  95. table.insert(result,nextVocab)
  96. namecount = namecount +1
  97. end
  98. end
  99. --print(result[1].cx)
  100. return result
  101. end
  102.  
  103. --vocab constructor. Enforces some data structure
  104. function newVocabZone(x,y,z,w )--,reward,name)
  105. local nvz = {}
  106. nvz.x ,nvz.y ,nvz.z ,nvz.w = x,y,z,w
  107.  
  108. nvz.cx = nvz.x - nvz.w - 2
  109. nvz.cy = nvz.y
  110. nvz.cz = nvz.z
  111. --nvz.name = name
  112. --nvz.reward = reward
  113.  
  114. return nvz
  115.  
  116. end
  117.  
  118.  
  119.  
  120.  
  121.  
  122. --vocabzone creation
  123. vocabSet = makeVocabZones(NUMBER_OF_VOCAB,VOCAB_WIDTH)
  124.  
  125. -- this function does the cloning to a position
  126. function cloneVocab(position,row,col)
  127. local index = (col-1)*4 + row
  128. local vocab = vocabSet[index]
  129. if vocab then
  130. 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")
  131. print("cloned vocab at col:"..col.." and row:"..row.." to x:"..position.x..", y:"..position.y..", z:"..position.z..". done!")
  132. print("the vocab master's origin is at x:"..vocab.cx..", y"..vocab.cy..", z:"..vocab.cz)
  133. else
  134. print("something wrong with vocab")
  135. end
  136.  
  137. end
  138.  
  139. function main()
  140. cloneVocab(POSITION,ROW,COL)
  141. end
  142.  
  143. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement