Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local command_arguments= {...}
- local command_right_meters= tonumber(command_arguments[1])
- local command_forward_meters= tonumber(command_arguments[2])
- function should_keep_block(
- block_name)
- local result= true
- local blacklist= {
- "BiomesOPlenty:mud",
- "chisel:andesite",
- "chisel:cobblestone",
- "chisel:diorite",
- "chisel:granite",
- "chisel:limestone",
- "minecraft:cobblestone",
- "minecraft:dirt",
- "minecraft:gravel"}
- for index= 1,#blacklist do
- if (block_name == blacklist[index]) then
- result= false
- break
- end
- end
- return result
- end
- function find_slot_with_block_name(
- block_name)
- local result= nil
- for index= 1,16 do
- local slot_data= turtle.getItemDetail(index)
- if slot_data and (slot_data.name == block_name) then
- result= index
- break
- end
- end
- return result
- end
- function core_drill(
- max_depth)
- local depth_stack= {}
- -- Dig down to max_depth or bedrock.
- for depth_index= 1,max_depth do
- local below_is_filled, below_data= turtle.inspectDown()
- if not below_is_filled then
- below_data= {name= "air", metadata= 0}
- end
- if (below_data.name == "minecraft:bedrock") then
- print("Found bedrock!")
- break
- end
- table.insert(depth_stack, below_data)
- turtle.digDown()
- turtle.down()
- end
- -- Return to the surface, replacing blocks as we go.
- while (#depth_stack > 0) do
- local popped= table.remove(depth_stack)
- turtle.up()
- local searched= popped
- if (searched.name == "minecraft:grass") then
- searched.name= "minecraft:dirt"
- end
- if (searched.name == "minecraft:stone") then
- searched.name= "minecraft:cobblestone"
- end
- if not should_keep_block(searched.name) then
- local slot_index= find_slot_with_block_name(searched.name)
- if slot_index then
- turtle.select(slot_index)
- turtle.placeDown()
- --print("Restored "..(searched.name))
- end
- else
- print("Kept "..(popped.name))
- end
- end
- end
- function core_mine(
- forward_meters,
- right_meters,
- down_meters)
- for right_index= 1,right_meters do
- for forward_index= 1,forward_meters do
- core_drill(down_meters)
- if (forward_index < forward_meters) then
- turtle.dig()
- turtle.forward()
- end
- end
- if (right_index < right_meters) then
- if (right_index%2 == 1) then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- turtle.dig()
- turtle.forward()
- if (right_index%2 == 1) then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- end
- end
- end
- core_mine(
- command_forward_meters,
- command_right_meters,
- 300)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement