Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Cactus farm by Fenixrus
- We must download this prorgam to your Robot, for using and run her.
- ]]--
- r = require("robot")
- slot = 1
- function need_block()
- if r.count(slot) == 0 then
- slot = slot + 1
- r.select(slot)
- end
- end
- function turnRightPlace()
- need_block()
- r.turnRight()
- r.forward()
- r.turnRight()
- r.placeDown()
- end
- function turnLeftPlace()
- need_block()
- r.turnLeft()
- r.forward()
- r.turnLeft()
- r.placeDown()
- end
- function place(count)
- r.select(slot)
- local i
- for i=1,count do
- need_block()
- r.forward()
- r.placeDown()
- end
- end
- function useDown()
- forward(3)
- r.down()
- r.useDown()
- r.turnAround()
- r.up()
- forward(3)
- r.turnRight()
- end
- function forward(count)
- for i=1,count do
- r.forward()
- end
- end
- function us_aro(count)
- forward(count)
- r.useDown()
- r.turnAround()
- forward(count)
- r.turnLeft()
- end
- function swing_forw(count)
- for i=1,count do
- r.swing()
- r.forward()
- r.swingDown()
- end
- end
- function swing_Turn_Left()
- r.turnLeft()
- r.swing()
- r.forward()
- r.swingDown()
- r.turnLeft()
- end
- function swing_Turn_Right()
- r.turnRight()
- r.swing()
- r.forward()
- r.swingDown()
- r.turnRight()
- end
- function place_cane()
- r.placeDown()
- place(7)
- turnRightPlace()
- place(7)
- end
- function gathering_Counter_Clockwise()
- swing_forw(8)
- swing_Turn_Left()
- swing_forw(7)
- for i=1,2 do
- r.turnRight()
- r.forward()
- r.swing()
- r.forward()
- r.swingDown()
- r.turnRight()
- swing_forw(7)
- swing_Turn_Left()
- swing_forw(7)
- end
- r.forward()
- r.turnAround()
- end
- function gathering_Clockwise()
- swing_forw(8)
- swing_Turn_Right()
- swing_forw(7)
- for i=1,2 do
- r.turnLeft()
- r.forward()
- r.swing()
- r.forward()
- r.swingDown()
- r.turnLeft()
- swing_forw(7)
- swing_Turn_Right()
- swing_forw(7)
- end
- r.forward()
- r.turnAround()
- end
- function build_area()
- local i
- print("Building area is start")
- r.up()
- place(10)
- turnRightPlace()
- place(9)
- turnLeftPlace()
- for i=1,5 do
- place(9)
- turnRightPlace()
- place(9)
- if i < 5 then
- turnLeftPlace()
- end
- end
- print("Building area is finish")
- end
- function build_frame()
- print("Building frame is start")
- r.up()
- r.turnRight()
- place(11)
- r.turnRight()
- place(9)
- r.turnRight()
- place(11)
- r.turnRight()
- place(9)
- print("Building frame is finish")
- end
- function build_sand()
- print("Placement of sand is start")
- slot = 4
- r.select(slot)
- r.back()
- for i=1,3 do
- r.turnRight()
- r.forward()
- r.forward()
- r.turnRight()
- r.placeDown()
- place(7)
- turnLeftPlace()
- place(7)
- end
- print("Placement of sand is finish")
- end
- function build_water()
- print("Placement of water is start")
- r.turnRight()
- r.forward()
- r.useDown()
- r.forward()
- r.turnLeft()
- useDown()
- us_aro(4)
- useDown()
- us_aro(7)
- useDown()
- us_aro(10)
- print("Placement of water is finish")
- end
- function build_cane()
- print("Placement of cane is start")
- slot = 5
- r.select(slot)
- r.up()
- r.turnLeft()
- forward(2)
- for i=1,3 do
- print(i)
- r.turnLeft()
- r.placeDown()
- place(7)
- turnRightPlace()
- place(7)
- r.turnLeft()
- if i < 3 then forward(2) end
- end
- r.turnLeft()
- r.back()
- r.up()
- print("Placement of cane is finish")
- end
- function work()
- print("Start working")
- slot = 1
- r.select(slot)
- local j = 1
- local Even = false
- while true do
- print("cycle: ",j)
- if j%2 == 0 then Even = true
- else Even = false end
- local drop = false
- if j == 4 or j == 8 then drop = true end
- if drop then
- r.down()
- for i=1,10 do
- r.select(i)
- r.dropDown()
- end
- r.up()
- slot = 1
- r.select(slot)
- end
- if r.detect() then
- if Even then
- gathering_Clockwise()
- j = j + 1
- else
- gathering_Counter_Clockwise()
- j = j + 1
- end
- end
- if j > 10 then j = 1 end
- os.sleep(60)
- end
- end
- print("Hello!")
- print("I am start building")
- build_area()
- build_frame()
- build_sand()
- build_water()
- build_cane()
- work()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement