[ Новые сообщения · Участники · Правила форума · Поиск · RSS ]
  • Страница 1 из 1
  • 1
Форум » Computer Craft & Open Computers » Open Computers » То, что не вошло в другие темы (Мусорка)
То, что не вошло в другие темы
Aleksey2093Дата: Вторник, 31.03.2015, 12:05 | Сообщение # 1
Подполковник
Группа: Администраторы
Сообщений: 116
Репутация: 0
Статус: Offline
Обязательно!!!
Код программы вставляйте под спойлер.
Сообщения без спойлера будут редактироваться, а при повторном нарушении удаляться.
 
Aleksey2093Дата: Вторник, 31.03.2015, 12:06 | Сообщение # 2
Подполковник
Группа: Администраторы
Сообщений: 116
Репутация: 0
Статус: Offline
Программа, чтобы водить овец по кругу.

Код
local robot = require("robot")
local component = component("component")
local leash = component.leash
local term = require("term")
unleash()
term.clear()
term.setCursor(1,1)
io.write("Привет, я робот! Моя задача водить этих овец по кругу")
while true do
--прем ко кругу как идиоты
for i=1,4 do os.sleep(3) robot.forward() robot.turnLeft() end
leash("bottom)
end
unleash()
 
Aleksey2093Дата: Вторник, 31.03.2015, 12:15 | Сообщение # 3
Подполковник
Группа: Администраторы
Сообщений: 116
Репутация: 0
Статус: Offline
Стрижка овец

Код
local robot = require("robot")
local component = component("component")
local term = require("term")
term.clear()
term.setCursor(1,1)
io.write("Привет, я робот! Моя задача стричь овец")

function chest()
for i=1,16 do if robot.count(i)>0 then robot.select(i) robot.dropUp() end end
end

while true do
for i=1,10 do robot.use() os.sleep(1) end
os.sleep(5) --дрыхнет еще несколько минут
if robot.count(15) then chest() end --выкинули хлам
end
 
Aleksey2093Дата: Понедельник, 06.04.2015, 21:50 | Сообщение # 4
Подполковник
Группа: Администраторы
Сообщений: 116
Репутация: 0
Статус: Offline
Зачатки программы для фермы пшеницы. Не добавлены таймеры и несколько проверок.

Код
local robot = require("robot")
local component = require("component")
local sides = require("sides")
local term = require("term")
Local geo = component.geolyzer

function sbor()
if geo.analyze(0).metadata == 4 then robot.swingDown()  
if robot.count(1)>0 then robot.select(1) robot.placeDown() end
end
end  

function seachest()
while not robot.detectUp() do
if not robot.forward() then robot.turnLeft() end
end
while robot.detectUp() and robot.detect() do robot.turnLeft() end  
robot.turnRight()
if robot.detect() then for i=1,16 do robot.select(i) robot.drop() end end
robot.turnLeft()
end

left=1
function povorot()
if left==1 then robot.turnLeft() else robot.turnRight() end  
if not robot.detect() then while not robot.forward() do end
if left==1 then robot.turnLeft() left=0 else robot.turnRight left=1 end
else seachest() end

end —закрывает функцию

while true do
if not robot.detect() then sbor() robot.forward()
else povorot() end

end
 
Aleksey2093Дата: Понедельник, 13.04.2015, 23:37 | Сообщение # 5
Подполковник
Группа: Администраторы
Сообщений: 116
Репутация: 0
Статус: Offline
Доступно только для пользователей

Завершенный вариант программы из предыдущего поста
Код
local robot = require("robot")     
local component = require("component")     
local sides = require("sides")     
local term = require("term")     
local geo = component.geolyzer     
local computer = require("computer")

function sbor()     
if geo.analyze(0).metadata == 13 or geo.analyze(0).metadate == 6 then robot.swingDown()
if robot.count(1)>0 then robot.select(1) robot.placeDown() end     
end     
end      

function seachest()     
while geo.analyze(3).name~="minecraft:chest" do
if not robot.forward() then robot.turnLeft() end     
end
for i=2,16 do robot.select(i) robot.drop() end     
os.sleep(60)
robot.turnLeft()
end

left=1     
function povorot()     
if left==1 then robot.turnLeft() else robot.turnRight() end
if not robot.detect() then while not robot.forward() do end
if left==1 then robot.turnLeft() left=0 else robot.turnRight() left=1 end
else seachest() end     

end

while true do     
while computer.energy()<10000 do os.sleep(500) end
if not robot.detect() then sbor() robot.forward()
else if not robot.forward() then povorot() end end

end

 
Форум » Computer Craft & Open Computers » Open Computers » То, что не вошло в другие темы (Мусорка)
  • Страница 1 из 1
  • 1
Поиск: