Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local distance = 0
- local direction = 0
- local times = 0
- local torches = 0
- local chest = 0
- local itemFuel = 0
- local td = 0 -- temp distance for
- local gap = 3
- local err = 0
- local function ioread()
- input = io.read();
- return input
- end
- local function fuelup()
- need = 0
- repeat
- if turtle.getFuelLevel() == "unlimited" then
- print( "NO NEED FOR FUEL" )
- need = 0
- elseif turtle.getFuelLevel() < 100 then
- turtle.select( 3 )
- turtle.refuel( 1 )
- need = 1
- itemFuel = itemFuel - 1
- elseif need == 1 then
- need = 0
- end
- until need == 0
- end
- local function precheck()
- if torch == 0 then
- print( "no torches" )
- end
- if chest == 0 then
- print( "no chests" )
- err = 1
- end
- if itemFuel == 0 then
- print( "no fuel" )
- err = 1
- end
- fuelup()
- end
- local function forward()
- light = 0
- repeat
- if turtle.detect() then
- turtle.dig()
- end
- if turtle.forward() then
- td = td - 1
- light = light + 1
- end
- if turtle.detectUp() then
- turtle.digUp()
- end
- if turtle.detectDown() then
- turtle.digDown()
- end
- --torch placer
- if light == 8 and torches > 0 then
- turtle.select(1)
- turtle.placeDown()
- torches = torches - 1
- light = light - 8
- end
- --chest placer
- if turtle.getItemCount(16) > 0 then
- --todo what if runs out of chest dont just die
- if chest > 0 then
- turtle.select( 2 )
- if turtle.detectDown() then
- turtle.digDown()
- end
- turtle.placeDown()
- chest = chest - 1
- for slot = 4, 16 do
- turtle.select( slot )
- turtle.dropDown()
- sleep( 1.5 )
- end
- turtle.select( 4 )
- else
- print( "no chests refuel into slot 2" )
- os.shutdown()
- end
- end
- fuelup()
- until td == 0
- end
- local function back()
- turtle.turnLeft()
- turtle.turnLeft()
- d = distance
- repeat
- if turtle.forward() then
- d = d - 1
- end
- if turtle.detect() then
- if d ~= 0 then
- turtle.dig()
- end
- end
- until d == 0
- if direction == 1 then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- end
- local function prepare()
- x = gap
- repeat
- if turtle.detect() then
- turtle.dig()
- end
- if turtle.forward() then
- x = x - 1
- end
- if turtle.detectUp() then
- turtle.digUp()
- end
- if turtle.detectDown() then
- turtle.digDown()
- end
- until x == 0
- if direction == 1 then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- if times == 0 then
- print( "turtle is done" )
- else
- times = times - 1
- end
- end
- local function mine()
- td = distance
- repeat
- forward()
- back()
- prepare()
- td = distance
- until times == 0
- end
- --start the program
- torches = turtle.getItemCount( 1 )
- chest = turtle.getItemCount( 2 )
- itemFuel = turtle.getItemCount( 3 )
- print( "strip miner")
- print( "enter distance" )
- distance = tonumber( ioread() )
- print( "what direction left=0 or right=1" )
- direction = tonumber( ioread() )
- print( "how many times" );
- times = tonumber( ioread() );
- precheck()
- if Error == 1 then
- print( "failed to start" )
- else
- mine()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement