You are not logged in.

Dear visitor, welcome to krpano.com Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

mstoss

Intermediate

  • "mstoss" started this thread

Posts: 198

Location: Berlin

  • Send private message

1

Friday, April 27th 2012, 12:32pm

does a for loop prevent plugins from reacting?

Hi,

I have scripted a loop which shows different states of an object, a bit like a slide show, right before the tour is running. When the loop is finished, the pano starts. This works nicely so far, but now I want to add a button to stop the loop and find that the button is not even enabled. Without the loop, the button is working. Is a loop like this:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
	<action name="start-ani">
			set(plugin[ani-bg].visible,true);
			tween(plugin[ani-bg].alpha,1,2);
			for(set(i,1), i LT %1, inc(i),
									txtadd(ani-name,'ani-',get(i));
									set(plugin[get(ani-name)].zorder,get(i));
									set(plugin[get(ani-name)].visible,true);
									tween(plugin[get(ani-name)].alpha,1,3);
									wait(5);
				);
			wait(5);
			stop-ani();
			set(autorotate.enabled,true); set(autorotate.speed,-3);set(autorotate.waittime,10);


preventing KRPano from listening to other user events?

Any help appreciated very much!

Michael

This post has been edited 1 times, last edit by "mstoss" (Apr 27th 2012, 2:06pm)


2

Friday, April 27th 2012, 1:03pm

Hi Micheal,

I not really checked your code, but the "wait" might be the problem. Did you try to use the "delayedcall" instead? The wait-command deactivates the whole tour until the time is over.

BR
Nupsi

mstoss

Intermediate

  • "mstoss" started this thread

Posts: 198

Location: Berlin

  • Send private message

3

Friday, April 27th 2012, 1:18pm

Thank you so much Nupsi, that sounds after a good explanation. I'll try to replace the wait().

mstoss

Intermediate

  • "mstoss" started this thread

Posts: 198

Location: Berlin

  • Send private message

4

Friday, April 27th 2012, 2:04pm

Hm. This does not work as expected, unfortunately.

Adding wait() obviously kills it all, you are right. But adding delayedcall() does not work neither.

I tried this:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
	<action name="start-ani">
			set(plugin[ani-bg].visible,true);
			tween(plugin[ani-bg].alpha,1,2);
			for(set(i,1), i LT %1, inc(i),
						delayedcall
						(2,
							ani-go(get(i)););
						);
			stop-ani();
	</action>
	
	<action name="ani-go">
	  			txtadd(ani-name,'ani-',%1);
				trace(ani-name);
				set(plugin[get(ani-name)].zorder,%1);
				set(plugin[get(ani-name)].visible,true);
				tween(plugin[get(ani-name)].alpha,1,3);			
	</action>


Adding wait() does work, it delays the loop but for the price of a totally passive behavior. Omitting wait results in no visible action at all, the animation elements don't show up, whilst trace shows, that the plug-in name is counted as it should.

Sigh...

inno

Trainee

Posts: 81

Location: Wyk auf Föhr

  • Send private message

5

Sunday, April 29th 2012, 4:18pm

Hi

from the documentation I get this

Quoted

Note - The user interface and all other actions are blocked during the waiting. That means
the next action will be executed when the current action was done. The oninterrupt
action can be used to make this action interrupt able by the user.

May the oninterrupt feature help?
Also the async version of loop/for could do the trick?

Greetings
Peter

mstoss

Intermediate

  • "mstoss" started this thread

Posts: 198

Location: Berlin

  • Send private message

6

Monday, April 30th 2012, 10:49am

Thank you Peter! I'll try that as well.

Michael

mstoss

Intermediate

  • "mstoss" started this thread

Posts: 198

Location: Berlin

  • Send private message

7

Monday, April 30th 2012, 12:05pm

I tried both the oninterrupt and asyncfor-loop. Oninterrupt is working so far by letting me stop the slide-show, but nothing more.

Maybe I am completely wrong with this approach?

Has anyone an idea to achieve this slide-show like effect?

1. On pano start the panorama is dimmed to be a background image only by some bg-image.jpg - DONE
2. A background image (ani-bg-image.jpg, set to be a parent object) for the slide show with 2 buttons to stop/restart the slide-show is tweening in. -DONE
3. The elements of the slide show are defined as child objects, set to invisible, alpha 0, disabled, their names being different only by a number (ani-1, ani-2 ... etc.). - DONE
4. An action which is displaying the child objects one by one, with adjustable duration before the next element is shown DONE SO FAR BUT NOT WORKING together with
5. Option to stop the slide-show or restart it.

Hm. Is there something like an array in KRPano?

Michael

inno

Trainee

Posts: 81

Location: Wyk auf Föhr

  • Send private message

8

Monday, April 30th 2012, 4:04pm

Hi Michael,


couldn't you use a kind of 'state-variable' which you toggle in the oninterrupt-action and according to the current state you execute your
delayedcall ani-go(get(i)

I think, more as a sketch, this way

Source code

1
oninterrupt( if(StopSlide,set(StopSlide,False),set(StopSlide,True)));


Your for loop could be modified like this

Source code

1
2
for...
ifnot(StopSlide==True,ani_go(%1))...


As mentioned just a rough idea, syntax me be wrong....

LG
Peter

mstoss

Intermediate

  • "mstoss" started this thread

Posts: 198

Location: Berlin

  • Send private message

9

Friday, May 4th 2012, 10:50pm

Thank you once again, Peter. A rough idea was just what I needed :-)

Anyway, I stepped back from the whole interrupt idea in favour of another approach. The problem was caused by the inactive buttons during the for loop running, the finished loop starting the panorama immediately. So no chance to press a stop, start button, right? Now I simply let the for loop run til its end and keep the panorama paused. Then the buttons are working as usual so that I can place a Restart Animation or Start Panorama Tour button beneath the animation. When the client has accepted this solution, I might place a link.

Thank you very much Nupsi and Peter for your thoughts so far.

Michael