KONTAKT - Script with while-loops nested that stop on the way

VST, AU, AAX, CLAP, etc. Plugin Virtual Instruments Discussion
Post Reply New Topic
RELATED
PRODUCTS
Kontakt$299.00Buy

Post

Hi world,

Here is a nested while-loops executed on the init callback that I can't make it finish, since it stop somewhere when the instruments have many groups, and everything that is after it.
Tons of things have been left out to make it very simple here, leaving only the "add_text_line", but as it flow, it should go storing values on big arrays.

Code: Select all

	$groups := 0
	while ($groups < $NUM_GROUPS)
		add_text_line($whatever, group_name($groups) & " " & $groups)
		$acount := 0
		while ($acount < 40)
				add_text_line($whatever,"acount: " & $acount)
				$xcount := 0
				while ($xcount < 9)
					add_text_line($whatever,"xcount: " & $xcount)
					inc($xcount)
				end while
			inc($acount)
		end while
		inc($groups)
	end while
Cheers

Post

Loops in KSP have a maximum of around 30-40k iterations. If you have a huge number of groups, this is why your above code won't work.

If you need to initialize a huge array, I suggest using a NKA file loaded from resource container (load_array() mode 2 - but if you're on K4 still, this won't work).

Post

Thanks for the info EvilDragon, but finally I found out days ago that it will work only if there's a short wait on the while-loop; and since it cannot be done from the init callback, the while-loop must put on a function invoked with a trigger pgs callback. Works like a charm now, I can't believe it!

Post Reply

Return to “Instruments”