So, I'm basically trying to create an array of all the shaders in a scene. I have this going so far, but was wondering how to put the looping bit into a separate proc, and have the appended array returned to the global procedure below. I've never been able to successfully setup something like this. Any help would be appreciated.

global procgetMeshes ()
{
    string $shaders[];
    string $additionalShaders[];

    $additionalShaders = lsType "phong";
    if (size $additionalShaders > 1)
    {
        stringArrayRemoveAtIndex(((size $additionalShaders) -1), $additionalShaders); // Removes the '' value in the last index.
        appendStringArray ($shaders, $additionalShaders, (size $additionalShaders));
        clear $additionalShaders;
    }
    $additionalShaders = lsType "phongE";
    if (size $additionalShaders > 1)
    {
        stringArrayRemoveAtIndex(((size $additionalShaders) -1), $additionalShaders);
        appendStringArray ($shaders, $additionalShaders, (size $additionalShaders));
        clear $additionalShaders;
    }
    $additionalShaders = lsType "lambert";
    if (size $additionalShaders > 1)
    {
        stringArrayRemoveAtIndex(((size $additionalShaders) -1), $additionalShaders);
        appendStringArray ($shaders, $additionalShaders, (size $additionalShaders));
        clear $additionalShaders;
    }
    $additionalShaders = lsType "blinn";
    if (size $additionalShaders > 1)
    {
        stringArrayRemoveAtIndex(((size $additionalShaders) -1), $additionalShaders);
        appendStringArray ($shaders, $additionalShaders, (size $additionalShaders));
        clear $additionalShaders;
    }

    print ($shaders);

}

Separately... the insert code thingy for creating these threads never seems to work for me. Anyone else have this issue? It just pasts the html stuff into the thread, and not my code.

  • created

    Jun '11
  • last reply

    Jul '11
  • 1

    reply

  • 1.9k

    views

  • 1

    user

11 days later

So, I think I figured out why I've been having issues with local procedures not executing. Most, if not all of the procs I've been calling I've been trying to call as the command value of a button. Apparently, that's a "No-no." Wasn't aware of this. I can restructure things to have the main, global proc, call the local one. Should be a simple enough fix. So, if anyone else is having an issue, such as a, "Can't find procedure ..." when you know its there... this could be the issue.

I should be able to put the above, repetitious bit into a local proc, then just call:

getAdditionalShaders (phong);
getAdditionalShaders (phongE);
... etc.