Need a help with "for" krpano action command

  • Hi everyone,

    I've got an action I need to start couple of times in looping. For example it is something like:
    <action name="shownext">
    showtext('test', infostyle);
    wait(5);
    showtext('test2', infostyle);
    wait(5);
    inc(i);
    </action>


    I tried loop() and for() commands. Both do not work.

    LOOP code:
    set(i,0);
    loop(i LT 10, action(shownext));

    FOR code:
    for(set(j,0), j LT 10, inc(j), action(shownext););

    I don't know what to think about *cursing* May be you have some suggestions. I would be very appreciated.

    Just to test I tried to use IF statemen like:
    set(i,0);
    if(i LT 10, action(shownext)); and it perfectly works. It starts action "shownext" with no issues! So there is something wrong with LOOP or FOR commands

    Thank you,
    Sergey

  • Hi there

    I tried your example, and the loop is working fine. The problem is that "showtext" only shows the text for a fraction of second, since it's meant to be used with "onhover".

    To display the text for a larger amount of time, you can use an asyncfor(), as shown below. However, the rest of the code gets a bit tricky, so it's better if you let us know exactly what it is you want to do.

    This shows the text for 100 frames:

    Code
    asyncfor(set(i,0), i LE 100, inc(i), showtext(test));


    To change between texts, you would need two actions, which call each other whenever the loop is over:


    <!-- %1 - time to loop -->
    <action name="show1">
    asyncfor(set(i,0), i LE %1, inc(i),
    if(i == %1,
    trace(changing to 2);
    show2(%1),
    showtext(test);
    );
    );
    </action>

    <action name="show2">
    asyncfor(set(j,0), j LE %1, inc(j),
    if(j == %1,
    trace(changing to 1);
    show1(%1),
    showtext(test2);
    );
    );
    </action>

    As I said, it's a bit tricky. It could also work with the new tween() which executes an action after every frame. But it's better to know what it is you're trying to do exactly *wink*

  • Thank's mate!

    So you mean I can't easily replace showtext(test) in your example (asyncfor(set(i,0), i LE 100, inc(i), showtext(test));) to the action easily? OK. I see.

    What I am trying to achive? I've got a tour. When the tour is started I show a demo. It works as an action. The task is to show this demo in a loop for hours (I'll have a big screen on a presentation). Demo starts and stops at the same position and it is 5 minutes long. I thought it would be great to perform 100 cycles - more than enough for my task, so I just need to start the same demo action 100 times.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!