Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local args = {...}
- local io = require("io")
- local robot = require("robot")
- local comp = require("computer")
- local filesystem = require("filesystem")
- local r_forward = robot.forward
- local arg1 = args[1]
- local arg2 = args[2]
- function robot.forward()
- repeat os.sleep(0) until r_forward()
- return true
- end
- if (arg1 == "size") then
- if (arg2 == nil) then return print("Не указан размер") end
- local farmsize = io.open("/home/farm.cfg", "w")
- farmsize:write(arg2)
- farmsize:flush()
- farmsize:close()
- return print("Позиция установлена")
- end
- if (filesystem.exists("/home/farm.cfg") == false) then
- return print("Файл конфигурации не создан! пожалуйста используйте аргумент size *Размер поля*")
- end
- local farmsize = io.open("/home/farm.cfg")
- local size = farmsize:read()
- farmsize:close()
- function farm()
- robot.forward()
- for y = 1, size do
- -- собрать 1 линию
- robot.swingDown()
- robot.useDown()
- robot.placeDown()
- for x = 1, (size - 1) do
- robot.forward()
- robot.swingDown()
- robot.useDown()
- robot.placeDown()
- end
- -- поворот
- if y % 2 == 1 then
- robot.turnLeft()
- robot.forward()
- robot.turnLeft()
- else
- robot.turnRight()
- robot.forward()
- robot.turnRight()
- end
- end
- if(size%2 == 0) then
- robot.turnLeft()
- robot.turnLeft()
- robot.turnLeft()
- -- возвращение на базу
- for y = 1, (size - 1) do robot.forward() end
- robot.turnRight()
- robot.turnLeft()
- robot.forward()
- robot.turnRight()
- robot.forward()
- robot.turnAround()
- else
- for y = 1, (size - 1) do robot.forward() end
- robot.turnLeft()
- for y = 1, (size) do robot.forward() end
- robot.turnRight()
- robot.forward()
- robot.turnAround()
- end
- end
- function dropitem()
- robot.turnAround()
- for c = 2, 16 do
- robot.select(c)
- if robot.count() > 0 then
- robot.drop()
- else
- robot.select(1)
- break
- end
- end
- robot.turnAround()
- end
- if arg1 == "primary" then
- farm()
- if robot.count(2) == 64 then dropitem() end
- end
- local primary = nil
- while true do
- -- таймер(1час)
- for i = 1, 10 do
- os.sleep(370)
- print((10 * i) .. '%')
- end
- farm()
- if robot.count(2) == 64 then dropitem() end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement