Diff
checker
テキスト
テキスト
画像
ドキュメント
Excel
フォルダ
Legal
Enterprise
デスクトップ
料金
ログイン
Diffchecker デスクトップのダウンロード
テキスト比較
2 つのテキスト ファイルの違いを見つける
ツール
履歴
ライブエディター
空白の変更を非表示
未変更行を折りたたむ
折り返しなし
レイアウト
分割
統合
比較精度
スマート
単語
文字
テキストスタイル
外観を変更
シンタックスハイライト
構文を選択
無視
テキスト変換
最初の差分へ移動
入力を編集
Diffchecker Desktop
Diffcheckerを実行する最も安全な方法。Diffchecker Desktopアプリを入手:あなたの差分はコンピューターから出ることはありません!
Desktopを入手
What the fuck
作成日
4 年前
差分は期限切れになりません
クリア
エクスポート
共有
説明
16 削除
行
合計
削除
文字
合計
削除
この機能を引き続き使用するには、アップグレードしてください
Diff
checker
Pro
価格を見る
481 行
すべてコピー
21 追加
行
合計
追加
文字
合計
追加
この機能を引き続き使用するには、アップグレードしてください
Diff
checker
Pro
価格を見る
486 行
すべてコピー
コピー
コピー済み
コピー
コピー済み
--- useless рекавери
--- Я не ответчаю за кирпич биос/ I dont ask about brick bios
-- Downloadable module with recovery tools
local component, computer, unicode, math, bootFiles, bootCandidates, keys, userChecked, width, height, gpu, screen, redraw, lines = component, computer, unicode, math, {"/init.lua", "/OS.lua"}, {}, {}
local component, computer, unicode, math, bootFiles, bootCandidates, keys, userChecked, width, height, gpu, screen, redraw, lines = component, computer, unicode, math, {"/init.lua", "/OS.lua"}, {}, {}
local function pullSignal(timeout)
local function pullSignal(timeout)
local signal = {computer.pullSignal(timeout)}
local signal = {computer.pullSignal(timeout)}
signal[1] = signal[1] or ""
signal[1] = signal[1] or ""
if cyan and ( signal[1]:match("ey") and not cyan:match(signal[5]) or signal[1]:match("cl") and not cyan:match(signal[4]) ) then
if cyan and ( signal[1]:match("ey") and not cyan:match(signal[5]) or signal[1]:match("cl") and not cyan:match(signal[4]) ) then
return ""
return ""
end
end
keys[signal[4] or ""] = signal[1]:match"do" and 1
keys[signal[4] or ""] = signal[1]:match"do" and 1
return table.unpack(keys[29] and (keys[46] or keys[32]) and signal[1]:match"do" and {"F"} or signal)
return table.unpack(keys[29] and (keys[46] or keys[32]) and signal[1]:match"do" and {"F"} or signal)
end
end
local function proxy(componentType)
local function proxy(componentType)
return component.list(componentType)() and component.proxy(component.list(componentType)())
return component.list(componentType)() and component.proxy(component.list(componentType)())
end
end
local function split(text, tabulate)
local function split(text, tabulate)
lines = {}
lines = {}
for line in text:gmatch"[^\r\n]+" do
for line in text:gmatch"[^\r\n]+" do
lines[#lines + 1] = line:gsub("\t", tabulate and " " or "")
lines[#lines + 1] = line:gsub("\t", tabulate and " " or "")
end
end
end
end
local function sleep(timeout, breakCode, onBreak, deadline, signalType, code, _)
local function sleep(timeout, breakCode, onBreak, deadline, signalType, code, _)
deadline = computer.uptime() + (timeout or math.huge)
deadline = computer.uptime() + (timeout or math.huge)
::LOOP::
::LOOP::
signalType, _, _, code = pullSignal(deadline - computer.uptime())
signalType, _, _, code = pullSignal(deadline - computer.uptime())
if signalType == "F" or signalType:match"do" and (code == breakCode or breakCode == 0) then
if signalType == "F" or signalType:match"do" and (code == breakCode or breakCode == 0) then
return 1, onBreak and onBreak()
return 1, onBreak and onBreak()
elseif computer.uptime() < deadline then
elseif computer.uptime() < deadline then
goto LOOP
goto LOOP
end
end
end
end
local function set(x, y, string, background, foreground)
local function set(x, y, string, background, foreground)
gpu.setBackground(background or 0x002b36)
gpu.setBackground(background or 0x002b36)
gpu.setForeground(foreground or 0x8cb9c5)
gpu.setForeground(foreground or 0x8cb9c5)
gpu.set(x, y, string)
gpu.set(x, y, string)
end
end
local function fill(x, y, w, h, background, foreground)
local function fill(x, y, w, h, background, foreground)
gpu.setBackground(background or 0x002b36)
gpu.setBackground(background or 0x002b36)
gpu.setForeground(foreground or 0x8cb9c5)
gpu.setForeground(foreground or 0x8cb9c5)
gpu.fill(x, y, w, h, " ")
gpu.fill(x, y, w, h, " ")
end
end
local function clear()
local function clear()
fill(1, 1, width, height)
fill(1, 1, width, height)
end
end
local function centrize(len)
local function centrize(len)
return math.floor(width / 2 - len / 2)
return math.floor(width / 2 - len / 2)
end
end
local function centrizedSet(y, text, background, foreground)
local function centrizedSet(y, text, background, foreground)
set(centrize(unicode.len(text)), y, text, background, foreground)
set(centrize(unicode.len(text)), y, text, background, foreground)
end
end
local function rebindGPU()
local function rebindGPU()
gpu, screen = proxy"gp", proxy"sc"
gpu, screen = proxy"gp", proxy"sc"
if gpu.getScreen() ~= screen.address then
if gpu.getScreen() ~= screen.address then
gpu.bind((screen.address))
gpu.bind((screen.address))
end
end
gpu.setPaletteColor(9, 0x002b36)
gpu.setPaletteColor(9, 0x002b36)
gpu.setPaletteColor(11, 0x8cb9c5)
gpu.setPaletteColor(11, 0x8cb9c5)
local aspectWidth, aspectHeight, proportion = screen.getAspectRatio()
local aspectWidth, aspectHeight, proportion = screen.getAspectRatio()
width, height = gpu.maxResolution()
width, height = gpu.maxResolution()
if not proxy"able" then
if not proxy"able" then
proportion = 2*(16*aspectWidth-4.5)/(16*aspectHeight-4.5)
proportion = 2*(16*aspectWidth-4.5)/(16*aspectHeight-4.5)
height = proportion > width / height and math.floor(width / proportion) or height
height = proportion > width / height and math.floor(width / proportion) or height
width = math.floor(height * proportion)
width = math.floor(height * proportion)
end
end
gpu.setResolution(width, height)
gpu.setResolution(width, height)
end
end
local function status(text, title, wait, breakCode, onBreak, y)
local function status(text, title, wait, breakCode, onBreak, y)
clear()
clear()
split(text)
split(text)
y = math.ceil(height / 2 - #lines / 2)
y = math.ceil(height / 2 - #lines / 2)
if title then
if title then
centrizedSet(y - 1, title, 0x002b36, 0xffffff)
centrizedSet(y - 1, title, 0x002b36, 0xffffff)
y = y + 1
y = y + 1
end
end
for i = 1, #lines do
for i = 1, #lines do
centrizedSet(y, lines[i])
centrizedSet(y, lines[i])
y = y + 1
y = y + 1
end
end
sleep(wait or 0, breakCode or 0, onBreak)
sleep(wait or 0, breakCode or 0, onBreak)
end
end
local function cutText(text, maxLength)
local function cutText(text, maxLength)
return unicode.len(text) > maxLength and unicode.sub(text, 1, maxLength) .. "…" or text
return unicode.len(text) > maxLength and unicode.sub(text, 1, maxLength) .. "…" or text
end
end
local function input(prefix, y, centrized, historyText, foreground)
local function input(prefix, y, centrized, historyText, foreground)
local text, prefixLen, cursorPos, cursorState, cursorX, x, signalType, char, code, _ = "", unicode.len(prefix), 1, 1
local text, prefixLen, cursorPos, cursorState, cursorX, x, signalType, char, code, _ = "", unicode.len(prefix), 1, 1
foreground = foreground or 0x8cb9c5
foreground = foreground or 0x8cb9c5
::LOOP::
::LOOP::
x = centrized and centrize(unicode.len(text) + prefixLen) or 1
x = centrized and centrize(unicode.len(text) + prefixLen) or 1
cursorX = x + prefixLen + cursorPos - 1
cursorX = x + prefixLen + cursorPos - 1
fill(1, y, width, 1)
fill(1, y, width, 1)
set(x, y, prefix .. text, F, foreground)
set(x, y, prefix .. text, F, foreground)
if cursorX <= width then
if cursorX <= width then
set(cursorX, y, gpu.get(cursorX, y), cursorState and foreground or 0x002b36, cursorState and 0x002b36 or foreground)
set(cursorX, y, gpu.get(cursorX, y), cursorState and foreground or 0x002b36, cursorState and 0x002b36 or foreground)
end
end
signalType, _, char, code = pullSignal(.5)
signalType, _, char, code = pullSignal(.5)
if signalType:match"do" then
if signalType:match"do" then
if code == 203 and cursorPos > 1 then
if code == 203 and cursorPos > 1 then
cursorPos = cursorPos - 1
cursorPos = cursorPos - 1
elseif code == 205 and cursorPos <= unicode.len(text) then
elseif code == 205 and cursorPos <= unicode.len(text) then
cursorPos = cursorPos + 1
cursorPos = cursorPos + 1
elseif code == 200 and historyText then
elseif code == 200 and historyText then
text = historyText
text = historyText
cursorPos = unicode.len(historyText) + 1
cursorPos = unicode.len(historyText) + 1
elseif code == 208 and historyText then
elseif code == 208 and historyText then
text = ""
text = ""
cursorPos = 1
cursorPos = 1
elseif code == 14 and #text > 0 and cursorPos > 1 then
elseif code == 14 and #text > 0 and cursorPos > 1 then
text = keys[29] and "" or unicode.sub(unicode.sub(text, 1, cursorPos - 1), 1, -2) .. unicode.sub(text, cursorPos, -1)
text = keys[29] and "" or unicode.sub(unicode.sub(text, 1, cursorPos - 1), 1, -2) .. unicode.sub(text, cursorPos, -1)
cursorPos = keys[29] and 1 or cursorPos - 1
cursorPos = keys[29] and 1 or cursorPos - 1
elseif code == 28 then
elseif code == 28 then
return text
return text
elseif char >= 32 and unicode.len(prefixLen .. text) < width - prefixLen then
elseif char >= 32 and unicode.len(prefixLen .. text) < width - prefixLen then
text = unicode.sub(text, 1, cursorPos - 1) .. unicode.char(char) .. unicode.sub(text, cursorPos, -1)
text = unicode.sub(text, 1, cursorPos - 1) .. unicode.char(char) .. unicode.sub(text, cursorPos, -1)
cursorPos = cursorPos + 1
cursorPos = cursorPos + 1
end
end
cursorState = 1
cursorState = 1
elseif signalType:match"cl" then
elseif signalType:match"cl" then
text = unicode.sub(text, 1, cursorPos - 1) .. char .. unicode.sub(text, cursorPos, -1)
text = unicode.sub(text, 1, cursorPos - 1) .. char .. unicode.sub(text, cursorPos, -1)
cursorPos = cursorPos + unicode.len(char)
cursorPos = cursorPos + unicode.len(char)
elseif signalType:match"mp" or signalType == "F" then
elseif signalType:match"mp" or signalType == "F" then
redraw = signalType:match"mp" and 1
redraw = signalType:match"mp" and 1
return
return
elseif not signalType:match"up" then
elseif not signalType:match"up" then
cursorState = not cursorState
cursorState = not cursorState
end
end
goto LOOP
goto LOOP
end
end
local function execute(code, stdin, env, palette, call)
local function execute(code, stdin, env, palette, call)
call = call or xpcall
call = call or xpcall
local chunk, err = load("return " .. code, stdin, F, env)
local chunk, err = load("return " .. code, stdin, F, env)
if not chunk then
if not chunk then
chunk, err = load(code, stdin, F, env)
chunk, err = load(code, stdin, F, env)
end
end
if chunk then
if chunk then
if palette and gpu then
if palette and gpu then
sleep(.3)
sleep(.3)
fill(1, 1, width or 0, height or 0, 0)
fill(1, 1, width or 0, height or 0, 0)
gpu.setPaletteColor(9, 0x969696)
gpu.setPaletteColor(9, 0x969696)
gpu.setPaletteColor(11, 0xb4b4b4)
gpu.setPaletteColor(11, 0xb4b4b4)
end
end
return call(chunk, debug.traceback)
return call(chunk, debug.traceback)
end
end
return F, err
return F, err
end
end
local function addCandidate(address)
local function addCandidate(address)
local proxy, allBootFiles, bootFile, i = component.proxy(address), {s = 1, z = 1}
local proxy, allBootFiles, bootFile, i = component.proxy(address), {s = 1, z = 1}
if proxy and address ~= computer.tmpAddress() then
if proxy and address ~= computer.tmpAddress() then
i = #bootCandidates + 1
i = #bootCandidates + 1
bootCandidates[i] = {
bootCandidates[i] = {
r = proxy,
r = proxy,
l = allBootFiles,
l = allBootFiles,
d = proxy,
d = proxy,
p = function(booting, y)
p = function(booting, y)
booting = booting and clear() or booting
booting = booting and clear() or booting
centrizedSet(y or height / 2,
centrizedSet(y or height / 2,
コピー
コピー済み
コピー
コピー済み
booting and ("
Booting
%s
from
%s (%s)"):format(
booting and ("
Загрузка
%s
Из
%s (%s)"):format(
bootFile,
bootFile,
proxy.getLabel() or "N/A",
proxy.getLabel() or "N/A",
cutText(address, width > 80 and 36 or 6)
cutText(address, width > 80 and 36 or 6)
) or bootFile and ("Boot%s %s (%s)"):format(
) or bootFile and ("Boot%s %s (%s)"):format(
(#allBootFiles == 1 and " " .. bootFile or "") .. " from",
(#allBootFiles == 1 and " " .. bootFile or "") .. " from",
proxy.getLabel() or "N/A",
proxy.getLabel() or "N/A",
cutText(address, 6)
cutText(address, 6)
) or ("Boot from %s (%s) isn't available"):format(
) or ("Boot from %s (%s) isn't available"):format(
proxy.getLabel() or "N/A",
proxy.getLabel() or "N/A",
cutText(address, 6)
cutText(address, 6)
)
)
, F, not booting and 0xffffff)
, F, not booting and 0xffffff)
コピー
コピー済み
コピー
コピー済み
booting = booting and not userChecked and cyan and (cyan:match("+") and pcall(status, "
Hold ENTER to boot
", F, math.huge, 28))
booting = booting and not userChecked and cyan and (cyan:match("+") and pcall(status, "
Зажмите Enter чтобы зайти в систему
", F, math.huge, 28))
end
end
}
}
bootCandidates[i].b = function()
bootCandidates[i].b = function()
if bootFile then
if bootFile then
local handle, data, chunk, success, err = proxy.open(bootFile, "r"), ""
local handle, data, chunk, success, err = proxy.open(bootFile, "r"), ""
::LOOP::
::LOOP::
chunk = proxy.read(handle, math.huge)
chunk = proxy.read(handle, math.huge)
if chunk then
if chunk then
data = data .. chunk
data = data .. chunk
goto LOOP
goto LOOP
end
end
proxy.close(handle)
proxy.close(handle)
pcall(bootCandidates[i].p, 1)
pcall(bootCandidates[i].p, 1)
chunk = computer.getBootAddress() ~= address and computer.setBootAddress(address)
chunk = computer.getBootAddress() ~= address and computer.setBootAddress(address)
success, err = execute(data, "=" .. bootFile, F, 1)
success, err = execute(data, "=" .. bootFile, F, 1)
success = success and pcall(computer.shutdown)
success = success and pcall(computer.shutdown)
pcall(rebindGPU)
pcall(rebindGPU)
コピー
コピー済み
コピー
コピー済み
pcall(status, err, "
¯\\_(ツ)_/¯
", math.huge, 0, computer.shutdown)
pcall(status, err, "
А ЗАЧЕМ ЛОМАТЬ :)
", math.huge, 0, computer.shutdown)
error(err)
error(err)
end
end
end
end
for j = 1, #bootFiles do
for j = 1, #bootFiles do
if proxy.exists(bootFiles[j]) then
if proxy.exists(bootFiles[j]) then
bootFile = bootFile or bootFiles[j]
bootFile = bootFile or bootFiles[j]
allBootFiles[#allBootFiles + 1] = {
allBootFiles[#allBootFiles + 1] = {
bootFiles[j],
bootFiles[j],
function()
function()
bootFile = bootFiles[j]
bootFile = bootFiles[j]
bootCandidates[i].b()
bootCandidates[i].b()
end
end
}
}
end
end
end
end
end
end
end
end
local function updateCandidates()
local function updateCandidates()
bootCandidates = {}
bootCandidates = {}
addCandidate(computer.getBootAddress() or "")
addCandidate(computer.getBootAddress() or "")
for address in next, component.list"file" do
for address in next, component.list"file" do
addCandidate(address ~= computer.getBootAddress() and address or "")
addCandidate(address ~= computer.getBootAddress() and address or "")
end
end
end
end
local function drawElements(elements, y, spaces, borderHeight, drawSelected, onDraw)
local function drawElements(elements, y, spaces, borderHeight, drawSelected, onDraw)
local elementsLineLength, x = 0
local elementsLineLength, x = 0
for i = 1, #elements do
for i = 1, #elements do
elementsLineLength = elementsLineLength + unicode.len(elements[i][1]) + spaces
elementsLineLength = elementsLineLength + unicode.len(elements[i][1]) + spaces
end
end
elementsLineLength = elementsLineLength - spaces
elementsLineLength = elementsLineLength - spaces
x = centrize(elementsLineLength)
x = centrize(elementsLineLength)
if onDraw then
if onDraw then
onDraw()
onDraw()
end
end
for i = 1, #elements do
for i = 1, #elements do
if elements.s == i and drawSelected then
if elements.s == i and drawSelected then
fill(x - spaces / 2, y - math.floor(borderHeight / 2), unicode.len(elements[i][1]) + spaces, borderHeight, 0x8cb9c5)
fill(x - spaces / 2, y - math.floor(borderHeight / 2), unicode.len(elements[i][1]) + spaces, borderHeight, 0x8cb9c5)
set(x, y, elements[i][1], 0x8cb9c5, 0x002b36)
set(x, y, elements[i][1], 0x8cb9c5, 0x002b36)
else
else
set(x, y, elements[i][1], 0x002b36, 0x8cb9c5)
set(x, y, elements[i][1], 0x002b36, 0x8cb9c5)
end
end
x = x + unicode.len(elements[i][1]) + spaces
x = x + unicode.len(elements[i][1]) + spaces
end
end
end
end
local function shell(env, data, str, text)
local function shell(env, data, str, text)
clear()
clear()
env = setmetatable({
env = setmetatable({
print = function(...)
print = function(...)
text = table.pack(...)
text = table.pack(...)
for i = 1, text.n do
for i = 1, text.n do
if type(text[i]):match"able" then
if type(text[i]):match"able" then
str = ''
str = ''
for k, v in pairs(text[i]) do
for k, v in pairs(text[i]) do
str = str .. tostring(k) .. " " .. tostring(v) .. "\n"
str = str .. tostring(k) .. " " .. tostring(v) .. "\n"
end
end
text[i] = str
text[i] = str
end
end
text[i] = tostring(text[i])
text[i] = tostring(text[i])
end
end
split(table.concat(text, " "), 1)
split(table.concat(text, " "), 1)
for i = 1, #lines do
for i = 1, #lines do
gpu.copy(1, 1, width, height - 1, 0, -1)
gpu.copy(1, 1, width, height - 1, 0, -1)
fill(1, height - 1, width, 1)
fill(1, height - 1, width, 1)
set(1, height - 1, lines[i])
set(1, height - 1, lines[i])
end
end
end,
end,
proxy = proxy,
proxy = proxy,
sleep = function(timeout)
sleep = function(timeout)
sleep(timeout, 32, error)
sleep(timeout, 32, error)
end
end
}, {__index = _G})
}, {__index = _G})
::LOOP::
::LOOP::
data = input("> ", height, F, data, 0xffffff, env)
data = input("> ", height, F, data, 0xffffff, env)
if data then
if data then
env.print("> " .. data)
env.print("> " .. data)
fill(1, height, width, 1)
fill(1, height, width, 1)
set(1, height, ">")
set(1, height, ">")
env.print(select(2, execute(data, "=shell", env)))
env.print(select(2, execute(data, "=shell", env)))
goto LOOP
goto LOOP
end
end
end
end
local function bootloader()
local function bootloader()
userChecked = 1, not gpu and error"No drives available"
userChecked = 1, not gpu and error"No drives available"
::UPDATE::
::UPDATE::
local elementsBootables, correction, elementsPrimary, selectedElements, signalType, code, newLabel, url, y, drive, bootingEntry, update, _ = {s = 1}
local elementsBootables, correction, elementsPrimary, selectedElements, signalType, code, newLabel, url, y, drive, bootingEntry, update, _ = {s = 1}
elementsPrimary = {
elementsPrimary = {
s = 1,
s = 1,
p = 1,
p = 1,
{"Halt", computer.shutdown},
{"Halt", computer.shutdown},
{"Shell", shell},
{"Shell", shell},
コピー
コピー済み
コピー
コピー済み
proxy"net" and {"
Netboot
", function()
proxy"net" and {"
Загрузка из интернета
", function()
clear()
clear()
コピー
コピー済み
コピー
コピー済み
centrizedSet(height / 2 - 1, "
Netboot
", F, 0xffffff)
centrizedSet(height / 2 - 1, "
Загрузка из интернета
", F, 0xffffff)
url = input("URL: ", height / 2 + 1, 1, F, 0x8cb9c5)
url = input("URL: ", height / 2 + 1, 1, F, 0x8cb9c5)
if url and #url > 0 then
if url and #url > 0 then
コピー
コピー済み
コピー
コピー済み
local handle, data, chunk = proxy"net".request(url, F, F, {["user-agent"]="
Netboot
"}), ""
local handle, data, chunk = proxy"net".request(url, F, F, {["user-agent"]="
Загрузка из интернета
"}), ""
if handle then
if handle then
コピー
コピー済み
コピー
コピー済み
status("Downloading script...",
"Netboot
")
status("Downloading script...",
Загрузка из Интернета
")
::LOOP::
::LOOP::
chunk = handle.read()
chunk = handle.read()
if chunk then
if chunk then
data = data .. chunk
data = data .. chunk
goto LOOP
goto LOOP
end
end
data = select(2, execute(data, "=stdin", F, 1, pcall)) or ""
data = select(2, execute(data, "=stdin", F, 1, pcall)) or ""
pcall(rebindGPU)
pcall(rebindGPU)
コピー
コピー済み
コピー
コピー済み
pcall(status, data, "
Netboot
", #data == 0 and 0 or math.huge)
pcall(status, data, "
Загрузка из интернета
", #data == 0 and 0 or math.huge)
else
else
コピー
コピー済み
コピー
コピー済み
status("Invalid URL", "
Netboot
", math.huge)
status("Invalid URL", "
Загрузка из интернета
", math.huge)
end
end
end
end
end}
end}
}
}
correction = #elementsPrimary + 1
correction = #elementsPrimary + 1
redraw = F
redraw = F
bootingEntry = F
bootingEntry = F
function update()
function update()
updateCandidates()
updateCandidates()
for i = 1, #bootCandidates do
for i = 1, #bootCandidates do
elementsBootables[i] = {
elementsBootables[i] = {
cutText(bootCandidates[i].d.getLabel() or "N/A", 6),
cutText(bootCandidates[i].d.getLabel() or "N/A", 6),
function()
function()
if #bootCandidates[i].l > 0 then
if #bootCandidates[i].l > 0 then
bootingEntry = i
bootingEntry = i
selectedElements = bootCandidates[bootingEntry].l
selectedElements = bootCandidates[bootingEntry].l
if #selectedElements == 1 then
if #selectedElements == 1 then
selectedElements[1][2]()
selectedElements[1][2]()
end
end
end
end
end
end
}
}
end
end
end
end
update()
update()
selectedElements = #bootCandidates > 0 and elementsBootables or elementsPrimary
selectedElements = #bootCandidates > 0 and elementsBootables or elementsPrimary
::LOOP::
::LOOP::
pcall(function()
pcall(function()
clear()
clear()
if selectedElements.z then
if selectedElements.z then
centrizedSet(height / 2 - 2, "Select boot entry", F, 0xffffff)
centrizedSet(height / 2 - 2, "Select boot entry", F, 0xffffff)
drawElements(selectedElements, height / 2 + 2, 6, 3, 1)
drawElements(selectedElements, height / 2 + 2, 6, 3, 1)
else
else
y = height / 2 - (#bootCandidates > 0 and -1 or 1)
y = height / 2 - (#bootCandidates > 0 and -1 or 1)
drawElements(elementsBootables, y - 4, 8, 3, not selectedElements.p and 1, function()
drawElements(elementsBootables, y - 4, 8, 3, not selectedElements.p and 1, function()
if #bootCandidates > 0 then
if #bootCandidates > 0 then
drive = bootCandidates[elementsBootables.s].r
drive = bootCandidates[elementsBootables.s].r
bootCandidates[elementsBootables.s].p(F, y + 3)
bootCandidates[elementsBootables.s].p(F, y + 3)
centrizedSet(y + 5, ("Storage %s%% / %s / %s"):format(
centrizedSet(y + 5, ("Storage %s%% / %s / %s"):format(
math.floor(drive.spaceUsed() / (drive.spaceTotal() / 100)),
math.floor(drive.spaceUsed() / (drive.spaceTotal() / 100)),
drive.isReadOnly() and "Read only" or "Read & Write",
drive.isReadOnly() and "Read only" or "Read & Write",
drive.spaceTotal() < 2 ^ 20 and "FDD" or drive.spaceTotal() < 2 ^ 20 * 12 and "HDD" or "RAID")
drive.spaceTotal() < 2 ^ 20 and "FDD" or drive.spaceTotal() < 2 ^ 20 * 12 and "HDD" or "RAID")
)
)
for i = correction, #elementsPrimary do
for i = correction, #elementsPrimary do
elementsPrimary[i] = F
elementsPrimary[i] = F
end
end
コピー
コピー済み
コピー
コピー済み
elementsPrimary[correction] = {"
Rename
", function()
elementsPrimary[correction] = {"
Переменовать
", function()
clear()
clear()
コピー
コピー済み
コピー
コピー済み
centrizedSet(height / 2 - 1, "
Rename
", F, 0xffffff)
centrizedSet(height / 2 - 1, "
Переменовать
", F, 0xffffff)
newLabel = input("
Enter new name
: ", height / 2 + 1, 1, F, 0x8cb9c5)
newLabel = input("
Введите новое имя
: ", height / 2 + 1, 1, F, 0x8cb9c5)
if newLabel and #newLabel > 0 and pcall(drive.setLabel, newLabel) then
if newLabel and #newLabel > 0 and pcall(drive.setLabel, newLabel) then
drive.setLabel(newLabel)
drive.setLabel(newLabel)
update()
update()
end
end
end}
end}
if not drive.isReadOnly() then
if not drive.isReadOnly() then
コピー
コピー済み
コピー
コピー済み
elementsPrimary[correction + 1] = {"
Format
", function()
elementsPrimary[correction + 1] = {"
Форматировать
", function()
drive.remove("/")
drive.remove("/")
drive.setLabel(F)
drive.setLabel(F)
update()
update()
end}
end}
end
end
else
else
centrizedSet(y + 3, "No drives available", F, 0xffffff)
centrizedSet(y + 3, "No drives available", F, 0xffffff)
end
end
end)
end)
drawElements(elementsPrimary, y, 6, 1, selectedElements.p and 1 or F)
drawElements(elementsPrimary, y, 6, 1, selectedElements.p and 1 or F)
end
end
end)
end)
if signalType and signalType:match"mp" or redraw then
if signalType and signalType:match"mp" or redraw then
pcall(rebindGPU)
pcall(rebindGPU)
goto UPDATE
goto UPDATE
end
end
signalType, _, _, code = pullSignal()
signalType, _, _, code = pullSignal()
_ = signalType == "F" and computer.shutdown()
_ = signalType == "F" and computer.shutdown()
if signalType:match"do" and gpu and screen then -- if you read this message please help they they forced me to do this
if signalType:match"do" and gpu and screen then -- if you read this message please help they they forced me to do this
selectedElements = (code == 200 or code == 208) and (
selectedElements = (code == 200 or code == 208) and (
selectedElements.z and elementsBootables or #bootCandidates > 0 and ( -- Up
selectedElements.z and elementsBootables or #bootCandidates > 0 and ( -- Up
selectedElements.p and elementsBootables or elementsPrimary
selectedElements.p and elementsBootables or elementsPrimary
)
)
) or selectedElements
) or selectedElements
selectedElements.s =
selectedElements.s =
code == 203 and ( -- Left
code == 203 and ( -- Left
selectedElements.s == 1 and #selectedElements or selectedElements.s - 1
selectedElements.s == 1 and #selectedElements or selectedElements.s - 1
) or code == 205 and (
) or code == 205 and (
selectedElements.s == #selectedElements and 1 or selectedElements.s + 1 -- Right
selectedElements.s == #selectedElements and 1 or selectedElements.s + 1 -- Right
) or selectedElements.s
) or selectedElements.s
if code == 28 then -- Enter
if code == 28 then -- Enter
selectedElements[selectedElements.s][2]()
selectedElements[selectedElements.s][2]()
end
end
end
end
goto LOOP
goto LOOP
end
end
computer.getBootAddress = function() return proxy"pro" and proxy"pro".getData() end
computer.getBootAddress = function() return proxy"pro" and proxy"pro".getData() end
computer.setBootAddress = function(d) return proxy"pro" and proxy"pro".setData(d) end
computer.setBootAddress = function(d) return proxy"pro" and proxy"pro".setData(d) end
updateCandidates()
updateCandidates()
pcall(rebindGPU)
pcall(rebindGPU)
コピー
コピー済み
コピー
コピー済み
pcall(status, "
Hold
ALT
to stay in bootloader
", F, 1, 56, bootloader)
pcall(status, "
Сборка от logicikaaren замжите
ALT
чтобы зайти в меню
", F, 1, 56, bootloader)
for i = 1, #bootCandidates do
for i = 1, #bootCandidates do
bootCandidates[i].b()
bootCandidates[i].b()
end
end
bootloader()
bootloader()
保存された差分
原文
ファイルを開く
local component, computer, unicode, math, bootFiles, bootCandidates, keys, userChecked, width, height, gpu, screen, redraw, lines = component, computer, unicode, math, {"/init.lua", "/OS.lua"}, {}, {} local function pullSignal(timeout) local signal = {computer.pullSignal(timeout)} signal[1] = signal[1] or "" if cyan and ( signal[1]:match("ey") and not cyan:match(signal[5]) or signal[1]:match("cl") and not cyan:match(signal[4]) ) then return "" end keys[signal[4] or ""] = signal[1]:match"do" and 1 return table.unpack(keys[29] and (keys[46] or keys[32]) and signal[1]:match"do" and {"F"} or signal) end local function proxy(componentType) return component.list(componentType)() and component.proxy(component.list(componentType)()) end local function split(text, tabulate) lines = {} for line in text:gmatch"[^\r\n]+" do lines[#lines + 1] = line:gsub("\t", tabulate and " " or "") end end local function sleep(timeout, breakCode, onBreak, deadline, signalType, code, _) deadline = computer.uptime() + (timeout or math.huge) ::LOOP:: signalType, _, _, code = pullSignal(deadline - computer.uptime()) if signalType == "F" or signalType:match"do" and (code == breakCode or breakCode == 0) then return 1, onBreak and onBreak() elseif computer.uptime() < deadline then goto LOOP end end local function set(x, y, string, background, foreground) gpu.setBackground(background or 0x002b36) gpu.setForeground(foreground or 0x8cb9c5) gpu.set(x, y, string) end local function fill(x, y, w, h, background, foreground) gpu.setBackground(background or 0x002b36) gpu.setForeground(foreground or 0x8cb9c5) gpu.fill(x, y, w, h, " ") end local function clear() fill(1, 1, width, height) end local function centrize(len) return math.floor(width / 2 - len / 2) end local function centrizedSet(y, text, background, foreground) set(centrize(unicode.len(text)), y, text, background, foreground) end local function rebindGPU() gpu, screen = proxy"gp", proxy"sc" if gpu.getScreen() ~= screen.address then gpu.bind((screen.address)) end gpu.setPaletteColor(9, 0x002b36) gpu.setPaletteColor(11, 0x8cb9c5) local aspectWidth, aspectHeight, proportion = screen.getAspectRatio() width, height = gpu.maxResolution() if not proxy"able" then proportion = 2*(16*aspectWidth-4.5)/(16*aspectHeight-4.5) height = proportion > width / height and math.floor(width / proportion) or height width = math.floor(height * proportion) end gpu.setResolution(width, height) end local function status(text, title, wait, breakCode, onBreak, y) clear() split(text) y = math.ceil(height / 2 - #lines / 2) if title then centrizedSet(y - 1, title, 0x002b36, 0xffffff) y = y + 1 end for i = 1, #lines do centrizedSet(y, lines[i]) y = y + 1 end sleep(wait or 0, breakCode or 0, onBreak) end local function cutText(text, maxLength) return unicode.len(text) > maxLength and unicode.sub(text, 1, maxLength) .. "…" or text end local function input(prefix, y, centrized, historyText, foreground) local text, prefixLen, cursorPos, cursorState, cursorX, x, signalType, char, code, _ = "", unicode.len(prefix), 1, 1 foreground = foreground or 0x8cb9c5 ::LOOP:: x = centrized and centrize(unicode.len(text) + prefixLen) or 1 cursorX = x + prefixLen + cursorPos - 1 fill(1, y, width, 1) set(x, y, prefix .. text, F, foreground) if cursorX <= width then set(cursorX, y, gpu.get(cursorX, y), cursorState and foreground or 0x002b36, cursorState and 0x002b36 or foreground) end signalType, _, char, code = pullSignal(.5) if signalType:match"do" then if code == 203 and cursorPos > 1 then cursorPos = cursorPos - 1 elseif code == 205 and cursorPos <= unicode.len(text) then cursorPos = cursorPos + 1 elseif code == 200 and historyText then text = historyText cursorPos = unicode.len(historyText) + 1 elseif code == 208 and historyText then text = "" cursorPos = 1 elseif code == 14 and #text > 0 and cursorPos > 1 then text = keys[29] and "" or unicode.sub(unicode.sub(text, 1, cursorPos - 1), 1, -2) .. unicode.sub(text, cursorPos, -1) cursorPos = keys[29] and 1 or cursorPos - 1 elseif code == 28 then return text elseif char >= 32 and unicode.len(prefixLen .. text) < width - prefixLen then text = unicode.sub(text, 1, cursorPos - 1) .. unicode.char(char) .. unicode.sub(text, cursorPos, -1) cursorPos = cursorPos + 1 end cursorState = 1 elseif signalType:match"cl" then text = unicode.sub(text, 1, cursorPos - 1) .. char .. unicode.sub(text, cursorPos, -1) cursorPos = cursorPos + unicode.len(char) elseif signalType:match"mp" or signalType == "F" then redraw = signalType:match"mp" and 1 return elseif not signalType:match"up" then cursorState = not cursorState end goto LOOP end local function execute(code, stdin, env, palette, call) call = call or xpcall local chunk, err = load("return " .. code, stdin, F, env) if not chunk then chunk, err = load(code, stdin, F, env) end if chunk then if palette and gpu then sleep(.3) fill(1, 1, width or 0, height or 0, 0) gpu.setPaletteColor(9, 0x969696) gpu.setPaletteColor(11, 0xb4b4b4) end return call(chunk, debug.traceback) end return F, err end local function addCandidate(address) local proxy, allBootFiles, bootFile, i = component.proxy(address), {s = 1, z = 1} if proxy and address ~= computer.tmpAddress() then i = #bootCandidates + 1 bootCandidates[i] = { r = proxy, l = allBootFiles, d = proxy, p = function(booting, y) booting = booting and clear() or booting centrizedSet(y or height / 2, booting and ("Booting %s from %s (%s)"):format( bootFile, proxy.getLabel() or "N/A", cutText(address, width > 80 and 36 or 6) ) or bootFile and ("Boot%s %s (%s)"):format( (#allBootFiles == 1 and " " .. bootFile or "") .. " from", proxy.getLabel() or "N/A", cutText(address, 6) ) or ("Boot from %s (%s) isn't available"):format( proxy.getLabel() or "N/A", cutText(address, 6) ) , F, not booting and 0xffffff) booting = booting and not userChecked and cyan and (cyan:match("+") and pcall(status, "Hold ENTER to boot", F, math.huge, 28)) end } bootCandidates[i].b = function() if bootFile then local handle, data, chunk, success, err = proxy.open(bootFile, "r"), "" ::LOOP:: chunk = proxy.read(handle, math.huge) if chunk then data = data .. chunk goto LOOP end proxy.close(handle) pcall(bootCandidates[i].p, 1) chunk = computer.getBootAddress() ~= address and computer.setBootAddress(address) success, err = execute(data, "=" .. bootFile, F, 1) success = success and pcall(computer.shutdown) pcall(rebindGPU) pcall(status, err, "¯\\_(ツ)_/¯", math.huge, 0, computer.shutdown) error(err) end end for j = 1, #bootFiles do if proxy.exists(bootFiles[j]) then bootFile = bootFile or bootFiles[j] allBootFiles[#allBootFiles + 1] = { bootFiles[j], function() bootFile = bootFiles[j] bootCandidates[i].b() end } end end end end local function updateCandidates() bootCandidates = {} addCandidate(computer.getBootAddress() or "") for address in next, component.list"file" do addCandidate(address ~= computer.getBootAddress() and address or "") end end local function drawElements(elements, y, spaces, borderHeight, drawSelected, onDraw) local elementsLineLength, x = 0 for i = 1, #elements do elementsLineLength = elementsLineLength + unicode.len(elements[i][1]) + spaces end elementsLineLength = elementsLineLength - spaces x = centrize(elementsLineLength) if onDraw then onDraw() end for i = 1, #elements do if elements.s == i and drawSelected then fill(x - spaces / 2, y - math.floor(borderHeight / 2), unicode.len(elements[i][1]) + spaces, borderHeight, 0x8cb9c5) set(x, y, elements[i][1], 0x8cb9c5, 0x002b36) else set(x, y, elements[i][1], 0x002b36, 0x8cb9c5) end x = x + unicode.len(elements[i][1]) + spaces end end local function shell(env, data, str, text) clear() env = setmetatable({ print = function(...) text = table.pack(...) for i = 1, text.n do if type(text[i]):match"able" then str = '' for k, v in pairs(text[i]) do str = str .. tostring(k) .. " " .. tostring(v) .. "\n" end text[i] = str end text[i] = tostring(text[i]) end split(table.concat(text, " "), 1) for i = 1, #lines do gpu.copy(1, 1, width, height - 1, 0, -1) fill(1, height - 1, width, 1) set(1, height - 1, lines[i]) end end, proxy = proxy, sleep = function(timeout) sleep(timeout, 32, error) end }, {__index = _G}) ::LOOP:: data = input("> ", height, F, data, 0xffffff, env) if data then env.print("> " .. data) fill(1, height, width, 1) set(1, height, ">") env.print(select(2, execute(data, "=shell", env))) goto LOOP end end local function bootloader() userChecked = 1, not gpu and error"No drives available" ::UPDATE:: local elementsBootables, correction, elementsPrimary, selectedElements, signalType, code, newLabel, url, y, drive, bootingEntry, update, _ = {s = 1} elementsPrimary = { s = 1, p = 1, {"Halt", computer.shutdown}, {"Shell", shell}, proxy"net" and {"Netboot", function() clear() centrizedSet(height / 2 - 1, "Netboot", F, 0xffffff) url = input("URL: ", height / 2 + 1, 1, F, 0x8cb9c5) if url and #url > 0 then local handle, data, chunk = proxy"net".request(url, F, F, {["user-agent"]="Netboot"}), "" if handle then status("Downloading script...", "Netboot") ::LOOP:: chunk = handle.read() if chunk then data = data .. chunk goto LOOP end data = select(2, execute(data, "=stdin", F, 1, pcall)) or "" pcall(rebindGPU) pcall(status, data, "Netboot", #data == 0 and 0 or math.huge) else status("Invalid URL", "Netboot", math.huge) end end end} } correction = #elementsPrimary + 1 redraw = F bootingEntry = F function update() updateCandidates() for i = 1, #bootCandidates do elementsBootables[i] = { cutText(bootCandidates[i].d.getLabel() or "N/A", 6), function() if #bootCandidates[i].l > 0 then bootingEntry = i selectedElements = bootCandidates[bootingEntry].l if #selectedElements == 1 then selectedElements[1][2]() end end end } end end update() selectedElements = #bootCandidates > 0 and elementsBootables or elementsPrimary ::LOOP:: pcall(function() clear() if selectedElements.z then centrizedSet(height / 2 - 2, "Select boot entry", F, 0xffffff) drawElements(selectedElements, height / 2 + 2, 6, 3, 1) else y = height / 2 - (#bootCandidates > 0 and -1 or 1) drawElements(elementsBootables, y - 4, 8, 3, not selectedElements.p and 1, function() if #bootCandidates > 0 then drive = bootCandidates[elementsBootables.s].r bootCandidates[elementsBootables.s].p(F, y + 3) centrizedSet(y + 5, ("Storage %s%% / %s / %s"):format( math.floor(drive.spaceUsed() / (drive.spaceTotal() / 100)), drive.isReadOnly() and "Read only" or "Read & Write", drive.spaceTotal() < 2 ^ 20 and "FDD" or drive.spaceTotal() < 2 ^ 20 * 12 and "HDD" or "RAID") ) for i = correction, #elementsPrimary do elementsPrimary[i] = F end elementsPrimary[correction] = {"Rename", function() clear() centrizedSet(height / 2 - 1, "Rename", F, 0xffffff) newLabel = input("Enter new name: ", height / 2 + 1, 1, F, 0x8cb9c5) if newLabel and #newLabel > 0 and pcall(drive.setLabel, newLabel) then drive.setLabel(newLabel) update() end end} if not drive.isReadOnly() then elementsPrimary[correction + 1] = {"Format", function() drive.remove("/") drive.setLabel(F) update() end} end else centrizedSet(y + 3, "No drives available", F, 0xffffff) end end) drawElements(elementsPrimary, y, 6, 1, selectedElements.p and 1 or F) end end) if signalType and signalType:match"mp" or redraw then pcall(rebindGPU) goto UPDATE end signalType, _, _, code = pullSignal() _ = signalType == "F" and computer.shutdown() if signalType:match"do" and gpu and screen then -- if you read this message please help they they forced me to do this selectedElements = (code == 200 or code == 208) and ( selectedElements.z and elementsBootables or #bootCandidates > 0 and ( -- Up selectedElements.p and elementsBootables or elementsPrimary ) ) or selectedElements selectedElements.s = code == 203 and ( -- Left selectedElements.s == 1 and #selectedElements or selectedElements.s - 1 ) or code == 205 and ( selectedElements.s == #selectedElements and 1 or selectedElements.s + 1 -- Right ) or selectedElements.s if code == 28 then -- Enter selectedElements[selectedElements.s][2]() end end goto LOOP end computer.getBootAddress = function() return proxy"pro" and proxy"pro".getData() end computer.setBootAddress = function(d) return proxy"pro" and proxy"pro".setData(d) end updateCandidates() pcall(rebindGPU) pcall(status, "Hold ALT to stay in bootloader", F, 1, 56, bootloader) for i = 1, #bootCandidates do bootCandidates[i].b() end bootloader()
変更されたテキスト
ファイルを開く
--- useless рекавери --- Я не ответчаю за кирпич биос/ I dont ask about brick bios -- Downloadable module with recovery tools local component, computer, unicode, math, bootFiles, bootCandidates, keys, userChecked, width, height, gpu, screen, redraw, lines = component, computer, unicode, math, {"/init.lua", "/OS.lua"}, {}, {} local function pullSignal(timeout) local signal = {computer.pullSignal(timeout)} signal[1] = signal[1] or "" if cyan and ( signal[1]:match("ey") and not cyan:match(signal[5]) or signal[1]:match("cl") and not cyan:match(signal[4]) ) then return "" end keys[signal[4] or ""] = signal[1]:match"do" and 1 return table.unpack(keys[29] and (keys[46] or keys[32]) and signal[1]:match"do" and {"F"} or signal) end local function proxy(componentType) return component.list(componentType)() and component.proxy(component.list(componentType)()) end local function split(text, tabulate) lines = {} for line in text:gmatch"[^\r\n]+" do lines[#lines + 1] = line:gsub("\t", tabulate and " " or "") end end local function sleep(timeout, breakCode, onBreak, deadline, signalType, code, _) deadline = computer.uptime() + (timeout or math.huge) ::LOOP:: signalType, _, _, code = pullSignal(deadline - computer.uptime()) if signalType == "F" or signalType:match"do" and (code == breakCode or breakCode == 0) then return 1, onBreak and onBreak() elseif computer.uptime() < deadline then goto LOOP end end local function set(x, y, string, background, foreground) gpu.setBackground(background or 0x002b36) gpu.setForeground(foreground or 0x8cb9c5) gpu.set(x, y, string) end local function fill(x, y, w, h, background, foreground) gpu.setBackground(background or 0x002b36) gpu.setForeground(foreground or 0x8cb9c5) gpu.fill(x, y, w, h, " ") end local function clear() fill(1, 1, width, height) end local function centrize(len) return math.floor(width / 2 - len / 2) end local function centrizedSet(y, text, background, foreground) set(centrize(unicode.len(text)), y, text, background, foreground) end local function rebindGPU() gpu, screen = proxy"gp", proxy"sc" if gpu.getScreen() ~= screen.address then gpu.bind((screen.address)) end gpu.setPaletteColor(9, 0x002b36) gpu.setPaletteColor(11, 0x8cb9c5) local aspectWidth, aspectHeight, proportion = screen.getAspectRatio() width, height = gpu.maxResolution() if not proxy"able" then proportion = 2*(16*aspectWidth-4.5)/(16*aspectHeight-4.5) height = proportion > width / height and math.floor(width / proportion) or height width = math.floor(height * proportion) end gpu.setResolution(width, height) end local function status(text, title, wait, breakCode, onBreak, y) clear() split(text) y = math.ceil(height / 2 - #lines / 2) if title then centrizedSet(y - 1, title, 0x002b36, 0xffffff) y = y + 1 end for i = 1, #lines do centrizedSet(y, lines[i]) y = y + 1 end sleep(wait or 0, breakCode or 0, onBreak) end local function cutText(text, maxLength) return unicode.len(text) > maxLength and unicode.sub(text, 1, maxLength) .. "…" or text end local function input(prefix, y, centrized, historyText, foreground) local text, prefixLen, cursorPos, cursorState, cursorX, x, signalType, char, code, _ = "", unicode.len(prefix), 1, 1 foreground = foreground or 0x8cb9c5 ::LOOP:: x = centrized and centrize(unicode.len(text) + prefixLen) or 1 cursorX = x + prefixLen + cursorPos - 1 fill(1, y, width, 1) set(x, y, prefix .. text, F, foreground) if cursorX <= width then set(cursorX, y, gpu.get(cursorX, y), cursorState and foreground or 0x002b36, cursorState and 0x002b36 or foreground) end signalType, _, char, code = pullSignal(.5) if signalType:match"do" then if code == 203 and cursorPos > 1 then cursorPos = cursorPos - 1 elseif code == 205 and cursorPos <= unicode.len(text) then cursorPos = cursorPos + 1 elseif code == 200 and historyText then text = historyText cursorPos = unicode.len(historyText) + 1 elseif code == 208 and historyText then text = "" cursorPos = 1 elseif code == 14 and #text > 0 and cursorPos > 1 then text = keys[29] and "" or unicode.sub(unicode.sub(text, 1, cursorPos - 1), 1, -2) .. unicode.sub(text, cursorPos, -1) cursorPos = keys[29] and 1 or cursorPos - 1 elseif code == 28 then return text elseif char >= 32 and unicode.len(prefixLen .. text) < width - prefixLen then text = unicode.sub(text, 1, cursorPos - 1) .. unicode.char(char) .. unicode.sub(text, cursorPos, -1) cursorPos = cursorPos + 1 end cursorState = 1 elseif signalType:match"cl" then text = unicode.sub(text, 1, cursorPos - 1) .. char .. unicode.sub(text, cursorPos, -1) cursorPos = cursorPos + unicode.len(char) elseif signalType:match"mp" or signalType == "F" then redraw = signalType:match"mp" and 1 return elseif not signalType:match"up" then cursorState = not cursorState end goto LOOP end local function execute(code, stdin, env, palette, call) call = call or xpcall local chunk, err = load("return " .. code, stdin, F, env) if not chunk then chunk, err = load(code, stdin, F, env) end if chunk then if palette and gpu then sleep(.3) fill(1, 1, width or 0, height or 0, 0) gpu.setPaletteColor(9, 0x969696) gpu.setPaletteColor(11, 0xb4b4b4) end return call(chunk, debug.traceback) end return F, err end local function addCandidate(address) local proxy, allBootFiles, bootFile, i = component.proxy(address), {s = 1, z = 1} if proxy and address ~= computer.tmpAddress() then i = #bootCandidates + 1 bootCandidates[i] = { r = proxy, l = allBootFiles, d = proxy, p = function(booting, y) booting = booting and clear() or booting centrizedSet(y or height / 2, booting and ("Загрузка %s Из %s (%s)"):format( bootFile, proxy.getLabel() or "N/A", cutText(address, width > 80 and 36 or 6) ) or bootFile and ("Boot%s %s (%s)"):format( (#allBootFiles == 1 and " " .. bootFile or "") .. " from", proxy.getLabel() or "N/A", cutText(address, 6) ) or ("Boot from %s (%s) isn't available"):format( proxy.getLabel() or "N/A", cutText(address, 6) ) , F, not booting and 0xffffff) booting = booting and not userChecked and cyan and (cyan:match("+") and pcall(status, "Зажмите Enter чтобы зайти в систему", F, math.huge, 28)) end } bootCandidates[i].b = function() if bootFile then local handle, data, chunk, success, err = proxy.open(bootFile, "r"), "" ::LOOP:: chunk = proxy.read(handle, math.huge) if chunk then data = data .. chunk goto LOOP end proxy.close(handle) pcall(bootCandidates[i].p, 1) chunk = computer.getBootAddress() ~= address and computer.setBootAddress(address) success, err = execute(data, "=" .. bootFile, F, 1) success = success and pcall(computer.shutdown) pcall(rebindGPU) pcall(status, err, "А ЗАЧЕМ ЛОМАТЬ :)", math.huge, 0, computer.shutdown) error(err) end end for j = 1, #bootFiles do if proxy.exists(bootFiles[j]) then bootFile = bootFile or bootFiles[j] allBootFiles[#allBootFiles + 1] = { bootFiles[j], function() bootFile = bootFiles[j] bootCandidates[i].b() end } end end end end local function updateCandidates() bootCandidates = {} addCandidate(computer.getBootAddress() or "") for address in next, component.list"file" do addCandidate(address ~= computer.getBootAddress() and address or "") end end local function drawElements(elements, y, spaces, borderHeight, drawSelected, onDraw) local elementsLineLength, x = 0 for i = 1, #elements do elementsLineLength = elementsLineLength + unicode.len(elements[i][1]) + spaces end elementsLineLength = elementsLineLength - spaces x = centrize(elementsLineLength) if onDraw then onDraw() end for i = 1, #elements do if elements.s == i and drawSelected then fill(x - spaces / 2, y - math.floor(borderHeight / 2), unicode.len(elements[i][1]) + spaces, borderHeight, 0x8cb9c5) set(x, y, elements[i][1], 0x8cb9c5, 0x002b36) else set(x, y, elements[i][1], 0x002b36, 0x8cb9c5) end x = x + unicode.len(elements[i][1]) + spaces end end local function shell(env, data, str, text) clear() env = setmetatable({ print = function(...) text = table.pack(...) for i = 1, text.n do if type(text[i]):match"able" then str = '' for k, v in pairs(text[i]) do str = str .. tostring(k) .. " " .. tostring(v) .. "\n" end text[i] = str end text[i] = tostring(text[i]) end split(table.concat(text, " "), 1) for i = 1, #lines do gpu.copy(1, 1, width, height - 1, 0, -1) fill(1, height - 1, width, 1) set(1, height - 1, lines[i]) end end, proxy = proxy, sleep = function(timeout) sleep(timeout, 32, error) end }, {__index = _G}) ::LOOP:: data = input("> ", height, F, data, 0xffffff, env) if data then env.print("> " .. data) fill(1, height, width, 1) set(1, height, ">") env.print(select(2, execute(data, "=shell", env))) goto LOOP end end local function bootloader() userChecked = 1, not gpu and error"No drives available" ::UPDATE:: local elementsBootables, correction, elementsPrimary, selectedElements, signalType, code, newLabel, url, y, drive, bootingEntry, update, _ = {s = 1} elementsPrimary = { s = 1, p = 1, {"Halt", computer.shutdown}, {"Shell", shell}, proxy"net" and {"Загрузка из интернета", function() clear() centrizedSet(height / 2 - 1, "Загрузка из интернета", F, 0xffffff) url = input("URL: ", height / 2 + 1, 1, F, 0x8cb9c5) if url and #url > 0 then local handle, data, chunk = proxy"net".request(url, F, F, {["user-agent"]="Загрузка из интернета"}), "" if handle then status("Downloading script...", Загрузка из Интернета") ::LOOP:: chunk = handle.read() if chunk then data = data .. chunk goto LOOP end data = select(2, execute(data, "=stdin", F, 1, pcall)) or "" pcall(rebindGPU) pcall(status, data, "Загрузка из интернета", #data == 0 and 0 or math.huge) else status("Invalid URL", "Загрузка из интернета", math.huge) end end end} } correction = #elementsPrimary + 1 redraw = F bootingEntry = F function update() updateCandidates() for i = 1, #bootCandidates do elementsBootables[i] = { cutText(bootCandidates[i].d.getLabel() or "N/A", 6), function() if #bootCandidates[i].l > 0 then bootingEntry = i selectedElements = bootCandidates[bootingEntry].l if #selectedElements == 1 then selectedElements[1][2]() end end end } end end update() selectedElements = #bootCandidates > 0 and elementsBootables or elementsPrimary ::LOOP:: pcall(function() clear() if selectedElements.z then centrizedSet(height / 2 - 2, "Select boot entry", F, 0xffffff) drawElements(selectedElements, height / 2 + 2, 6, 3, 1) else y = height / 2 - (#bootCandidates > 0 and -1 or 1) drawElements(elementsBootables, y - 4, 8, 3, not selectedElements.p and 1, function() if #bootCandidates > 0 then drive = bootCandidates[elementsBootables.s].r bootCandidates[elementsBootables.s].p(F, y + 3) centrizedSet(y + 5, ("Storage %s%% / %s / %s"):format( math.floor(drive.spaceUsed() / (drive.spaceTotal() / 100)), drive.isReadOnly() and "Read only" or "Read & Write", drive.spaceTotal() < 2 ^ 20 and "FDD" or drive.spaceTotal() < 2 ^ 20 * 12 and "HDD" or "RAID") ) for i = correction, #elementsPrimary do elementsPrimary[i] = F end elementsPrimary[correction] = {"Переменовать", function() clear() centrizedSet(height / 2 - 1, "Переменовать", F, 0xffffff) newLabel = input("Введите новое имя: ", height / 2 + 1, 1, F, 0x8cb9c5) if newLabel and #newLabel > 0 and pcall(drive.setLabel, newLabel) then drive.setLabel(newLabel) update() end end} if not drive.isReadOnly() then elementsPrimary[correction + 1] = {"Форматировать", function() drive.remove("/") drive.setLabel(F) update() end} end else centrizedSet(y + 3, "No drives available", F, 0xffffff) end end) drawElements(elementsPrimary, y, 6, 1, selectedElements.p and 1 or F) end end) if signalType and signalType:match"mp" or redraw then pcall(rebindGPU) goto UPDATE end signalType, _, _, code = pullSignal() _ = signalType == "F" and computer.shutdown() if signalType:match"do" and gpu and screen then -- if you read this message please help they they forced me to do this selectedElements = (code == 200 or code == 208) and ( selectedElements.z and elementsBootables or #bootCandidates > 0 and ( -- Up selectedElements.p and elementsBootables or elementsPrimary ) ) or selectedElements selectedElements.s = code == 203 and ( -- Left selectedElements.s == 1 and #selectedElements or selectedElements.s - 1 ) or code == 205 and ( selectedElements.s == #selectedElements and 1 or selectedElements.s + 1 -- Right ) or selectedElements.s if code == 28 then -- Enter selectedElements[selectedElements.s][2]() end end goto LOOP end computer.getBootAddress = function() return proxy"pro" and proxy"pro".getData() end computer.setBootAddress = function(d) return proxy"pro" and proxy"pro".setData(d) end updateCandidates() pcall(rebindGPU) pcall(status, "Сборка от logicikaaren замжите ALT чтобы зайти в меню ", F, 1, 56, bootloader) for i = 1, #bootCandidates do bootCandidates[i].b() end bootloader()
違いを見つける