Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local computer = require("computer")
- local robot = require("robot")
- function forward( _steps)
- for i = 1, _steps, 1 do
- robot.forward()
- end
- end
- function mineForward( _steps)
- for i = 1, _steps, 1 do
- if robot.detect() then
- robot.swing()
- end
- robot.forward()
- end
- end
- function back( _steps)
- for i = 1, _steps, 1 do
- robot.back()
- end
- end
- function up( _steps)
- for i = 1, _steps, 1 do
- robot.up()
- end
- end
- function down( _steps)
- for i = 1, _steps, 1 do
- robot.down()
- end
- end
- function mineRow()
- while robot.detect() do
- robot.swing()
- forward(1)
- end
- end
- function left()
- robot.turnLeft()
- end
- function right()
- robot.turnRight()
- end
- function turnAround()
- robot.turnAround()
- end
- function toBottom()
- while robot.down() do
- end
- end
- function use()
- robot.use()
- end
- function energyIsFull()
- if computer.energy() >= (computer.maxEnergy() - 5) then
- return true
- else
- return false
- end
- end
- function loadEnergy()
- right()
- forward(2)
- right()
- forward(3)
- left()
- forward(1)
- left()
- up(1)
- use()
- down(1)
- while not energyIsFull() do
- end
- up(1)
- use()
- down(1)
- left()
- forward(1)
- right()
- forward(3)
- left()
- forward(2)
- right()
- end
- function mineLevel()
- x = 0
- y = 0
- while y < 16 do
- mineForward(15)
- if x == 0 then
- right()
- mineForward(1)
- right()
- x = 1
- else
- left()
- mineForward(1)
- left()
- x = 0
- end
- y = y + 1
- end
- mineForward(15)
- left()
- forward(16)
- left()
- forward(15)
- turnAround()
- end
- -- Gehe zur Startposition
- mineLevel()
- for i = 1, 7, 1 do
- up(1)
- mineLevel()
- end
- -- loadEnergy()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement