From 62d62ef14dad9155a85f86562852362f57d6cd4f Mon Sep 17 00:00:00 2001 From: Leonmmcoset Date: Mon, 1 Sep 2025 16:56:35 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E9=9F=B3=E9=A2=91):=20=E6=B7=BB=E5=8A=A0C?= =?UTF-8?q?C=E7=94=B5=E8=84=91=E5=90=AF=E5=8A=A8=E9=9F=B3=E4=B9=90?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加简单的C大调音阶作为启动音乐,当检测到扬声器时自动播放 --- .trae/rules/project_rules.md | 2 ++ .../lua/rom/startup/50_audio.lua | 25 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 .trae/rules/project_rules.md create mode 100644 data/computercraft/lua/rom/startup/50_audio.lua diff --git a/.trae/rules/project_rules.md b/.trae/rules/project_rules.md new file mode 100644 index 0000000..bbc60c5 --- /dev/null +++ b/.trae/rules/project_rules.md @@ -0,0 +1,2 @@ +这个是我的世界模组CC电脑Tweaked版本的操作系统 +所以要用CC Tweaked所支持的lua代码写 \ No newline at end of file diff --git a/data/computercraft/lua/rom/startup/50_audio.lua b/data/computercraft/lua/rom/startup/50_audio.lua new file mode 100644 index 0000000..73fe1aa --- /dev/null +++ b/data/computercraft/lua/rom/startup/50_audio.lua @@ -0,0 +1,25 @@ +-- LeonOS Startup Music +local rc = ... +local peripheral = require("peripheral") +local speaker = peripheral.find("speaker") + +-- 检查是否连接了扬声器 +if speaker then + -- 简单的开机音乐(C大调音阶) + local notes = { + {note = "C4", duration = 0.25}, + {note = "D4", duration = 0.25}, + {note = "E4", duration = 0.25}, + {note = "F4", duration = 0.25}, + {note = "G4", duration = 0.25}, + {note = "A4", duration = 0.25}, + {note = "B4", duration = 0.25}, + {note = "C5", duration = 0.5} + } + + -- 播放音乐 + for _, note_info in ipairs(notes) do + speaker.playNote(note_info.note) + rc.sleep(note_info.duration) + end +end \ No newline at end of file