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.

1

Friday, September 24th 2010, 10:12pm

basic question about triggering actions with key

hi,

i want trigger an action with a key, and launch a reverse action with the same key,
with the code below, first action is triggered but clicking a second time the same key do nothing, so what's wrong i my code ?? *unsure*

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
<events 

	onkeydown="action(keydown);"
	onkeyup="action(keyup);"
 />

	<action name="keydown">
 	if(keycode == 186, if(key186_pressed != true, hide_map(); set(key186_pressed,true););  );
	</action>
	
	<action name="keyup">
 	 if(keycode == 186, show_map(); set(key186_pressed,false); );
	</action>


thanks

2

Friday, September 24th 2010, 10:41pm

Quoted

- if/ifnot(condition, trueaction, falseaction) action
- condition:
- varA
- only one variable as parameter
- this variable will be compared against "true"
- varA OPERATOR varB
- compare two variables
- the below for all possible operators
- trueaction - actions that will be called on true
- falseaction - actions that will be called on false
- usage examples:
if(fullscreen, action(fullscreen_setup), action(windowmode_setup) );
if(view.vlookat GE 45, set(view.vlookat, 45) );
if(plugin[xyz].visible == true, set(plugin[xyz].visible,false) );


;-)

3

Friday, September 24th 2010, 11:20pm

sorry , i 'm too tired i cannot figure out what's wrong...
try later...

Thanks

4

Sunday, September 26th 2010, 10:01am

Anybody else ??

Thanks

(should be in wiki)

michel

Professional

Posts: 1,153

Location: ANDORRA

Occupation: TV

  • Send private message

5

Sunday, September 26th 2010, 7:36pm

Hi zadda,

Your code above works as it is supposed it has to do... But, I suppose that it does not do what you wants it to do... If you are looking to make an hide/show action pressing a key, perhaps this modified code could help:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
	<events	onkeydown="action(keydown);" />

	<action name="keydown">
		if(keycode == 186,
				if(key186_pressed != true,
						show_map(); set(key186_pressed,true);
						,
						hide_map(); set(key186_pressed,false);
					);
			);
	</action>

	<action name="hide_map">set(plugin[name].visible,false);</action>

	<action name="show_map">set(plugin[name].visible,true);</action>


Hope this help...

SAlut.

6

Sunday, September 26th 2010, 8:28pm

Hi Michel,

Quoted


Your code above works as it is supposed it has to do... But, I suppose that it does not do what you wants it to do...

definitely... *smile*

one more time you save my day *g*
i don't know why, but my brain got hard time with intricated conditionals *wacko*

(btw i understand job.1 reply, he surely want i improve my krpano knowledge and skills but unfortunately sometimes i'm stuck somewhere and my mind lock up *unsure* )

so, i hope this code snippet will be added in the wiki, because that's very handy, not only to show/hide a map for example but also to display/hide options/editor when working on hotspots :

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<events 

	onkeydown="action(keydown);"
	onkeyup="action(keyup);"
   
        />

<action name="keydown">
	 <!-- Setup editor and Options when "Enter" key Down (French Azerty Keyboard - keycode "Enter" = 13) -->
	if(keycode == 13,
				if(key13_pressed != true,
						addeditor(); set(key13_pressed,true);
						,
						removeeditor(); set(key13_pressed,false);
					);
			);
	</action>

<!-- actions to add/remove options/editor plugin -->
	<action name="addeditor">
	addplugin(options);
	set(plugin[options].url,krpano_files/options.swf);
	addplugin(editor);
	set(plugin[editor].url,krpano_files/editor.swf);
	</action>

	<action name="removeeditor">
	removeplugin(options);
	removeplugin(editor);
	</action>


Thanks Michel

Tuur

Sage

Posts: 3,239

Location: Netherlands

Occupation: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer

  • Send private message

7

Monday, September 27th 2010, 2:51am

i did it like this... with the keys

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<events onkeydown="checkkey();" />

<action name="checkkey">
  trace('keycode=', keycode);
  if(keycode == 83, action(kick));
  if(keycode == 68, action(snare));
  if(keycode == 70, action(tom));
  if(keycode == 75, action(floor));
  if(keycode == 76, action(hh));
  if(keycode == 80, action(cymbal));
  if(keycode == 82, action(crash_left));
  if(keycode == 73, action(crash_right));
  if(keycode == 32, action(kick_big));
  
</action>

	
	<!-- kick		= 	S
		snare		= 	D
		tom			=	J
		floor		=	F
		hh			=	L
		cymbal		=	P
		crash_left 	=	U
		crash_right	=	R
		kick_big   	=	space
	
	
	-->
	
	
	
<action name="kick">
    	playsound(auto, kick.mp3, 1);
	   	lookat(20,47,45);
	    
		</action>
		
<action name="snare">
    	playsound(auto, snare.mp3, 1);
	   	lookat(-3,49,35);
	    
		</action>
		
<action name="tom">
    	playsound(auto, tom.mp3, 1);
	   	lookat(16,27,35);
	    
		</action>
		
<action name="floor">
    	playsound(auto, floor.mp3, 1);
	   	lookat(55,41,45);
	    
		</action>
		
<action name="hh">
    	playsound(auto, hh.mp3, 1);
	   	lookat(-31,26,45);
	    
		</action>
		
<action name="cymbal">
    	playsound(auto, cymbal.mp3, 1);
	   	lookat(42,18,45);
	    
		</action>
		
<action name="crash_left">
    	playsound(auto, crash_left.mp3, 1);
	   	lookat(-35,-3,45);
	    
		</action>
		
<action name="crash_right">
    	playsound(auto, crash_right.mp3, 1);
	   	lookat(65,-1,45);
	    
		</action>
		
<action name="kick_big">
    	playsound(auto, kick_big.mp3, 1);
	   	lookat(119,29,45);
	    
		</action>

	
	
	
	<action name="loop">
    	playsound(loop, loop.mp3, 1, 0.0, 20);
	   
	    
		</action>



http://www.virtualtuur.com/studio

but what you do is smart aswell ! gonna use that..

cheers

Tuur *thumbsup*
http://www.virtualtuur.com
Skype:studiotuur

8

Monday, September 27th 2010, 2:50pm

well see Tuur,

nice example of interactivity,
let's drum now ! *g*

z

Similar threads