SHARE
TWEET

anothertestforargs

guamie May 26th, 2020 (edited) 1,239 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --Rednet Logging
  2. --Digs 3 rows at a time, wherever possible.
  3. --Dumps to return-chest OR EnderChest.
  4. --Places slabs if set on bottom AND/OR top
  5. --Can Run from Left or Right Corner
  6. --Can Run from Middle (left or right of even)
  7. --Can Run Inverted (Down)
  8. --Can return a one-line command
  9.  
  10. --eventhorizoncomputer?other bad coputersscifi
  11.  
  12. --  Rednet Channels:
  13.   --  9997  -   All Action Logging
  14.   --  8089  -   Master Action Logging
  15.   --  666   -   Master Command Channel
  16.   --  69    -   Turtle-Interlink Channel
  17.   --  420   -   Farm Broadcasts
  18.   --  17    -   Quote of the Day
  19.   --  43    -   WhoIs
  20.   --        -   FuelLevel
  21.   --        -   Inventory Count, Type, table?
  22.   --  host   -   systemname
  23.   --  loc    -   GPS location
  24.   --  Mod    -   hasmodem t/f
  25.   --  Mx     -   Direction directly away
  26.   --  My     -   Direction Left/Right
  27.   --  Mz     -   Direction Up/Down
  28.   --  Ms     -   Starting Corner (Just L/R to start; middle squares in v.9000)
  29.   --  Sb     -   FloorBottom Slab
  30.   --  St     -   FloorTop Slab
  31.   --  Mq     -   Direction (inversion?)
  32.   --  Mc     -   Chest (reg,ender,none)
  33. --  Start modem & announce self on network.
  34. --  Check GPS Location
  35. --  No GPS == set local location
  36.  
  37. --Move the turtle forward, make sure the turtle actually moves into a free space before moving, attempt to pick up things if attack triggered.
  38. --Rednet(9997)
  39.  
  40. function moveForward()
  41.     if not turtle.forward() then
  42.         if turtle.detect() then
  43.             if not turtle.dig() then
  44.                 print("dig returning false after detect")
  45.                 return false
  46.             else
  47.                 if turtle.forward() == true then
  48.                     return true
  49.                         else
  50.                             return moveForward()
  51.                 end
  52.             end
  53.             else
  54.                 while turtle.attack() do
  55.                     turtle.suck()
  56.                     print("Turtle is attacking")
  57.                 end
  58.                 if turtle.forward() == true then
  59.                     return true
  60.                         else
  61.                             return moveForward()
  62.                 end
  63.         end
  64.     else
  65.         return true
  66.     end
  67. end
  68.  
  69. --Move the turtle down, make sure the turtle actually moves into a free space before moving, attempt to pick up things if attack triggered.
  70. --Rednet(9997)
  71.  
  72. function moveDown()
  73.     if not turtle.down() then
  74.         if turtle.detectDown() then
  75.             if not turtle.digDown() then
  76.                 print("dig down returning false after detect")
  77.                 return false
  78.             else
  79.                 turtle.down()
  80.                 return true
  81.             end
  82.         else
  83.             while turtle.attackDown() do
  84.                 turtle.suckDown()
  85.                 turtle.attackDown()
  86.                 turtle.suckDown()
  87.             end
  88.             turtle.down()
  89.             return true
  90.         end
  91.     else
  92.         return true
  93.     end
  94. end
  95.  
  96. --Move the turtle up, make sure the turtle actually moves into a free space before moving, attempt to pick up things if attack triggered.
  97. --Rednet(9997)
  98.  
  99. function moveUp()
  100.     if not turtle.up() then
  101.         if turtle.detectUp() then
  102.             if not turtle.digUp() then
  103.                 print("dig up returning false after detect")
  104.                 return false
  105.             else
  106.                 turtle.up()
  107.                 return true
  108.             end
  109.         else
  110.             while turtle.attackUp() do
  111.                 turtle.suckUp()
  112.                 turtle.attackUp()
  113.                 turtle.suckUp()
  114.             end
  115.             turtle.up()
  116.             return true
  117.         end
  118.     else
  119.         return true
  120.     end
  121. end
  122.  
  123. --Deal with digging one row.
  124.  
  125. function oneRow()
  126.     for i = 1, 1 do
  127.         for j = 1, MYy do
  128.             for k = 1, MYx do
  129.                 moveForward()
  130.             end
  131.     if j < MYy then
  132.         if direction then
  133.             turtle.turnRight()
  134.             moveForward()
  135.             turtle.turnRight()
  136.             direction = false
  137.         else
  138.             turtle.turnLeft()
  139.             moveForward()
  140.             turtle.turnLeft()
  141.             direction = true
  142.         end
  143.     end
  144.         end
  145.     end
  146. end
  147.  
  148. --Deal with digging two rows.
  149.  
  150. function twoRow()
  151.    
  152.     turtle.digUp()
  153.     turtle.up()
  154.    
  155.     for i = 1, 1 do
  156.         for j = 1, MYy do
  157.             for k = 1, MYx do
  158.                 moveForward()
  159.                 turtle.digDown()
  160.             end
  161.     if j < MYy then
  162.         if direction then
  163.             turtle.turnRight()
  164.             moveForward()
  165.             turtle.digDown()
  166.             turtle.turnRight()
  167.             direction = false
  168.         else
  169.             turtle.turnLeft()
  170.             moveForward()
  171.             turtle.digDown()
  172.             turtle.turnLeft()
  173.             direction = true
  174.         end
  175.     end
  176.         end
  177.     end
  178. end
  179.  
  180.  --main boi
  181.  
  182. function main()
  183.         turtle.digUp()
  184.         turtle.up()
  185.         MYz = MYz/3
  186.     for i = 1, MYz do
  187.         for j = 1, MYy do
  188.             for k = 1, MYx do
  189.                 moveForward()
  190.                 turtle.digUp()
  191.                 turtle.digDown()
  192.             end
  193.     if j < MYy then
  194.         if direction then
  195.             turtle.turnRight()
  196.             moveForward()
  197.             turtle.digUp()
  198.             turtle.digDown()
  199.             turtle.turnRight()
  200.             direction = false
  201.         else
  202.             turtle.turnLeft()
  203.             moveForward()
  204.             turtle.digUp()
  205.             turtle.digDown()
  206.             turtle.turnLeft()
  207.             direction = true
  208.         end
  209.     end
  210.         end
  211.     end
  212. end
  213.  
  214.    
  215. MYx=0
  216. MYy=0
  217. MYz=0
  218. MYs = null
  219. Sb=0
  220. St=0
  221. Mq = null
  222. Mc = null
  223. direction = true
  224. interactive = "blarg"
  225.  
  226. --Interactive mode if the flags aren't what is expected.  
  227.  
  228. local tArgs = {...}
  229.  
  230. if #tArgs ~= 8 then
  231.     print("\n   Arguments are invalid.\n\n     Starting in your face interface.")
  232.    
  233. --Set Myx
  234.  
  235. while MYx==0 do
  236.   print("Input X, directly away.")
  237.   n = tonumber(read())
  238.   MYx = n
  239.   if type(n) == "number" then
  240.     print("X has been set to"..MYx)
  241.   end
  242. end
  243.  
  244. --Set MYy
  245.  
  246. while MYy==0 do
  247.   print("Input Y, direction left/right.")
  248.   n = tonumber(read())
  249.   MYy = n
  250.   if type(n) == "number" then
  251.     print("Y has been set to"..MYy)
  252.   end
  253. end
  254.  
  255. --Set MYz
  256.  
  257. while MYz==0 do
  258.   print("Input Z, direction up/down/")
  259.   n = tonumber(read())
  260.   MYz = n
  261.   if type(n) == "number" then
  262.     print("Z has been set to"..MYz)
  263.   end
  264. end
  265.  
  266. --Set MYs
  267.  
  268. while MYs==null do
  269.   print("Build Left or Right?")
  270.   n = tonumber(read())
  271.   MYs = n
  272.   if type(n) == "number" then
  273.     print("Starting corner has been set to"..MYs)
  274.   end
  275. end
  276.  
  277. --Set Sb
  278.  
  279. while Sb==0 do
  280.   print("Build slab floor?")
  281.   n = tonumber(read())
  282.   Sb = n
  283.   if type(n) == "number" then
  284.     print("Slab floor has been set to"..Sb)
  285.   end
  286. end
  287.  
  288. --Set St
  289.  
  290. while St==0 do
  291.   print("Build slab roof?")
  292.   n = tonumber(read())
  293.   St = n
  294.   if type(n) == "number" then
  295.     print("Slab floor has been set to"..St)
  296.   end
  297. end
  298.  
  299. --Set Mq
  300.  
  301. while Mq==null do
  302.   print("Room (up) or Excavate (down)?")
  303.   n = tonumber(read())
  304.   Mq = n
  305.   if type(n) == "number" then
  306.     print("Room/Excavate has been set to"..Mq)
  307.   end
  308. end
  309.  
  310. --Set Mc
  311.  
  312. while Mc==null do
  313.   print("Am I using a chest?")
  314.   n = tonumber(read())
  315.   Mc = n
  316.   if type(n) == "number" then
  317.     print("Chest value has been set to"..Mc)
  318.   end
  319. end
  320.  
  321. print("Your combination should be:")
  322. print("room "..MYx.." "..MYy.." "..MYz.." "..MYs.." "..Sb.." "..St.." "..Mq.." "..Mc)
  323.  
  324. --Check fuel before continueing
  325. --TASK, if not enough, tell user how many coal to fill, and wait for it.
  326. local fuel = turtle.getFuelLevel()
  327. local roomSize = MYx * MYy * MYz
  328. print(roomSize)
  329. while fuel < roomSize do
  330. if not turtle.refuel(1) then
  331. print("Not enough fuel")
  332. return
  333. end
  334. end
  335.  
  336. --shell.run(thestring)
  337.  
  338.  
  339. print("Would you like to run now?")
  340.  
  341.     repeat
  342.     event , param1 = os.pullEvent("char")
  343.         if param1 == "y" then
  344.             shell.run("room "..MYx.." "..MYy.." "..MYz.." "..MYs.." "..Sb.." "..St.." "..Mq.." "..Mc)
  345.             print("Running room program!")
  346.         elseif param1 == "n" then
  347.             print("Ending.")
  348.             return
  349.         elseif  param1  ~= ("y"or"a")   then
  350.             print ("wrong key")
  351.         end
  352.     until param1 == ("y"or"a")
  353.  
  354. else
  355.    
  356.     local MYx   = tonumber(tArgs[1]) - 1
  357.     local MYy   = tonumber(tArgs[2])
  358.     local MYz   = tonumber(tArgs[3])
  359.     local MYs   = tonumber(tArgs[4])
  360.     local Sb    = tonumber(tArgs[5])
  361.     local St    = tonumber(tArgs[6])
  362.     local Mq    = tonumber(tArgs[7])
  363.     local Mc    = tonumber(tArgs[8])       
  364.  
  365. end
  366.  
  367.  
  368. local direction = true
  369.  
  370. if MYz==1 then
  371.     oneRow()
  372. elseif MYz==2 then
  373.         turtle.digUp()
  374.     turtle.up()
  375.    
  376.     for i = 1, 1 do
  377.         for j = 1, MYy do
  378.             for k = 1, MYx do
  379.                 moveForward()
  380.                 turtle.digDown()
  381.             end
  382.     if j < MYy then
  383.         if direction then
  384.             turtle.turnRight()
  385.             moveForward()
  386.             turtle.digDown()
  387.             turtle.turnRight()
  388.             direction = false
  389.         else
  390.             turtle.turnLeft()
  391.             moveForward()
  392.             turtle.digDown()
  393.             turtle.turnLeft()
  394.             direction = true
  395.         end
  396.     end
  397.         end
  398.     end
  399. elseif MYz>=3 then
  400.     if MYz % 3 then
  401.         main()
  402.     elseif MYz- 2 % 3 then
  403.         main()
  404.         twoRow()
  405.     elseif MYz - 1 % 3 then
  406.         main()
  407.         turtle.up()
  408.         oneRow()
  409.     end
  410. end
  411.  
  412.  
  413. if MYy % 2 == 0 then
  414.     turtle.turnRight()
  415.         for i = 1, MYy do
  416.             turtle.forward()
  417.         end
  418.     turtle.turnRight()
  419. else
  420.     turtle.turnLeft()
  421.         for i = 1, MYy do
  422.             turtle.forward()
  423.         end
  424.     turtle.turnLeft()
  425.         for i = 1, MYx do
  426.             turtle.forward()
  427.         end
  428.     turtle.turnRight()
  429.     turtle.turnRight()
  430. end
  431. for i = 1, MYz do
  432.     turtle.down()
  433. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top