Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Librerie
- local term = require("term")
- local robot = require("robot")
- --
- -- Variabili globali
- raggio = 0
- raggioDim = 0
- scavo = true
- --
- function avanti()
- robot.forward()
- end
- function indietro()
- robot.back()
- end
- function su()
- robot.up()
- end
- function giu()
- robot.down()
- end
- function ruotaD()
- robot.turnRight()
- end
- function ruotaS()
- robot.turnLeft()
- end
- function scavaAvanti()
- robot.swing()
- end
- function scavaSotto()
- robot.swingDown()
- end
- function inizio()
- term.clear()
- print("Benvenuto! Inserisci il raggio di scavaggio: ")
- raggio = term.read()
- end
- function scava()
- scavo = true
- repeat
- if(robot.detectDown()) then
- robot.swingDown()
- end
- if(robot.detectDown()) then
- scavo = false
- break end
- if(robot.detectDown() == false) then
- giu()
- end
- raggioDim = raggio
- repeat
- local i = 0
- for r = 1, 4, 1 do
- for i = 0, raggio-2, 1 do
- if(robot.detectDown()) then
- scavaSotto()
- end
- if(robot.detect()) then
- scavaAvanti()
- avanti()
- end
- if(robot.detectDown()) then
- scavaSotto()
- end
- end
- if (raggioDim ~= 1) then ruotaD() end
- end
- raggioDim = raggioDim - 1
- until (raggioDim == 1)
- local dimezzato = math.floor(raggio/2)
- local pos = 0
- ruotaS()
- repeat
- avanti()
- pos = pos + 1
- until(pos == dimezzato)
- pos = 0
- ruotaS()
- repeat
- avanti()
- pos = pos + 1
- until(pos == dimezzato)
- ruotaS()
- ruotaS()
- scavaSotto()
- giu()
- until(scavo == false)
- end
- inizio()
- scava()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement