Advertisement
guamie

xfer

May 12th, 2020
931
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.78 KB | None | 0 0
  1. --eventhorizoncomputer?other bad coputersscifi
  2.  
  3. --  Rednet Channels:
  4.   --  9997  -   All Action Logging
  5.   --  8089  -   Master Action Logging
  6.   --  666   -   Master Command Channel
  7.   --  69    -   Turtle-Interlink Channel
  8.   --  420   -   Farm Broadcasts
  9.   --  17    -   Quote of the Day
  10.   --  43    -   WhoIs
  11.   --        -   FuelLevel
  12.   --        -   Inventory Count, Type, table?
  13. --  Rednet Variables
  14.   --  host  -   systemname
  15.   --  loc  -   GPS location
  16.   --  Mod   -   hasmodem t/f
  17.  
  18.  
  19. --Arguments for location and etc.
  20.   --  x     -   Direction directly away
  21.   --  y     -   Direction Left/Right
  22.   --  z     -   Direction Up/Down
  23.   --  -     -   Starting Corner (Just L/R to start; middle squares in v.9000)
  24.   --  -     -   FloorBottom Slab
  25.   --  -     -   FloorTop Slab
  26.   --  -     -   Direction (inversion?)
  27.   --  -     -   Chest (reg,ender,none)
  28.  
  29. --  Start modem & announce self on network.
  30. --  Check GPS Location
  31. --  No GPS == set local location
  32.  
  33. --Move the turtle forward, make sure the turtle actually moves into a free space before moving, attempt to pick up things if attack triggered.
  34. --Rednet(9997)
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49. function moveForward()
  50.     if not turtle.forward() then
  51.                 if turtle.detect() then
  52.                         if not turtle.dig() then
  53.                                 print("dig returning false after detect")
  54.                                 return false
  55.                         else
  56.                                 if turtle.forward() == true then
  57.                                         return true
  58.                                 else
  59.                                         return moveForward()
  60.                                 end
  61.                         end
  62.                 else
  63.                         while turtle.attack() do
  64.                                 turtle.suck()
  65.                                 print("Turtle is attacking")
  66.                         end
  67.                         if turtle.forward() == true then
  68.                                 return true
  69.                         else
  70.                                 return moveForward()
  71.                         end
  72.                 end
  73.         else
  74.                 return true
  75.     end
  76. end
  77.  
  78. --Move the turtle down, make sure the turtle actually moves into a free space before moving, attempt to pick up things if attack triggered.
  79. --Rednet(9997)
  80. function moveDown()
  81.     if not turtle.down() then
  82.         if turtle.detectDown() then
  83.             if not turtle.digDown() then
  84.                 print("dig down returning false after detect")
  85.                 return false
  86.                         else
  87.                                 turtle.down()
  88.                                 return true
  89.                         end
  90.                 else
  91.                         attack = True
  92.                         while turtle.attackDown() do
  93.                                 turtle.suckDown()
  94.                                 turtle.attackDown()
  95.                                 turtle.suckDown()
  96.                         end
  97.                         turtle.down()
  98.             return true
  99.         end
  100.     else
  101.                 return true
  102.         end
  103. end
  104.  
  105. --Move the turtle up, make sure the turtle actually moves into a free space before moving, attempt to pick up things if attack triggered.
  106. --Rednet(9997)
  107. function moveUp()
  108.         if not turtle.up() then
  109.                 if turtle.detectUp() then
  110.                         if not turtle.digUp() then
  111.                                 print("dig up returning false after detect")
  112.                                 return false
  113.                         else
  114.                                 turtle.up()
  115.                                 return true
  116.                         end
  117.         else
  118.             attack = True                  
  119.                         while turtle.attackUp() do
  120.                                 turtle.suckUp()
  121.                                 turtle.attackUp()
  122.                                 turtle.suckUp()
  123.             end
  124.             turtle.up()
  125.             return true
  126.         end
  127.     else
  128.         return true
  129.     end
  130. end
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150. local tArgs = {...}
  151.     if #tArgs ~= 3 then
  152.       print("Requires length, width, height")
  153.       return
  154.     end
  155.      
  156.     local x = tonumber(tArgs[1]) - 1
  157.     local y = tonumber(tArgs[2])
  158.     local z = tonumber(tArgs[3])
  159.      
  160.     if x == nil or y == nil or z == nil then
  161.       print("Invalid dimensions")
  162.       return
  163.     end
  164.      
  165.     if x < 0 or y < 0 or z < 0 then
  166.       print("Invalid (negative) dimensions")
  167.       return
  168.     end
  169.  
  170.  
  171.      
  172.     local fuel = turtle.getFuelLevel()
  173.     local roomSize = x * y * z
  174.     while fuel < roomSize do
  175.       if not turtle.refuel(1) then
  176.         print("Not enough fuel")
  177.         return
  178.       end
  179.     end
  180.  
  181.  
  182.      
  183.     local direction = true
  184.     for i = 1, z do
  185.       for j = 1, y do
  186.         for k = 1, x do
  187.         moveForward()
  188.         end
  189.         if j < y then
  190.           if direction then
  191.             turtle.turnRight()
  192.             moveForward()
  193.             turtle.turnRight()
  194.             direction = false
  195.           else
  196.             turtle.turnLeft()
  197.             moveForward()
  198.             turtle.turnLeft()
  199.             direction = true
  200.           end
  201.         end
  202.       end
  203.       if i < z then
  204.         moveUp()
  205.         turtle.turnRight()
  206.         turtle.turnRight()
  207.       end
  208.     end
  209.      
  210.     if y % 2 == 0 then
  211.       turtle.turnRight()
  212.       for i = 1, y do
  213.         turtle.forward()
  214.       end
  215.       turtle.turnRight()
  216.     else
  217.       turtle.turnLeft()
  218.       for i = 1, y do
  219.         turtle.forward()
  220.       end
  221.       turtle.turnLeft()
  222.       for i = 1, x do
  223.         turtle.forward()
  224.       end
  225.       turtle.turnRight()
  226.       turtle.turnRight()
  227.     end
  228.     for i = 1, z do
  229.       turtle.down()
  230.     end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement