Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local strtPos={[1]=0, [2]=0, [3]=0} --x,y,z
- local curPos= {[1]=strtPos[1], [2]=strtPos[2], [3]=strtPos[3]}
- local opt1,opt2="<<<",""
- local opt=1
- function moveForw()
- local try=1
- while not turtle.forward() do
- print("I can't go forward .. try:"..try)
- sleep(1)
- try=try+1
- end
- end
- function moveBack()
- local try=1
- while not turtle.back() do
- print("I can't go back .. try:"..try)
- sleep(1)
- try=try+1
- end
- end
- function moveUp()
- local try=1
- while not turtle.up() do
- print("I can't go up .. try:"..try)
- sleep(1)
- try=try+1
- end
- curPos[2]=curPos[2]+1
- end
- function moveDown()
- local try=1
- while not turtle.down() do
- print("I can't go down .. try:"..try)
- sleep(1)
- try=try+1
- end
- curPos[2]=curPos[2]-1
- end
- function turnL()
- turtle.turnLeft()
- end
- function turnR()
- turtle.turnRight()
- end
- function turn2()
- for A=1,2 do
- turnR()
- end
- end
- function digForw()
- while turtle.detect() do
- turtle.dig()
- end
- moveForw()
- end
- function digDown()
- turtle.digDown()
- moveDown()
- end
- function digUp()
- while turtle.detectUp() do
- turtle.digUp()
- end
- moveUp()
- end
- function placeForw()
- if not turtle.detect() then
- local try=1
- while not turtle.place() do
- print("I can't place forw. a block !..Try: "..try)
- try=try+1
- sleep(1)
- end
- end
- end
- function placeUp()
- if not turtle.detectUp() then
- local try=1
- while not turtle.placeUp() do
- print("I can't place up. a block !..Try: "..try)
- try=try+1
- sleep(1)
- end
- end
- end
- function placeDown()
- if not turtle.detectDown() then
- local try=1
- while not turtle.placeDown() do
- print("I can't place down. a block !..Try: "..try)
- try=try+1
- sleep(1)
- end
- end
- end
- function selectSlot()
- for A=1,16 do
- if turtle.getItemCount(A)>12 then
- turtle.select(A)
- break
- end
- if A== 16 then
- gotoStrt()
- end
- end
- end
- function gotoStrt()
- digForw()
- turnL()
- digForw()
- while strtPos[2]~=curPos[2]+1 do
- if opt==1 then moveDown() else moveUp() end
- end
- exit()
- end
- function buildTower()
- if opt==1 then
- digUp()
- digUp()
- digForw()
- turnL()
- while not turtle.detectUp() do
- for A=1,4 do
- for B=1,3 do
- digForw()
- placeDown()
- end
- turnL()
- selectSlot()
- end
- moveUp()
- end
- else
- digDown()
- digDown()
- digForw()
- turnL()
- while not turtle.detectDown() do
- for A=1,4 do
- for B=1,3 do
- digForw()
- placeUp()
- end
- turnL()
- selectSlot()
- end
- moveDown()
- end
- end
- gotoStrt()
- end
- function prntStartScreen()
- term.clear()
- term.setCursorPos(1,1)
- print("Choose your options")
- print("A: build a tower upwards "..opt1)
- print("B: build a tower downwards "..opt2)
- term.setCursorPos(1,10)
- print("Enter: to start")
- end
- function enterOptions()
- while true do
- local check,key=os.pullEvent("key")
- if check then
- if key==keys.a then opt1="<<<" opt2="" opt=1
- elseif key==keys.b then opt1="" opt2="<<<" opt=0
- elseif key==keys.enter then
- term.clear()
- term.setCursorPos(12,5)
- print("START BUILDING")
- term.setCursorPos(12,7)
- textutils.slowPrint("..............",5)
- break
- end
- prntStartScreen()
- end
- end
- end
- prntStartScreen()
- enterOptions()
- buildTower()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement