Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Use this script to swap the contents (key and element) of two slots in the catalgoue
- -- requires 20.000 BLOCKS v2.5 with the new horizontal layout
- -- HOW TO USE
- -- You need two people in the world to be able to do this:
- -- 1. go to the catalogue and note down the numbers of the two slots you want to swap
- -- 2. go to the computer and open it
- -- 3. type "swap_slots <number_of_slot_1> <number_of_slot_2>"
- -- 4. press ENTER and wait a bit
- -- 5. if all goes well it will output "success""
- ---DONT CHANGE THE CODE BELOW
- os.loadAPI('registry')
- --a multi builder which uses the vocab constructor to create sets of vocab
- local function initCatalogueElements(countX, countZ, sizeX, sizeZ)
- local x,y,z = registry.FIRST_ELEMENT.x, registry.FIRST_ELEMENT.y, registry.FIRST_ELEMENT.z
- local result = {}
- local id = 1
- for i=0,countZ-1 do
- for k=0,countX-1 do
- local xpos = x - k * ( registry.GRIDCELL_SIZE * ( 2*registry.CATALOGUE_SLOTSIZE.x + 2 + registry.CATALOGUE_SLOT_OFFSET))
- local ypos = y
- local zpos = z + i*( registry.GRIDCELL_SIZE * ( registry.CATALOGUE_SLOTSIZE.z + 1 + registry.CATALOGUE_SLOT_OFFSET))
- --print("adding an element",i,k)
- local nextElement = newCatalogueElement(
- id,
- xpos,ypos,zpos,
- sizeX, sizeZ
- )
- table.insert(result,nextElement)
- id = id +1
- end
- end
- return result
- end
- --a catalogue slot constructor. Enforces some data structure
- function newCatalogueElement(id, x,y,z,sizeX, sizeZ)
- local nvz = {}
- nvz.id = id
- nvz.keyX ,nvz.keyY ,nvz.keyZ = x,y,z
- nvz.sizeX, nvz.sizeZ = sizeX, sizeZ
- nvz.elementX = nvz.keyX - nvz.sizeX - registry.GRIDCELL_SIZE --
- nvz.elementY = nvz.keyY
- nvz.elementZ = nvz.keyZ
- nvz.elementCenterX = nvz.elementX + math.floor ( nvz.sizeX/2 )
- nvz.elementCenterY = nvz.elementY
- nvz.elementCenterZ = nvz.elementZ + math.floor ( nvz.sizeZ/2 )
- nvz.keyCenterX = nvz.keyX + math.floor ( nvz.sizeX/2 )
- nvz.keyCenterY = nvz.keyY
- nvz.keyCenterZ = nvz.keyZ + math.floor ( nvz.sizeZ/2 )
- return nvz
- end
- --vocabzone creation
- --vocabSet = makeVocabZones(NUMBER_OF_VOCAB,VOCAB_WIDTH)
- elementSet = initCatalogueElements(
- registry.CATALOGUE_SLOTCOUNT.x,
- registry.CATALOGUE_SLOTCOUNT.z,
- registry.ELEMENT.sizeX,
- registry.ELEMENT.sizeZ
- )
- --- this function does the swapping
- -- slot_id1 and slot_id2 are the ids as displayed in the minecraft world in the catalogue matrix
- function swapSlots(slot_id1, slot_id2)
- print("swapping...")
- local element_1 = elementSet[slot_id1]
- local element_2 = elementSet[slot_id2]
- local height_offset = 10
- if element_1 and element_2 then
- --
- --clone element 1 above itself using the VOCAB HEIGHT
- --clone the key
- commands.clone( element_1.keyX, element_1.keyY, element_1.keyZ, element_1.keyX+element_1.sizeX, element_1.keyY+registry.VOCAB_HEIGHT, element_1.keyZ+element_1.sizeZ,
- element_1.keyX, element_1.keyY+registry.VOCAB_HEIGHT+height_offset, element_1.keyZ)
- --clone the element
- commands.clone( element_1.elementX, element_1.elementY, element_1.elementZ, element_1.elementX+element_1.sizeX, element_1.elementY+registry.VOCAB_HEIGHT, element_1.elementZ+element_1.sizeZ,
- element_1.elementX, element_1.elementY+registry.VOCAB_HEIGHT+height_offset, element_1.elementZ)
- --
- --
- --clone element 2 to element 1
- --clone the key
- commands.clone( element_2.keyX, element_2.keyY, element_2.keyZ, element_2.keyX+element_2.sizeX, element_2.keyY+registry.VOCAB_HEIGHT, element_2.keyZ+element_2.sizeZ,
- element_1.keyX, element_1.keyY, element_1.keyZ)
- --clone the element
- commands.clone( element_2.elementX, element_2.elementY, element_2.elementZ, element_2.elementX+element_2.sizeX, element_2.elementY+registry.VOCAB_HEIGHT, element_2.elementZ+element_2.sizeZ,
- element_1.elementX, element_1.elementY, element_1.elementZ)
- --
- --
- --clone the copy of element 1 to element 2
- --clone the key
- commands.clone( element_1.keyX, element_1.keyY+registry.VOCAB_HEIGHT+height_offset, element_1.keyZ, element_1.keyX+element_1.sizeX, element_1.keyY+2*registry.VOCAB_HEIGHT+height_offset, element_1.keyZ+element_1.sizeZ,
- element_2.keyX, element_2.keyY, element_2.keyZ)
- --clone the element
- commands.clone( element_1.elementX, element_1.elementY+registry.VOCAB_HEIGHT+height_offset, element_1.elementZ, element_1.elementX+element_1.sizeX, element_1.elementY+2*registry.VOCAB_HEIGHT+height_offset, element_1.elementZ+element_1.sizeZ,
- element_2.elementX, element_2.elementY, element_2.elementZ)
- --delete the copy of element 1
- --delete the key
- fillSmart(registry.BLOCKS.AIR.block, element_1.keyX, element_1.keyY+registry.VOCAB_HEIGHT+height_offset, element_1.keyZ, element_1.sizeX, registry.VOCAB_HEIGHT, element_1.sizeZ)
- --delete the element
- fillSmart(registry.BLOCKS.AIR.block, element_1.elementX, element_1.elementY+registry.VOCAB_HEIGHT+height_offset, element_1.elementZ, element_1.sizeX, registry.VOCAB_HEIGHT, element_1.sizeZ)
- else
- print("something wrong with element",slot_id1,element_1)
- print("and element",slot_id2,element_2)
- return
- end
- print("success!")
- end
- -- process command line parameters
- local tArgs = { ... } -- get the command line arguments
- local id1, id2
- if #tArgs == 2 then
- id1 = tonumber(tArgs[1])
- id2 = tonumber(tArgs[2])
- swapSlots(id1, id2)
- elseif #tArgs > 2 then
- print("Usage: swap_slots <number_of_slot_1> <number_of_slot_2>")
- return
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement