Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Запускает команду/скрипт при ребуте пк
- -- Поместите в /autorun.lua
- local StartTime = 5
- local ScriptPath = "/home/start.lua"
- --————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————--
- local event = require("event")
- local component = require("component")
- local process = require("process")
- local gpu, screen = component.gpu, component.screen
- require("term").clear()
- print("Запуск программы произойдёт через ".. StartTime .." секунд")
- print("Нажмите любую клавишу что-бы отменить запуск.")
- for i = 1, StartTime / 0.01 do
- local eventType = event.pull(0)
- if eventType == "key_down" then
- print("Отмена запуска программы!")
- return
- end
- end
- os.execute(ScriptPath)
- event.timer(10, function()
- if gpu.getScreen() ~= screen.address then -- на многих серверах экраны тупо дохнут и их приходиться переподключать
- gpu.bind(screen.address)
- end
- if (process.running()) ~= ScriptPath then -- то-же костыль. компы кривая штука, порой софт с бесконечным циклом сам по себе завершает работу
- os.execute(ScriptPath)
- end
- end, math.huge)
Add Comment
Please, Sign In to add comment