mirror of
https://github.com/IgorTimofeev/MineOS.git
synced 2026-01-10 05:02:40 +01:00
фафуа
This commit is contained in:
parent
7c5313fbe9
commit
0837e56aba
@ -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
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user