mirror of
https://github.com/IgorTimofeev/MineOS.git
synced 2026-01-07 19:52:40 +01:00
afaef
This commit is contained in:
parent
1f3ec1db75
commit
ed4d8bc2a2
82
Applications/Robot/Commander.lua
Normal file
82
Applications/Robot/Commander.lua
Normal file
@ -0,0 +1,82 @@
|
||||
local robot = require("robot")
|
||||
local robotAPI = require("robotAPI")
|
||||
|
||||
local args = {...}
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
if #args < 0 then error("No arguments!") end
|
||||
local commands = args[1]
|
||||
|
||||
local symbols = {}
|
||||
local symbolcounter = 1
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
local function executeCommand(symbol)
|
||||
if symbol == "f" then
|
||||
robotAPI.move("forward")
|
||||
elseif symbol == "r" then
|
||||
robot.turnRight()
|
||||
print("Поворачиваюсь направо!")
|
||||
elseif symbol == "l" then
|
||||
robot.turnLeft()
|
||||
print("Поворачиваюсь налево!")
|
||||
elseif symbol == "t" then
|
||||
robot.turnAround()
|
||||
print("Крррррууу-гом!")
|
||||
elseif symbol == "u" then
|
||||
robotAPI.move("up")
|
||||
print("Поднимаюсь выше!")
|
||||
elseif symbol == "d" then
|
||||
robotAPI.move("down")
|
||||
print("Опускаюсь ниже!")
|
||||
elseif symbol == "m" then
|
||||
robotAPI.move("forward")
|
||||
robot.swing()
|
||||
print("Копаю вперед!")
|
||||
elseif symbol == "s" then
|
||||
print("Копаю впереди!", robot.swing())
|
||||
|
||||
--Вообще потная хуйня, но работает, епта!
|
||||
elseif tonumber(symbol) ~= nil then
|
||||
local startNumber = symbol
|
||||
local counter = 1
|
||||
for i = (symbolcounter + 1), #symbols do
|
||||
local newNumber = tonumber(symbols[i])
|
||||
if newNumber then
|
||||
startNumber = startNumber .. symbols[i]
|
||||
counter = counter + 1
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
startNumber = tonumber(startNumber)
|
||||
|
||||
print("Выполняю "..startNumber.." раз команду "..symbols[symbolcounter + counter])
|
||||
for i = 1, startNumber do
|
||||
executeCommand(symbols[symbolcounter + counter])
|
||||
end
|
||||
|
||||
symbolcounter = symbolcounter + counter
|
||||
end
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------
|
||||
|
||||
for i = 1, #commands do
|
||||
table.insert(symbols, string.sub(commands, i, i))
|
||||
end
|
||||
|
||||
print(" ")
|
||||
print("Начинаю работать!")
|
||||
print(" ")
|
||||
|
||||
while symbolcounter <= #symbols do
|
||||
executeCommand(symbols[symbolcounter])
|
||||
symbolcounter = symbolcounter + 1
|
||||
end
|
||||
|
||||
print(" ")
|
||||
print("Работа завершена!")
|
||||
print(" ")
|
||||
31
Applications/Robot/HorizontalLazer.lua
Normal file
31
Applications/Robot/HorizontalLazer.lua
Normal file
@ -0,0 +1,31 @@
|
||||
local robot = require("robot")
|
||||
local component = require("component")
|
||||
local robotAPI = require("robotAPI")
|
||||
local inventory = component.inventory_controller
|
||||
|
||||
local args = { ... }
|
||||
if #args < 2 then print(" "); print("Использование: laser <длина> <ширина>"); print(" "); return end
|
||||
|
||||
local width = tonumber(args[2])
|
||||
local length = tonumber(args[1])
|
||||
|
||||
for w = 1, width/2 do
|
||||
for h = 1, length do
|
||||
robot.useDown()
|
||||
if h < length then robotAPI.move("forward") end
|
||||
end
|
||||
|
||||
robot.turnRight()
|
||||
robotAPI.move("forward")
|
||||
robot.turnRight()
|
||||
|
||||
for h = 1, length do
|
||||
robot.useDown()
|
||||
if h < length then robotAPI.move("forward") end
|
||||
end
|
||||
|
||||
robot.turnLeft()
|
||||
robotAPI.move("forward")
|
||||
robot.turnLeft()
|
||||
end
|
||||
|
||||
2
Applications/Robot/Installer.lua
Normal file
2
Applications/Robot/Installer.lua
Normal file
@ -0,0 +1,2 @@
|
||||
local shell = require("shell")
|
||||
|
||||
@ -6,13 +6,13 @@ local inventory = component.inventory_controller
|
||||
local args = { ... }
|
||||
if #args < 2 then print(" "); print("Использование: laser <ширина> <высота>"); print(" "); return end
|
||||
|
||||
local width = args[1]
|
||||
local height = args[2]
|
||||
local width = tonumber(args[1])
|
||||
local height = tonumber(args[2])
|
||||
|
||||
for w = 1, width/2 do
|
||||
for h = 1, height do
|
||||
robot.use()
|
||||
robotAPI.move("up")
|
||||
if h < height then robotAPI.move("up") end
|
||||
end
|
||||
|
||||
robot.turnRight()
|
||||
@ -20,8 +20,8 @@ for w = 1, width/2 do
|
||||
robot.turnLeft()
|
||||
|
||||
for h = 1, height do
|
||||
robotAPI.move("down")
|
||||
robot.use()
|
||||
if h < height then robotAPI.move("down") end
|
||||
end
|
||||
|
||||
robot.turnRight()
|
||||
@ -29,11 +29,3 @@ for w = 1, width/2 do
|
||||
robot.turnLeft()
|
||||
end
|
||||
|
||||
robot.turnLeft()
|
||||
|
||||
for w = 1, width do
|
||||
robotAPI.move("forward")
|
||||
end
|
||||
|
||||
robot.turnRight()
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user