Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- clones a vocab by number (row and column) to the position of a provided player name
- --
- --
- print("Starting vocab copy")
- VOCAB_WIDTH = 27
- VOCAB_HEIGHT = 19
- NUMBER_OF_VOCAB = 10
- DEFAULT_REWARD = 'minecraft:emerald 2 0 {display:{Name:"Emerald",Lore:[Trade this to the villager for wool]}}'
- DEFAULT_NAME = 'default-vocab'
- local ox,oy,oz = commands.getBlockPosition()
- --return a list of all players in the game world as player objects
- local function getAllPos(selector)
- local result, message = commands.tp("@a["..selector.."]","~ ~ ~")
- local names = {}
- if result == true then
- for i,result in ipairs(message) do
- local wordpattern = "[^, ]+"
- local numberpattern = "[%-% ]%d+[%.]%d+"
- local words,numbers = {},{}
- for word in string.gmatch(result, wordpattern) do
- table.insert(words,word)
- end
- for number in string.gmatch(result, numberpattern) do table.insert(numbers,number) end
- local coords = {
- x = math.floor(numbers[1]),
- y = math.floor(numbers[2]),
- z = math.floor(numbers[3])
- }
- local name = words[2]
- table.insert(names,newPlayerData(name,coords.x,coords.y,coords.z))
- --print("Player Found - getAllPos")
- end
- end
- return names
- end
- --buildzone and vocabzone creation
- local vocabSet = makeVocabZones(NUMBER_OF_VOCAB,VOCAB_WIDTH)
- --a multi builder which uses the vocab constructor to create sets of vocab
- local function makeVocabZones(quant,w)
- local x,y,z = ox,oy,oz+6
- local result = {}
- local namecount = 1
- for i=0,quant-1 do
- for k=0,3 do
- local zpos = i-4
- local ypos = k
- if i == 0 then
- print("vocab at X")
- print(x-(2*w)-6)
- print("and Z")
- print(z+((w+1)*zpos))
- end
- 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)
- table.insert(result,nextVocab)
- namecount = namecount +1
- end
- end
- return result
- end
- --vocab constructor. Enforces some data structure
- function newVocabZone(x,y,z,w,reward,name)
- local nvz = {}
- nvz.x ,nvz.y ,nvz.z ,nvz.w = x,y,z,w
- nvz.cx = nvz.x - nvz.w - 2
- nvz.cy = nvz.y
- nvz.cz = nvz.z
- nvz.name = name
- nvz.reward = reward
- return nvz
- end
- -- this function does the cloning to a position
- function cloneVocab(position,row,col)
- 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")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement