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