- Home /
Question by
zacharyaghaizu · Feb 02, 2021 at 09:04 AM ·
instantiatefunctionsinstantiation
How would I make this Cloned Function Copy to an endless amount?
This shows how each if will bring a copy of AddSoundObjectRec(1); and it will copy then increase each time. There is definitely a better way to write this that isn't manual?
if(layeramount==1)
{
AddSoundObjectRec(1);
}
if(layeramount==2)
{
AddSoundObjectRec(1);
AddSoundObjectRec(2);
}
if(layeramount==3)
{
AddSoundObjectRec(1);
AddSoundObjectRec(2);
AddSoundObjectRec(3);
}
Comment
Best Answer
Answer by AbandonedCrypt · Feb 02, 2021 at 09:07 AM
im writing this in browser, so take it as pseudocode:
for(int i = 0; i < layeramount; i++)
{
AddSoundObjectRec(i + 1);
}
or
for(int i = 1; i <= layeramount; i++)
{
AddSoundObjectRec(i);
}
both should work, second one is index shifted by 1, as to be more in line with the layeramount, basically just as to be able to use the index itself to parse to AddSoundObjectRec without having to use an add-1-operation each time.
Your answer
