From 0837e56aba1b25b7cf9c4da4311edc71d0bcd09f Mon Sep 17 00:00:00 2001 From: Igor Timofeev Date: Fri, 15 Jun 2018 02:01:13 +0300 Subject: [PATCH] =?UTF-8?q?=D1=84=D0=B0=D1=84=D1=83=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Applications/Robot/fisherEEPROM.lua | 57 ++++++++++++----------------- 1 file changed, 23 insertions(+), 34 deletions(-) diff --git a/Applications/Robot/fisherEEPROM.lua b/Applications/Robot/fisherEEPROM.lua index 4bde7ede..99dc6476 100644 --- a/Applications/Robot/fisherEEPROM.lua +++ b/Applications/Robot/fisherEEPROM.lua @@ -1,51 +1,40 @@ - local robot = component.proxy(component.list("robot")()) local redstone = component.proxy(component.list("redstone")()) -local gpu = component.proxy(component.list("gpu")()) -local width, height = gpu.getResolution() -local tryCatchTime = 30 -local startSleepTime = 3 -local catchSleepTime = 3 -local side = 0 -local useTime = 1 - -local function print(text) - gpu.copy(1, 1, width, height, 0, -1) - gpu.set(1, height, text) -end +local tryCatchTime = 20 +local startSleepTime = 2 +local catchSleepTime = 1 +local side = 3 local function sleep(timeout) - local deadline = computer.uptime() + (timeout or 0) - while computer.uptime() < deadline do - computer.pullSignal(deadline - computer.uptime()) - end + local deadline = computer.uptime() + (timeout or 0) + while computer.uptime() < deadline do + computer.pullSignal(deadline - computer.uptime()) + end end local function pushRod() - print("Pushing rod...") - robot.use(side, true, useTime) - sleep(startSleepTime) + robot.use(side) + sleep(startSleepTime) end local function pullRod() - print("Pulling rod...") - robot.use(side, true, useTime) - sleep(catchSleepTime) + robot.use(side) + sleep(catchSleepTime) end pushRod() -while true do - local e = {computer.pullSignal(tryCatchTime)} - if e[1] == "redstone_changed" then - if e[5] == 0 then - pullRod() - pushRod() - end - elseif not e[1] then - pullRod() - pushRod() - end +while true do + local e = {computer.pullSignal(tryCatchTime)} + if e[1] == "redstone_changed" then + if e[5] == 0 then + pullRod() + pushRod() + end + elseif not e[1] then + pullRod() + pushRod() + end end