From b7427aa9739894c92275c0aab3b9cd9218b25769 Mon Sep 17 00:00:00 2001 From: MayaTheShy Date: Wed, 25 Mar 2026 22:37:03 -0400 Subject: [PATCH] feat: implement reboot listener for mining turtle to handle remote reboot commands --- startup/miner.lua | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/startup/miner.lua b/startup/miner.lua index aa7d429..16f7d0d 100644 --- a/startup/miner.lua +++ b/startup/miner.lua @@ -55,4 +55,28 @@ print("") print("Starting miningTurtle...") sleep(1) -shell.run("miningTurtle.lua") +-- Reboot listener: reboots this turtle on remote command +local SYSTEM_CHANNEL = 4205 +local ROLE = "miner" + +local function rebootListener() + local m = peripheral.find("modem") + if not m then return end + m.open(SYSTEM_CHANNEL) + while true do + local _, _, channel, _, message = os.pullEvent("modem_message") + if channel == SYSTEM_CHANNEL and type(message) == "table" and message.type == "reboot" then + local target = message.target or "all" + if target == "all" or target == ROLE or target == tostring(os.getComputerID()) then + print("[SYSTEM] Reboot command received. Rebooting...") + sleep(0.5) + os.reboot() + end + end + end +end + +parallel.waitForAny( + function() shell.run("miningTurtle.lua") end, + rebootListener +)