Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local r = require("robot")
- local component = require("component")
- local ge = component.geolyzer
- local x = 1
- local y = 1
- local z = 1
- local yh = 1
- local g = component.generator
- function xup()
- while x < 41 do
- scan()
- if r.swing() == true then
- repeat
- r.swing()
- until r.swing() == false
- else
- if r.forward() == true then
- x = x+1
- end
- end
- end
- end
- function xdown()
- scan()
- while x > 1 do
- if r.swing() == true then
- repeat
- r.swing()
- until r.swing() == false
- else
- if r.forward() == true then
- x = x-1
- end
- end
- end
- end
- function yup()
- scan()
- while yh < 4 do
- if r.swing() == true then
- repeat
- print("dig")
- r.swing()
- until r.swing() == false
- else
- if r.forward() == true then
- yh = yh+1
- y = y+1
- end
- end
- end
- yh = 1
- end
- function drop()
- local selectedSlot = r.select()
- r.select(1)
- r.drop(r.count() - 1)
- r.select(2)
- r.drop(r.count() - 1)
- r.select(3)
- r.drop(r.count() - 1)
- print("drop")
- end
- function scan()
- print("scan")
- if ge.analyze(1).hardness > 1.5 then
- r.swingUp(1)
- end
- if ge.analyze(0).hardness > 1.5 then
- r.swingDown(0)
- end
- if ge.analyze(4).hardness > 1.5 then
- r.turnRight()
- r.swing()
- r.turnLeft()
- end
- if ge.analyze(5).hardness > 1.5 then
- r.turnLeft()
- r.swing()
- r.turnRight()
- else
- print("pusto")
- end
- end
- -- program main
- while y < 41 do
- xup()
- r.turnRight()
- yup()
- drop()
- r.turnRight()
- xdown()
- r.turnLeft()
- yup()
- drop()
- r.turnLeft()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement