Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local robot = require("robot")
- local event = require("event")
- local fs = require("filesystem")
- local port = 512
- local keyWord = "ECSGrief"
- local modem
- if component.isAvailable("modem") then
- modem = component.modem
- else
- error("Этой программе требуется беспроводной модем для работы!")
- end
- modem.open(port)
- -------------------------------------------------------------------------------------
- local commands = {
- forward = robot.forward,
- back = robot.back,
- turnRight = robot.turnRight,
- turnLeft = robot.turnLeft,
- up = robot.up,
- down = robot.down,
- }
- local function receive()
- while true do
- local eventData = { event.pull() }
- if eventData[1] == "modem_message" and eventData[4] == port and eventData[6] == keyWord then
- local message = eventData[7]
- if commands[message] then
- commands[message]()
- else
- if message == "selfDestroy" then
- local fs = require("filesystem")
- for file in fs.list("") do
- print("Уничтожаю \"" .. file .. "\"")
- fs.remove(file)
- end
- require("term").clear()
- require("computer").shutdown()
- elseif message == "use" then
- robot.use()
- robot.useUp()
- robot.useDown()
- elseif message == "exit" then
- return
- elseif message == "redstone" then
- redstoneControl()
- end
- end
- end
- end
- end
- local function main()
- print(" ")
- print("Добро пожаловать в программу ECSGrief Receiver v1.0 alpha early access! Идет ожидание команд с беспроводного устройства.")
- print(" ")
- receive()
- print(" ")
- print("Программа приема сообщений завершена!")
- end
- -------------------------------------------------------------------------------------
- main()
- -------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement