Link menu items to array

pule_puje
pule_puje Member Posts: 2 Newcomer
edited June 2022 in Scripting Workshop

Hi everybody,

I am a newbie on ksp scripting so forgive me if I ask dumb questions. I am working on a kontakt project right now, but I am kinda stuck. I am planning to make a sort of randomizer with musical keys. So my purpose is that when the randomizer is on and a certain key is chosen, only the notes inside that key will play randomly. So I started making a ui_menu including major keys and arrays, each for a specific key. So far I am here:

on init
 declare %CMaj[22] := (60,62,64,65,67,69,71,72,74,76,77,79,81,83,84,86,88,89,91,93,95,96)
 declare %GMaj[22] := (60,62,64,66,67,69,71,72,74,76,78,79,81,83,84,86,88,90,91,93,95,96)
 declare %DMaj[22] := (61,62,64,66,67,69,71,73,74,76,78,79,81,83,85,86,88,90,91,93,95,97)
 declare %AMaj[22] := (61,62,64,66,68,69,71,73,74,76,78,80,81,83,85,86,88,90,92,93,95,97)
 declare %EMaj[22] := (61,63,64,66,68,69,71,73,75,76,78,80,81,83,85,87,88,90,92,93,95,97)
 declare %BMaj[22] := (61,63,64,66,68,70,71,73,75,76,78,80,82,83,85,87,88,90,92,94,95,97)

 declare ui_menu $Maj_key_menu

 add_menu_item($Maj_key_menu,"C",0)
 add_menu_item($Maj_key_menu,"G",1)
 add_menu_item($Maj_key_menu,"D",2)
 add_menu_item($Maj_key_menu,"A",3)
 add_menu_item($Maj_key_menu,"E",4)
 add_menu_item($Maj_key_menu,"B",5)

 make_perfview

end on


on note

 message($EVENT_NOTE)

 while ($Maj_key_menu<14 and ($EVENT_NOTE=24))

  while ($NOTE_HELD=1)

   play_note(%CMaj[random(0,22)],10,0,-1)

   wait(1000000)

  end while

 end while

end on

is there a way to not repeat the on note part? I am also not so sure that I am doing the array the right way. Sorry for this many questions.

Thanks in advance to whoever will lose their time on this.

Back To Top