Advertisement
antonsavov

cloneVertCatToHorizCat v2.5

Dec 7th, 2017
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.31 KB | None | 0 0
  1. -- Use this script to clone the full catalogue from the old (pre 2.5) 20.000 BLOCKS layout
  2. -- to the new horizontal layout
  3.  
  4. -- HOW TO USE
  5. -- You need two people in the world to be able to do this:
  6. -- 1. go to the old computer and write down its coordinates
  7. -- 2. open computer and type "edit registry"
  8. -- 3. write down the values of "NUMBER_OF_VOCAB", "VOCAB_WIDTH", "VOCAB_HEIGHT", "GRIDCELL_COUNT" and "GRIDCELL_SIZE"
  9. -- 4. press CTRL key and choose "EXIT" and press ENTER then press ESC to close the computer console
  10. -- 5. go to a new location in the world (at best find a location further down on positive Z from the old setup otherwise you might wipe your exisitng catalogue)
  11. -- 6. place a new command computer on the ground
  12. -- 7. download the latest 20.000 BLOCKS version 2.5 with command <pastebin get FcGRrZgr setup_2_5>
  13. -- 8. run "setup_2_5"
  14. -- 9. dont start the game yet
  15. -- 10. type "edit registry"
  16. -- 11. find CATALOGUE_SLOTCOUNT and change the field "x" to equal 4 and the field "z" to equal the value of "NUMBER_OF_VOCAB" form step 3.
  17. -- 12. find "GRIDCELL_SIZE" and "GRIDCELL_COUNT" and set them to the values from step 3.
  18. -- 13. press CTRL key and choose "SAVE" and press ENTER
  19. -- 14. press CTRL key and choose "EXIT" and press ENTER then press ESC to close the computer console
  20. -- 15. run "play" and once it loads terminate it with CTRL+T
  21. -- 16. type "edit clone_old_vocab_to_new_catalogue"
  22. -- 17. find "OLD_COMPUTER" and change the x,y,z fields to the coordinates from step 1.
  23. -- 18. find "NUMBER_OF_VOCAB", "VOCAB_WIDTH", "VOCAB_HEIGHT" and set them to the values from step 3.
  24. -- 19. press CTRL key and choose "SAVE" and press ENTER
  25. -- 20. press CTRL key and choose "EXIT" and press ENTER then press ESC to close the computer console
  26. -- 21. Have your second team member stay in the area with the old catalogue so its chunks stay loaded otherwise the copying will fail
  27. -- 22. run "clone_old_vocab_to_new_catalogue"
  28. -- 23. wait for it to complete. It will output "success" if all goes well
  29. -- 24. check the new catalogue to see if everything copied correctly
  30. -- 25. run "play" and test your game
  31.  
  32.  
  33. --FILL IN THE VARIABLES BELOW WITH THE INFO FROM YOUR OLD SETUP
  34.  
  35. --the position of the old computer
  36. OLD_COMPUTER = {
  37.     x = -58,
  38.     y = 57,
  39.     z = -525
  40. }
  41. NUMBER_OF_VOCAB = 5 -- the number of vocab columns in your old setup
  42. VOCAB_WIDTH = 27 -- in blocks
  43. VOCAB_HEIGHT = 19 -- in blocks
  44.  
  45. ---DONT CHANGE THE CODE BELOW
  46.  
  47. os.loadAPI('registry')
  48.  
  49. FIRSTVOCAB= {
  50.     x=OLD_COMPUTER.x,
  51.     y=OLD_COMPUTER.y,
  52.     z=OLD_COMPUTER.z
  53. }
  54.  
  55. --a multi builder which uses the vocab constructor to create sets of vocab
  56. local function makeVocabZones(quant,w)
  57.     local x,y,z = FIRSTVOCAB.x, FIRSTVOCAB.y, FIRSTVOCAB.z
  58.     local result = {}
  59.     local id = 1
  60.     for i=0,quant-1 do
  61.         for k=0,3 do
  62.             local zpos = i-4
  63.             local ypos = k
  64.             local nextVocab = newVocabZone(
  65.                 x-(2*w)-6,y+(ypos*(VOCAB_HEIGHT+3)),
  66.                 z+((w+1)*zpos),
  67.                 w,
  68.                 id
  69.             )
  70.             table.insert(result,nextVocab)
  71.             id = id +1
  72.         end
  73.     end
  74.     return result
  75. end
  76.  
  77. --vocab constructor. Enforces some data structure
  78. function newVocabZone(x,y,z,w,id )
  79.     local nvz = {}
  80.     nvz.x ,nvz.y ,nvz.z ,nvz.w = x,y,z,w
  81.     nvz.id = id
  82.     nvz.cx = nvz.x - nvz.w - 2
  83.     nvz.cy = nvz.y
  84.     nvz.cz = nvz.z
  85.    
  86.     return nvz
  87.    
  88. end
  89.  
  90. --a multi builder which uses the vocab constructor to create sets of vocab
  91. local function initCatalogueElements(countX, countZ, sizeX, sizeZ)
  92.     local x,y,z = registry.FIRST_ELEMENT.x, registry.FIRST_ELEMENT.y, registry.FIRST_ELEMENT.z
  93.     local result = {}
  94.     local id = 1
  95.     for i=0,countZ-1 do
  96.         for k=0,countX-1 do
  97.  
  98.             local xpos = x - k * ( registry.GRIDCELL_SIZE * ( 2*registry.CATALOGUE_SLOTSIZE.x + 2 + registry.CATALOGUE_SLOT_OFFSET))
  99.             local ypos = y
  100.             local zpos = z + i*( registry.GRIDCELL_SIZE * ( registry.CATALOGUE_SLOTSIZE.z + 1 + registry.CATALOGUE_SLOT_OFFSET))
  101.             --print("adding an element",i,k)
  102.             local nextElement = newCatalogueElement(
  103.                 id,
  104.                 xpos,ypos,zpos,
  105.                 sizeX, sizeZ
  106.             )
  107.             table.insert(result,nextElement)
  108.             id = id +1
  109.         end
  110.     end
  111.     return result
  112. end
  113.  
  114. --a catalogue slot constructor. Enforces some data structure
  115. function newCatalogueElement(id, x,y,z,sizeX, sizeZ)
  116.     local nvz = {}
  117.     nvz.id = id
  118.     nvz.keyX ,nvz.keyY ,nvz.keyZ = x,y,z
  119.     nvz.sizeX, nvz.sizeZ = sizeX, sizeZ
  120.     nvz.elementX = nvz.keyX - nvz.sizeX - registry.GRIDCELL_SIZE --
  121.     nvz.elementY = nvz.keyY
  122.     nvz.elementZ = nvz.keyZ
  123.     nvz.elementCenterX = nvz.elementX + math.floor ( nvz.sizeX/2 )
  124.     nvz.elementCenterY = nvz.elementY
  125.     nvz.elementCenterZ = nvz.elementZ + math.floor ( nvz.sizeZ/2 )
  126.     nvz.keyCenterX = nvz.keyX + math.floor ( nvz.sizeX/2 )
  127.     nvz.keyCenterY = nvz.keyY
  128.     nvz.keyCenterZ = nvz.keyZ + math.floor ( nvz.sizeZ/2 )
  129.     return nvz 
  130. end
  131.  
  132. --vocabzone creation
  133. vocabSet = makeVocabZones(NUMBER_OF_VOCAB,VOCAB_WIDTH)
  134. elementSet = initCatalogueElements(
  135.     registry.CATALOGUE_SLOTCOUNT.x,
  136.     registry.CATALOGUE_SLOTCOUNT.z,
  137.     registry.ELEMENT.sizeX,
  138.     registry.ELEMENT.sizeZ
  139. )
  140.  
  141. -- this function does the cloning
  142. function cloneVocabToCatalogue()
  143.     print("copying old catalogue to the new location...")
  144.     for col=1, registry.CATALOGUE_SLOTCOUNT.z do
  145.         for row = 1, registry.CATALOGUE_SLOTCOUNT.x do
  146.            
  147.             local index = (col-1)*registry.CATALOGUE_SLOTCOUNT.x + row
  148.             local vocab = vocabSet[index]
  149.             local element = elementSet[index]
  150.             if vocab and element then
  151.                 --clone the key
  152.                 commands.clone( vocab.x, vocab.y, vocab.z, vocab.x+vocab.w, vocab.y+VOCAB_HEIGHT, vocab.z+vocab.w,
  153.                     element.keyCenterX-math.floor(vocab.w/2), element.keyCenterY, element.keyCenterZ-math.floor(vocab.w/2),"masked")
  154.                 --clone the element                
  155.                 commands.clone( vocab.cx, vocab.cy, vocab.cz, vocab.cx+vocab.w, vocab.cy+VOCAB_HEIGHT, vocab.cz+vocab.w,
  156.                     element.elementCenterX-math.floor(vocab.w/2), element.elementCenterY, element.elementCenterZ-math.floor(vocab.w/2),"masked")
  157.                 --
  158.                 --print("cloned vocab key at col:"..col.." and row:"..row)
  159.                 --print("to x:"..(element.keyCenterX-math.floor(vocab.w/2))..", y:"..(element.keyCenterY)..", z:"..(element.keyCenterZ-math.floor(vocab.w/2))..". done!")
  160.                 --print("from x:"..vocab.x..", y"..vocab.y..", z:"..vocab.z)
  161.                 --print("from x:"..vocab.cx..", y"..vocab.cy..", z:"..vocab.cz)
  162.             else
  163.                 print("something wrong with vocab",col,row,vocab,element)
  164.                 return
  165.             end
  166.         end
  167.     end
  168.     print("success!")
  169. end
  170.  
  171. cloneVocabToCatalogue()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement