Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- MC Turtle Stripmining Program
- ----------------------------------------------------------
- -- Variables
- ----------------------------------------------------------
- glength = 0
- gwidth = 0
- cnt = 0
- scnt = 1
- -- Dialoge
- ----------------------------------------------------------
- write("Length: ")
- glength = tonumber(read())
- write("Width: ")
- gwidth = tonumber(read())
- -- Function: refill
- ----------------------------------------------------------
- function refill()
- for idx = 1,16 do
- turtle.select(idx)
- turtle.refuel()
- end
- turtle.select(1)
- end
- -- Function: torch (Places a Torch)
- ----------------------------------------------------------
- function torch(mode)
- turtle.select(16)
- if mode == 2 then
- turtle.place()
- else
- turtle.placeDown()
- end
- turtle.select(1)
- end
- -- Function: turn180 (Turn 180 Deg)
- ----------------------------------------------------------
- function turn180()
- turtle.turnRight()
- turtle.turnRight()
- end
- -- Function: step (Makes one digging step forward)
- ----------------------------------------------------------
- function step(mode)
- if mode == 2 then
- while turtle.detectUp() do
- turtle.digUp()
- sleep(0.5)
- end
- while turtle.detectDown() do
- turtle.digDown()
- end
- end
- while (not turtle.forward()) do
- turtle.dig()
- end
- while turtle.detectDown() do
- turtle.digDown()
- end
- while turtle.detectUp() do
- turtle.digUp()
- sleep(0.5)
- end
- end
- -- Function: halfstrip (Digs one Strip side)
- ----------------------------------------------------------
- function halfstrip(lwidth)
- flag = false
- lcnt = 1
- while (lcnt < lwidth) do
- step(2)
- lcnt = lcnt + 1
- end
- lcnt = 1
- while (lcnt < lwidth) do
- while (not turtle.back()) do
- sleep(0.5)
- end
- if (not flag) then
- torch(2)
- flag = true
- end
- lcnt = lcnt + 1
- end
- end
- -- Function: strip (Digs the complete Strip)
- ----------------------------------------------------------
- function strip(gwidth)
- turtle.turnRight()
- halfstrip(gwidth)
- turtle.turnLeft()
- turtle.turnLeft()
- halfstrip(gwidth)
- turtle.turnRight()
- end
- -- MAIN FUNCTION
- ----------------------------------------------------------
- while (cnt<glength) do
- if turtle.getFuelLevel() < 1 then
- refill()
- end
- if turtle.getFuelLevel() < 1 then
- write ("Not enough fuel!")
- return
- end
- step(1)
- if (scnt >= 3) then
- strip(gwidth)
- torch(1)
- scnt = 0
- else
- scnt = scnt + 1
- end
- cnt = cnt + 1
- end
- write ("Mission completed.")
- return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement