Spirit13300

Untitled

Sep 26th, 2025
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.45 KB | Gaming | 0 0
  1. -- startup.lua — Mélodie d'accueil (speaker à gauche)
  2.  
  3. local SIDE = "left"            -- le haut-parleur est à gauche
  4. local INSTRUMENT = "harp"      -- autres possibles: "bell","chime","xylophone", etc.
  5. local VOLUME = 1.0             -- 0.0 à 3.0 selon CC:Tweaked
  6.  
  7. -- Récupération du périphérique speaker
  8. local sp = peripheral.wrap(SIDE)
  9. if not sp or peripheral.getType(SIDE) ~= "speaker" then
  10.   -- sécurité: on tente de trouver un speaker ailleurs
  11.   sp = peripheral.find("speaker")
  12. end
  13. if not sp then
  14.   print("Aucun 'speaker' détecté. Place un haut-parleur sur le côté gauche.")
  15.   return
  16. end
  17.  
  18. -- Petite aide pour jouer une note
  19. local function note(pitch, dur)
  20.   -- pitch: entier 0..24 (gamme note block Minecraft)
  21.   -- dur: durée en secondes
  22.   sp.playNote(INSTRUMENT, VOLUME, pitch)
  23.   sleep(dur or 0.12)
  24. end
  25.  
  26. -- Jingle d'accueil (arpège + petite descente)
  27. -- Pitches choisis pour faire un C majeur '8-bit' : C-E-G-C' puis retour
  28. local seq = {
  29.   {12, 0.14},  -- C
  30.   {16, 0.14},  -- E
  31.   {19, 0.14},  -- G
  32.   {24, 0.22},  -- C' (octave)
  33.   {19, 0.12},  -- G
  34.   {16, 0.12},  -- E
  35.   {12, 0.18},  -- C
  36. }
  37.  
  38. -- Petit "whoosh" d'ouverture (glissando)
  39. for p = 9, 12 do note(p, 0.06) end
  40.  
  41. -- Mélodie principale
  42. for _, n in ipairs(seq) do note(n[1], n[2]) end
  43.  
  44. -- Tint final (accord court C-E-G simultané simulé)
  45. sp.playNote(INSTRUMENT, VOLUME, 12)
  46. sp.playNote(INSTRUMENT, VOLUME, 16)
  47. sp.playNote(INSTRUMENT, VOLUME, 19)
  48. sleep(0.18)
  49.  
Advertisement
Add Comment
Please, Sign In to add comment