From 67deb425bfaf30eeea0b2d455beccdb845a21150 Mon Sep 17 00:00:00 2001 From: Leonmmcoset Date: Fri, 5 Sep 2025 19:26:08 +0800 Subject: [PATCH] =?UTF-8?q?fix(turtle=5Fminer):=20=E5=B0=86os.sleep?= =?UTF-8?q?=E6=9B=BF=E6=8D=A2=E4=B8=BA=5FG.os.sleep=E4=BB=A5=E9=81=BF?= =?UTF-8?q?=E5=85=8D=E5=85=A8=E5=B1=80=E5=8F=98=E9=87=8F=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改turtle_miner.lua中的os.sleep调用为_G.os.sleep,确保在可能存在全局变量os被覆盖的环境中仍能正常工作。这解决了在某些情况下可能出现的函数调用失败问题。 --- data/computercraft/lua/rom/programs/turtle_miner.lua | 6 +++--- installer.lua | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/data/computercraft/lua/rom/programs/turtle_miner.lua b/data/computercraft/lua/rom/programs/turtle_miner.lua index 045c4b9..fbd5215 100644 --- a/data/computercraft/lua/rom/programs/turtle_miner.lua +++ b/data/computercraft/lua/rom/programs/turtle_miner.lua @@ -271,18 +271,18 @@ local function startMining() print("Mining...") turtle.dig() -- 检查是否有掉落物需要捡起 - os.sleep(0.5) + _G.os.sleep(0.5) end -- 检查上方是否有方块可以挖掘 if turtle.detectUp() then print("Mining above...") turtle.digUp() - os.sleep(0.5) + _G.os.sleep(0.5) end -- 短暂延迟避免CPU占用过高 - os.sleep(0.1) + _G.os.sleep(0.1) end print(colors.yellow .. "Auto mining stopped." .. colors.white) diff --git a/installer.lua b/installer.lua index d19759c..efeef1f 100644 --- a/installer.lua +++ b/installer.lua @@ -1,5 +1,5 @@ -- LeonOS installer -local INSTALLER_VERSION = "0.3.8 Beta 9" +local INSTALLER_VERSION = "0.3.8 Beta 10" local DEFAULT_ROM_DIR = "/leonos" print("Start loading LeonOS installer ("..INSTALLER_VERSION..")...")