From 8ffe6dac9c177199693dfa48b0903a3c2c4bb971 Mon Sep 17 00:00:00 2001 From: erius0 <63460770+erius0@users.noreply.github.com> Date: Sat, 9 Jan 2021 20:19:34 +0300 Subject: [PATCH] Update craftCrystal.lua --- craftCrystal.lua | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/craftCrystal.lua b/craftCrystal.lua index 0c2afab..684bc48 100644 --- a/craftCrystal.lua +++ b/craftCrystal.lua @@ -1,19 +1,30 @@ local robot = require("robot") local component = require("component") local sides = require("sides") +local event = require("event") +local computer = require("computer") local rs = component.redstone local flag = false + +print("U - обновить ПО робота, E - выйти в OpenOS") + +function onKeyPressed() + local _, _, _, key, _ = event.pull(0.05, "key_down") + if key == 0x16 then + computer.shutdown(true) + elseif key == 0x12 then + os.exit() + end +end + while true do + onKeyPressed() if rs.getInput(sides.top) > 0 then - if not flag then - robot.turnAround() - flag = true - end - robot.suck() + flag = true + robot.suckUp() robot.dropDown() else if flag then - robot.turnAround() flag = false os.sleep(5) end