Return to site

Javascript remove empty slots in array

broken image

$t_stream(_loading)įunc _soundArrayFill(): # fill array if empty and check for empty values (what am i doing wrong here?) If Input.is_action_just_released('_interact'): # if array empty on button release, reload itįunc _soundLoader(): # load sound from array If Input.is_action_just_pressed('_interact'): Var _preloadArray = įunc _ready(): # here the array fills with exported values, ignore the prompt, that's workingįunc _process(_delta): # listen for input every frameįunc _soundTrigger(): # listen for input I don't want to have to write this code for every item that uses it.

broken image

I have tried loops to remove empty strings and other things and it continues to plug in the empty values. (Think the piano sounds at Bioshock's opening menu).

broken image
broken image

Essentially, if a 'slot' in the array is empty, I want to remove it before the load. I am exporting six values to fill this array but don't need all six slots each time (using this code across multiple objects that won't all need six sound files). I have an array of sounds that trigger, one at a time, from an array of loads.

broken image