Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- args = {...}
- height = args[2]
- width = args[1]
- if height == nil then
- print("reed [width] height")
- return
- end
- if width == nil then
- print("reed width [height]")
- return
- end
- x = 0
- y = 0
- dir = 1
- print(height)
- print(width)
- go = turtle
- --
- -- Sjekker om vi har nok brennstoff
- --
- function checkFuel()
- print("Fuel:", go.getFuelLevel())
- level = getFuel(width * height)
- if go.getFuelLevel() < 300 then
- print("Fuel has to exceed ", 300)
- return
- end
- end
- --
- -- Dig
- --
- function dig()
- go.up()
- go.dig()
- go.down()
- go.dig()
- end
- --
- -- Forrover
- --
- function forward()
- dig()
- if go.forward() then
- y = y + dir
- end
- print(x, y)
- end
- function right()
- go.turnRight()
- go.forward()
- dig()
- go.forward()
- go.turnRight()
- dir = -1
- x = x + 2
- print(x, y)
- end
- function left()
- go.turnLeft()
- go.forward()
- dig()
- go.forward()
- go.turnLeft()
- dir = 1
- x = x + 2
- print(x, y)
- end
- function empty()
- for inv = 1, 16, 1 do
- turtle.select(inv)
- turtle.drop()
- end
- end
- function home()
- if dir == 1 then
- go.turnLeft()
- go.turnLeft()
- print("turning")
- end
- for i=0, y-1 do
- dig()
- turtle.forward()
- end
- go.turnRight()
- for i=0, x-1 do
- dig()
- turtle.forward()
- end
- go.turnLeft()
- empty()
- go.turnRight()
- go.turnRight()
- end
- checkFuel()
- for X=0, math.floor((width)/2)-1 do
- for Y=0, height-1 do
- forward()
- end
- right()
- for Y=0, height-1 do
- forward()
- end
- left()
- end
- home()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement