Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function checkSupply()
- local b_sup = False
- for i=9,16,1 do
- if turtle.getItemCount(i) > 0 then
- -- print(i)
- return i
- end
- end
- end
- function dropTrash()
- for i=1,8,1 do
- turtle.select(i)
- turtle.drop()
- end
- end
- function hangAleft()
- turtle.turnLeft()
- turtle.forward()
- turtle.turnRight()
- end
- function snake(bool)
- if bool == true then
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- else
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- end
- end
- function replaceBlock(type)
- local hasBlocks = checkSupply()
- --print(hasBlocks)
- if hasBlocks ~= false then
- if type == 1 then
- --Wall
- if turtle.detect() then
- turtle.dig()
- checkSupply()
- turtle.select(hasBlocks)
- turtle.place()
- else
- return false
- end
- elseif type == 2 then
- --Floor
- if turtle.detectDown() then
- turtle.digDown()
- checkSupply()
- turtle.select(hasBlocks)
- turtle.placeDown()
- else
- return false
- end
- elseif type == 3 then
- --Ceiling
- if turtle.detectUp() then
- turtle.digUp()
- checkSupply()
- turtle.select(hasBlocks)
- turtle.placeDown()
- else
- return false
- end
- end
- end
- end
- function moveType(type,max,count,alt)
- local counter = count
- local maxy = max
- local booly = alt
- if type == 1 then
- if booly == true then
- turtle.up()
- counter = counter + 1
- if counter == maxy + 1 then
- replaceBlock(type)
- hangAleft()
- booly = false
- end
- else
- turtle.down()
- counter = counter - 1
- if counter == 1 then
- replaceBlock(type)
- hangAleft()
- booly = true
- end
- end
- return counter,booly
- --print(count .. " / " .. reset)
- else
- turtle.forward()
- counter = counter + 1
- print(counter)
- if counter == maxy + 1 then
- replaceBlock(type)
- snake(booly)
- if booly == true then
- booly = false
- else
- booly = true
- end
- counter = 1
- end
- return counter, booly
- end
- end
- function mineMove(x,y,type)
- local num = tonumber(type)
- local reset = tonumber(x)
- local bull = true
- local count = 1
- for i=1,y,1 do
- for a=1,x,1 do
- -- print(i .. " | " .. a)
- replaceBlock(num)
- print(">>>" .. count .. " , " .. tostring(bull))
- local a,b = moveType(num,reset,count,bull)
- print(a .. " | " .. tostring(b))
- count = a
- bull = b
- print("<<<" .. count .. " , " .. tostring(bull))
- end
- end
- end
- function main()
- print("enter y:")
- local x = read()
- print("enter x:")
- local y = read()
- print("1=wall | 2=floor | 3=ceiling")
- print("enter type:")
- local type = read()
- mineMove(x,y,type)
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement