Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- startup.lua — Mélodie d'accueil (speaker à gauche)
- local SIDE = "left" -- le haut-parleur est à gauche
- local INSTRUMENT = "harp" -- autres possibles: "bell","chime","xylophone", etc.
- local VOLUME = 1.0 -- 0.0 à 3.0 selon CC:Tweaked
- -- Récupération du périphérique speaker
- local sp = peripheral.wrap(SIDE)
- if not sp or peripheral.getType(SIDE) ~= "speaker" then
- -- sécurité: on tente de trouver un speaker ailleurs
- sp = peripheral.find("speaker")
- end
- if not sp then
- print("Aucun 'speaker' détecté. Place un haut-parleur sur le côté gauche.")
- return
- end
- -- Petite aide pour jouer une note
- local function note(pitch, dur)
- -- pitch: entier 0..24 (gamme note block Minecraft)
- -- dur: durée en secondes
- sp.playNote(INSTRUMENT, VOLUME, pitch)
- sleep(dur or 0.12)
- end
- -- Jingle d'accueil (arpège + petite descente)
- -- Pitches choisis pour faire un C majeur '8-bit' : C-E-G-C' puis retour
- local seq = {
- {12, 0.14}, -- C
- {16, 0.14}, -- E
- {19, 0.14}, -- G
- {24, 0.22}, -- C' (octave)
- {19, 0.12}, -- G
- {16, 0.12}, -- E
- {12, 0.18}, -- C
- }
- -- Petit "whoosh" d'ouverture (glissando)
- for p = 9, 12 do note(p, 0.06) end
- -- Mélodie principale
- for _, n in ipairs(seq) do note(n[1], n[2]) end
- -- Tint final (accord court C-E-G simultané simulé)
- sp.playNote(INSTRUMENT, VOLUME, 12)
- sp.playNote(INSTRUMENT, VOLUME, 16)
- sp.playNote(INSTRUMENT, VOLUME, 19)
- sleep(0.18)
Advertisement
Add Comment
Please, Sign In to add comment