Jump to content

rich1051414

Members
  • Posts

    4
  • Joined

  • Last visited

Everything posted by rich1051414

  1. you can also use an energy link to convert the power into engine power, teleport it with a teleport pipe, receive it and send to an engine generator to convert it back into EU's.
  2. it wouldn't be entirely necessary, but makes dig loops in case of gravel and sand a couple lines shorter to code. You can also turtle.detect for all directions, but it only returns a Boolean and only detects solid blocks(detects snow even tho it doesnt have to mine snow to move however). I do not think there is a way to check for fluid blocks at all, but the turtle is immune to lava and water anyways.
  3. This morning i was asked a few questions so i'm going to update the code to include comments and to allow arguments. It also has a block counter just for curiosity sake. I can add a few lines to detect when it is finished, if you ask. I thought a manual entry for height allowed for more flexible usage tho(like clearing an underground chamber), so i left it out. when you run the script, use this syntax: turtleFlatten [length] [width] [height] like this: turtleFlatten 16 8 20 This will mine 16x8x20 blocks. --TurtleFlatten --rich1051414 -------------------------------------------------- --Sends turtle out to flatten a plot land -------------------------------------------------- --Check arguments for correct formatting local args = { ... } if #args ~= 3 then --Check if it's not exactly 3 arguments. shell.run("clear") print("Invalid number of arguments") print("turtleflatten [length] [width] [height]") do return end end for i = 1, 3 do --Step through each argument and make sure it is a number greater than 1. if tonumber(args[i]) < 2 then shell.run("clear") print("Invalid arguments") print("All measurements must be numbers greater than 1") do return end end end -------------------------------------------------- --commandline arguments [length] [width] [height] length = tonumber(args[1]) --length of square width = tonumber(args[2]) --width of square height = tonumber(args[3]) --how high it needs to go -------------------------------------------------- -------------------------------------------------- -- Now for the logic -------------------------------------------------- -- Boolean to remember which way to turn. direction = false LayerBlockCount = 0 TotalBlocksBusted = 0 ------------------------------------------ -- Nested loops, 1 each for length width and height. shell.run("clear") print("Flatten land initialized.\n") write("Length: ") write(tostring(length)) write(" Width: ") write(tostring(width)) write(" Height: ") write(tostring(height)) print("\n\n\n") for x = 1, height do write("Layer ") write(tostring(x)) write(" started.\n\n") for xx = 1, width - 1 do for xxx = 1, length do --Digs until the turtle can move forward, to deal with gravel and sand. repeat if turtle.detect() then TotalBlocksBusted = TotalBlocksBusted + 1 end turtle.dig() until turtle.forward() == true -------------------------------------------------- end -- Orientation. if direction == false then direction = true turtle.turnRight() repeat if turtle.detect() then TotalBlocksBusted = TotalBlocksBusted + 1 end turtle.dig() until turtle.forward() == true turtle.turnRight() else direction = false turtle.turnLeft() repeat if turtle.detect() then TotalBlocksBusted = TotalBlocksBusted + 1 end turtle.dig() until turtle.forward() == true turtle.turnLeft() end -------------------------------------------------- end -- Last line finished outside of loop to remove unneeded steps. for xxx = 1, length do repeat if turtle.detect() then TotalBlocksBusted = TotalBlocksBusted + 1 end turtle.dig() until turtle.forward() == true end -------------------------------------------------- --Checks if it needs to go up or just turn around for completion. if x < height then repeat if turtle.detectUp() then TotalBlocksBusted = TotalBlocksBusted + 1 end turtle.digUp() until turtle.up() == true turtle.turnRight() turtle.turnRight() else turtle.turnRight() turtle.turnRight() end -------------------------------------------------- end print("Job Completed.\n") --Return turtle to starting point(if all dimensions are even numbers) print("Returning...\n") for a = 1, height do turtle.down() end write(tostring(TotalBlocksBusted)) write(" total blocks busted.\n\n") print("Powering down.\n") --------------------------------------------------
  4. I wrote a simple program that flattens land. Maybe it will help. It doesnt detect dangerous blocks but i only use it above water level anyways. It mines a cube and its starting position is the bottom front left corner. You have to modify two variables because i can't be bothered to add an argument handler. area = 16 --length of sides height = 30 --how high it needs to go direction = false for x = 1, height do for xx = 1, area - 1 do for xxx = 1, area do repeat turtle.dig() until turtle.forward() == true end if direction == false then direction = true turtle.turnRight() repeat turtle.dig() until turtle.forward() == true turtle.turnRight() else direction = false turtle.turnLeft() repeat turtle.dig() until turtle.forward() == true turtle.turnLeft() end end for xxx = 1, area do repeat turtle.dig() until turtle.forward() == true end if x < height then repeat turtle.digUp() until turtle.up() == true turtle.turnRight() turtle.turnRight() else turtle.turnRight() turtle.turnRight() end end for a = 1, height do turtle.down() ---return to ground level end
×
×
  • Create New...