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
- --
- --
- -- PLAYER = "quantx"
- POSITION = {
- x = 18,
- y = 57,
- z = -30
- }
- ROW = 1 --the number of the row for the wanted vocab. First is 1, not 0
- COL = 7 --the number of the column for the wanted vocab. First is 1, not 0
- VOCAB_WIDTH = 27
- VOCAB_HEIGHT = 19
- NUMBER_OF_VOCAB = 10
- FIRSTVOCAB= { --this is at ~-4 ~ ~-4 from the corner of the shape zone of the vocab that is closest to zero
- x=-60,
- y=57,
- z=-107
- }
- --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 getPlayePos(name)
- local result, message = commands.tp("@a[name="..name.."]","~ ~ ~")
- 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
- local position = {
- x = names[0].x,
- y = names[0].y,
- z = names[0].z
- }
- return position
- end
- --]==]
- --[==[
- --constructor for player object so that data structure is consistant
- function newPlayerData(name,x,y,z)
- local p = {
- name = name,
- x=x,
- y=y,
- z=z
- }
- return p
- end
- --]==]
- --a multi builder which uses the vocab constructor to create sets of vocab
- function makeVocabZones(quant,w)
- local x,y,z = FIRSTVOCAB.x, FIRSTVOCAB.y, FIRSTVOCAB.z
- local result = {}
- local namecount = 1
- for i=0,quant-1 do
- for k=0,3 do
- local zpos = i
- local ypos = k
- if i == -1 then
- print("vocab at X")
- print(x)
- print("and Z")
- print(z)
- end
- 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)
- table.insert(result,nextVocab)
- namecount = namecount +1
- end
- end
- --print(result[1].cx)
- 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
- --vocabzone creation
- vocabSet = makeVocabZones(NUMBER_OF_VOCAB,VOCAB_WIDTH)
- -- this function does the cloning to a position
- function cloneVocab(position,row,col)
- local index = (col-1)*4 + row
- local vocab = vocabSet[index]
- if vocab then
- 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")
- print("cloned vocab at col:"..col.." and row:"..row.." to x:"..position.x..", y:"..position.y..", z:"..position.z..". done!")
- print("the vocab master's origin is at x:"..vocab.cx..", y"..vocab.cy..", z:"..vocab.cz)
- else
- print("something wrong with vocab")
- end
- end
- function main()
- cloneVocab(POSITION,ROW,COL)
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement