From ce6c7b64033442e0c34e98129111ff79d326c6cd Mon Sep 17 00:00:00 2001 From: Leonmmcoset Date: Sun, 31 Aug 2025 22:22:49 +0800 Subject: [PATCH] =?UTF-8?q?refactor(installer):=20=E5=B0=86term.write?= =?UTF-8?q?=E6=9B=BF=E6=8D=A2=E4=B8=BAprint=E4=BB=A5=E7=AE=80=E5=8C=96?= =?UTF-8?q?=E8=BE=93=E5=87=BA=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改installer.lua中的输出方式,使用print替代term.write以提高代码简洁性,同时保持相同功能 --- installer.lua | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/installer.lua b/installer.lua index 9becf61..ff4000f 100644 --- a/installer.lua +++ b/installer.lua @@ -1,8 +1,8 @@ -- LeonOS installer local DEFAULT_ROM_DIR = "/rc" -term.at(1, 2).write("Start loading LeonOS installer...\n") -term.write("[Installer] Loading module 1\n") +print("Start loading LeonOS installer...\n") +print("[Installer] Loading module 1\n") local function dl(f) local hand, err = http.get(f, nil, true) if not hand then @@ -14,41 +14,41 @@ local function dl(f) return data end -term.write("[Installer] Loading done.\n") -term.write("[Installer] Loading module 2\n") +print("[Installer] Loading done.\n") +print("[Installer] Loading module 2\n") -- set up package.loaded for LeonOS libs package.loaded.rc = { expect = require("cc.expect").expect, write = write, sleep = sleep } -term.write("[Installer] Loading done.\n") -term.write("[Installer] Loading module 3\n") +print("[Installer] Loading done.\n") +print("[Installer] Loading module 3\n") package.loaded.term = term package.loaded.colors = colors _G.require = require -term.write("[Installer] Loading done.\n") -term.write("[Installer] Loading module 4\n") +print("[Installer] Loading done.\n") +print("[Installer] Loading module 4\n") function term.at(x, y) term.setCursorPos(x, y) return term end -term.write("[Installer] Loading done.\n") -term.write("[Installer] Loading module 5\n") +print("[Installer] Loading done.\n") +print("[Installer] Loading module 5\n") local function ghload(f, c) return assert(load(dl("https://gh.catmak.name/https://raw.githubusercontent.com/"..f), "="..(c or f), "t", _G))() end -term.write("[Installer] Loading done.\n") -term.write("[Installer] Loading module 6\n") +print("[Installer] Loading done.\n") +print("[Installer] Loading module 6\n") local json = ghload("rxi/json.lua/master/json.lua", "ghload(json)") package.loaded["rc.json"] = json -term.write("[Installer] Loading module 7\n") +print("[Installer] Loading module 7\n") local function rcload(f) return ghload( "Leonmmcoset/LeonOS/refs/heads/main/data/computercraft/lua/rom/"..f, f) end -term.write("[Installer] Loading done.\n") -term.write("[Installer] Loading module 8\n") +print("[Installer] Loading done.\n") +print("[Installer] Loading module 8\n") -- get LeonOS's textutils with its extra utilities local tu = rcload("apis/textutils.lua")