Advertisement
psychedelixx

Minecraft Turtle: Compact house

Jan 20th, 2015
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --[[
  2. Auflistung Materialien:
  3. 01 Fußboden innen:   12
  4. 02 Fußboden Veranda:  0
  5. 03 Halfsteps:         4
  6. 04 Sockel:           14
  7. 05 Wände Typ 1:      22
  8. 06 Wände Typ 2:       0
  9. 07 Fenster:           8
  10. 08 Türen:             0
  11. 09 Trittplatte:       0
  12. 10 Craftingtable:     1
  13. 11 Truhen:            0
  14. 12 Fackeln:           9
  15. 13 Öfen:              0
  16. 14 Dach:             38
  17. 15 Dach:              0
  18. 16 Giebel:            0
  19.  
  20.         Minecraft Turtle: Simple House
  21.         2013-12-13 (c) psychedelixx / thebiglebowski33
  22.  
  23.         Builds a simple house
  24.  
  25.         Usage:
  26.         - use turtle and type "label set <name>"
  27.           (to give your turtle an unique name so it remembers its programs)
  28.         - type "pastebin get jQ7H0UJd house"
  29. --]]
  30.  
  31. --[[ --- Konstanten --- ]]--
  32. dirCounter = 1
  33.  
  34. countList={}
  35. keyFloorIn    = "1"
  36. keyFloorOut   = "2"
  37. halfSteps     = "3"
  38. keySocket     = "4"
  39. keyWalls1     = "5"
  40. keyWalls2     = "6"
  41. keyWindows    = "7"
  42. keyDoors      = "8"
  43. keyPressPlate = "9"
  44. keyCraftTable = "10"
  45. keyChests     = "11"
  46. keyTorches    = "12"
  47. keyFurnaces   = "13"
  48. keyRoof1      = "14"
  49. keyRoof2      = "15"
  50. keyGable      = "16"
  51.  
  52. countList[keyFloorIn]    = 12
  53. countList[keyFloorOut]   = 0
  54. countList[halfSteps]     = 4
  55. countList[keySocket]     = 14
  56. countList[keyWalls1]     = 22
  57. countList[keyWalls2]     = 0
  58. countList[keyWindows]    = 8
  59. countList[keyDoors]      = 0
  60. countList[keyPressPlate] = 0
  61. countList[keyCraftTable] = 1
  62. countList[keyChests]     = 0
  63. countList[keyTorches]    = 9
  64. countList[keyFurnaces]   = 0
  65. countList[keyRoof1]      = 38
  66. countList[keyRoof2]      = 0
  67. countList[keyGable]      = 0
  68.  
  69. --[[
  70. for key, value in pairs(countList) do
  71.     print (key, " = " , value)
  72. end
  73. ]]--
  74.  
  75. --[[ --- Parameter ---- ]]--
  76. local args = { ... }
  77. if #args < 1 then
  78.         print("")
  79. end
  80. --[[arg1 = tonumber(args[1])]]--
  81.  
  82. --[[ --- Item Check --- ]]--
  83. function enoughResources()
  84.     for key, value in pairs(countList) do
  85.         if turtle.getItemCount(tonumber(key)) < value then
  86.             return false
  87.         end
  88.     end
  89.     return true
  90. end  
  91.  
  92. function calcFuel(blueprint)
  93.     return #blueprint*#blueprint[1]*#blueprint[1][1]
  94. end
  95.  
  96. function turn()
  97.     if dirCounter%2 == 1 then
  98.         t.right()
  99.         t.forward()
  100.         t.right()
  101.     else
  102.         t.left()
  103.         t.forward()
  104.         t.left()
  105.     end
  106.  
  107.     dirCounter = dirCounter + 1
  108. end
  109.  
  110. function buildHouse(blueprint)
  111.    
  112.     t.up()
  113.  
  114.     yMax = #blueprint
  115.     y = 1
  116.  
  117.     while y <= #blueprint do
  118.         zMax = #blueprint[y]
  119.         z = 1
  120.    
  121.         while z <= zMax do
  122.             xMax = #blueprint[y][z]
  123.            
  124.             if dirCounter%2 == 1 then
  125.                 x = 1
  126.             else
  127.                 x = xMax
  128.             end
  129.    
  130.             while (x <= xMax and dirCounter%2 == 1)
  131.                or (x >= 1 and dirCounter%2 == 0) do
  132.                 slot = blueprint[y][z][x]
  133.                
  134.                 print("x: ", x, "/", xMax, " - ",
  135.                       "z: ", z, "/", zMax, " - ",
  136.                       "y: ", y, "/", yMax, " - ",
  137.                       "slot: ", slot)
  138.                      
  139.                 if slot > 0 then
  140.                    
  141.                     if turtle.getItemCount(slot) == 0 and
  142.                        slot == 14 then
  143.                         slot = 15
  144.                     end
  145.             if slot == 13 then
  146.             t.left()
  147.             end
  148.  
  149.                     t.placeDown(slot)
  150.  
  151.             if slot == 13 then
  152.             t.right()
  153.             end
  154.                 end
  155.                 if (x < xMax and dirCounter%2 == 1)
  156.                  or(x > 1 and dirCounter%2 == 0) then
  157.                     t.forward()
  158.                 end
  159.                
  160.                 if dirCounter%2 == 1 then
  161.                     x = x+1
  162.                 else
  163.                     x = x-1
  164.                 end
  165.             end
  166.            
  167.             if z < zMax then
  168.                 turn()
  169.             end
  170.             z = z+1
  171.         end
  172.  
  173.         if y < yMax then
  174.             driveToStartPos(blueprint, y)
  175.         else
  176.             t.forward()
  177.             for y = 1, yMax, 1 do
  178.                 t.down()
  179.             end
  180.             print("Finished!")
  181.             print("All your base are belong to us")  
  182.         end
  183.         y = y+1
  184.     end
  185. end
  186.  
  187. --[[ Funktion Rückfahrt: ]]--
  188. function driveToStartPos(array, y)    
  189.     print("Driving to start position")  
  190.     if dirCounter%2 == 0 then
  191.         t.right()
  192.     else
  193.         t.right()
  194.         t.right()
  195.         for x = 1, #array[y][#array[y]]-1, 1 do
  196.             t.forward()
  197.         end
  198.         t.right()
  199.     end
  200.      
  201.     for z = 1, #array[y]-1, 1 do
  202.         t.forward()
  203.     end
  204.      
  205.     t.right()
  206.     t.up()
  207.     dirCounter = 1
  208. end
  209.  
  210. function start()
  211.     if enoughResources() or 1 == 1 then
  212.         print("forwards, to the moon, alice")
  213.  
  214.         layer    = {}    
  215.  
  216.         layer[1] = {{ 0,12, 4, 4, 4,12},
  217.             { 3, 4, 1, 1, 1, 4},
  218.             { 3, 4, 1, 1, 1, 4},
  219.             { 3, 4, 1, 1, 1, 4},
  220.             { 3, 4, 1, 1, 1, 4},
  221.             { 0,12, 4, 4, 4,12}}
  222.  
  223.         layer[2] = {{ 0, 0, 5, 5, 5, 0},
  224.             { 0, 5, 0, 0, 0, 5},
  225.             { 0, 0, 0, 0, 0, 5},
  226.             { 0, 5, 0, 0, 0, 5},
  227.             { 0, 5, 10, 0, 0, 5},
  228.             { 0, 0, 5, 5, 5, 0}}
  229.  
  230.         layer[3] = {{ 0, 0, 5, 7, 5, 0},
  231.             { 0, 5, 0, 0,12, 5},
  232.             { 0, 0, 0, 0, 0, 7},
  233.             { 0, 5, 0, 0, 0, 7},
  234.             { 0, 5, 0, 0, 0, 5},
  235.             { 0, 0, 5, 7, 5, 0}}
  236.  
  237.         layer[4] = {{ 0,15,15,15,15,15},
  238.             { 0,15, 0, 0, 0,15},
  239.             { 0,15, 0, 0, 0,15},
  240.             { 0,15, 0, 0, 0,15},
  241.             { 0,15, 0, 0, 0,15},
  242.             { 0,15,15,15,15,15}}
  243.  
  244.         layer[5] = {{ 0, 0, 0, 0, 0, 0},
  245.             { 0,15,15,15,15,15},
  246.             { 0, 7, 0, 0, 0, 7},
  247.             { 0, 7, 0, 0, 0, 7},
  248.             { 0,15,15,15,15,15},
  249.             { 0, 0, 0, 0, 0, 0}}
  250.  
  251.         layer[6] = {{ 0, 0, 0, 0, 0, 0},
  252.             { 0,12, 0, 0, 0,12},
  253.             { 0,15,15,15,15,15},
  254.             { 0,15,15,15,15,15},
  255.             { 0,12, 0, 0, 0,12},
  256.             { 0, 0, 0, 0, 0, 0}}
  257.                    
  258.         if turtle.getFuelLevel() < calcFuel(layer) then
  259.             print("Amount of missing fuel: ", calcFuel(layer)-turtle.getFuelLevel())
  260.             print("Missing fuel in coal: ", calcFuel(layer)-turtle.getFuelLevel()/80+1)
  261.             print("Fill fuel in slot 1, type 'refuel <amount>' and try again")
  262.             error()
  263.         end
  264.        
  265.         buildHouse(layer)
  266.     else
  267.         print("Not enough Resources")
  268.     end
  269. end
  270.  
  271.  
  272. print("======== 2013 (c) psy & lebo ==========")
  273. print("======== Simple House Builder =========")
  274.  
  275. start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement