You are not logged in.

Tuur

Sage

  • "Tuur" started this thread

Posts: 3,839

Location: Netherlands

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

  • Send private message

1

Wednesday, April 18th 2012, 6:21pm

syntax question..

Hi,

maybe a stupid question:

imagin that i have 2 or more plugins.
One i give an id
and that id i want to manipulate with an if call.

I make a stupid mistake somewhere:

Source code

1
2
3
4
5
6
7
8
9
10
<plugin name="btn_help" url="../skin/buttons/btn_help.png" style="tour_btn" id="tourbtn" ondown=""  y="150" />
<plugin name="btn_gyro" url="../skin/buttons/btn_gyro.png" style="tour_btn" id="tourbtn" ondown=""  y="170" />
<plugin name="btn_rotate" url="../skin/buttons/btn_rotate.png" style="tour_btn" id="tourbtn" ondown=""  y="190" />

<action name="show_tourmenu">

if(id == tourbtn, set(visible,true); );


</action>


does not work..

what is going wrong?
I hope for quick reply..
Thanx

Tuur *thumbsup*

Zephyr

Professional

Posts: 1,003

Location: Netherlands

Occupation: Web developer

  • Send private message

2

Wednesday, April 18th 2012, 7:14pm

Source code

1
2
3
4
5
for(set(i, 0), i LT plugin.count, inc(i),
      if(plugin[get(i)].id == tourbtn,
           set(plugin[get(i)].visible, false);
      );
);


You cant mass asign plugins based on id like that, you need to say it 1 by 1.

Usually with stuff like this, I create a plugin with a 2x2 empty png as url, and I use that as parent for the rest (scalechildren false) then I just hide the parent and the rest follows.

Posts: 1,857

Occupation: Virtual Tours - Photography - Krpano developer

  • Send private message

3

Wednesday, April 18th 2012, 7:16pm

That would work only if the action was called in the onloaded of each plugin.
You need to cycle through the plugin array to check for the id and then continue.

Source code

1
2
3
4
5
		for(sub(i,plugin.count,1), i GE 0, dec(i), 
			if(plugin[get(i)].id =='tour_btn',
				set(plugin[get(i)].visible,true);
			);
		);


use the groups action code instead..its been posted a bunch of times but I forget the link. Or you can remake it with what I posted and fill it with arguments.
KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour

Tuur

Sage

  • "Tuur" started this thread

Posts: 3,839

Location: Netherlands

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

  • Send private message

4

Wednesday, April 18th 2012, 7:16pm

Ok Thanx Zephyr,

but i remember an other way, more similar to my example ,you told me some months ago..

well

i give it a try..

Thanks for quick reply!!

Tuur *thumbsup*

Tuur

Sage

  • "Tuur" started this thread

Posts: 3,839

Location: Netherlands

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

  • Send private message

5

Wednesday, April 18th 2012, 7:18pm

Yess..

works perfect!!!

Thanx!!

*g* *g* *g* *g* *g*


@Sacha, that group thing was what i was looking for in the beginning
http://www.krpano.com/forum/wbb/index.ph…18945#post18945
..but for now this is better..

Tuur *thumbsup*

Zephyr

Professional

Posts: 1,003

Location: Netherlands

Occupation: Web developer

  • Send private message

6

Wednesday, April 18th 2012, 7:26pm

I don't know another way. I usually dont loop through all the plugins. If you have a lot, it sometimes misses one or there's some lag. So I usually do the parent system thing or I put all the elements in an array and loop that.

Perhaps this would work:

Source code

1
set(style[tour_btn].visible, false);

Im not sure, would be epic if it did. Perhaps feature request ?:P

Tuur

Sage

  • "Tuur" started this thread

Posts: 3,839

Location: Netherlands

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

  • Send private message

7

Wednesday, April 18th 2012, 7:29pm

no style things you can't manipulate..
i asked Klaus already..

Would be nice though!!

Tuur *thumbsup*

Zephyr

Professional

Posts: 1,003

Location: Netherlands

Occupation: Web developer

  • Send private message

8

Wednesday, April 18th 2012, 7:30pm

Yess..

works perfect!!!

Thanx!!

*g* *g* *g* *g* *g*


@Sacha, that group thing was what i was looking for in the beginning
http://www.krpano.com/forum/wbb/index.ph…18945#post18945
..but for now this is better..

Tuur *thumbsup*


This describes the same method, only more global (any type of attribute)

Posts: 1,857

Occupation: Virtual Tours - Photography - Krpano developer

  • Send private message

9

Wednesday, April 18th 2012, 7:59pm

Exactly, the code I posted an evolution of the same code, optimized with the new "for" action.
This lets you only need 5 lines and 1 action. All you need to do is replace the particulars with arguments.

@zephr.. FUNNY! Same code, you went up and I went down.

Yess..



@Sacha, that group thing was what i was looking for in the beginning
http://www.krpano.com/forum/wbb/index.ph…18945#post18945
..but for now this is better..

Tuur *thumbsup*
KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour

Tuur

Sage

  • "Tuur" started this thread

Posts: 3,839

Location: Netherlands

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

  • Send private message

10

Wednesday, April 18th 2012, 8:02pm

ok next,

why does this not work?

Source code

1
2
3
4
5
for(set(i, 0), i LT plugin.count, inc(i),
      if(plugin[get(i)].tag == menu,
           tween(plugin[get(i)].x, -200,3);
      );
);

i also tried:

Source code

1
2
3
4
5
for(set(i, 0), i LT plugin.count, inc(i),
      if(plugin[get(i)].tag == menu,
           switch(plugin[get(i)].x, -200,10);
      );
);



*confused*

difficult for me..

Tuur *thumbsup*

Tuur

Sage

  • "Tuur" started this thread

Posts: 3,839

Location: Netherlands

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

  • Send private message

11

Wednesday, April 18th 2012, 8:10pm

i also try with switch and tween.. i like to us ethat actualy

Source code

1
2
3
4
5
for(set(i, 0), i LT plugin.count, inc(i),
      if(plugin[get(i)].tag == menu,
           switch(tween(plugin[get(i)].x,-200,3);, tween(plugin[get(i)].x,10,3));
      );
);


*confused*

Zephyr

Professional

Posts: 1,003

Location: Netherlands

Occupation: Web developer

  • Send private message

12

Wednesday, April 18th 2012, 8:30pm

you can't switch actions.

A switch checks if a variable has value of x, else set it to y and vica versa. An action like tween can't be checked.


Quoted

@zephr.. FUNNY! Same code, you went up and I went down.


Haha, but mine has fewer characters and 1 method less to execute! *tongue* beat you by 0,0001 ms

Posts: 1,857

Occupation: Virtual Tours - Photography - Krpano developer

  • Send private message

13

Wednesday, April 18th 2012, 8:35pm

There looks to be a bug in krpano..
Your code should work.. and even when I have it all stripped down.. the first tween doesn't tween, but jumps immediately.

Source code

1
2
3
4
	<action name="set_hotspots/plugin3">
		trace('tween(plugin[',%1,'].',%2,',',%3,')');
		tween(plugin[%1].%2,%3);
	</action>
KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour

Zephyr

Professional

Posts: 1,003

Location: Netherlands

Occupation: Web developer

  • Send private message

14

Wednesday, April 18th 2012, 8:40pm

it's not really a bug. You can't tween 2 objects at the same time or even 2 properties. you have to add a wait(blend) between it or use asyncfor.

Tuur

Sage

  • "Tuur" started this thread

Posts: 3,839

Location: Netherlands

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

  • Send private message

15

Wednesday, April 18th 2012, 8:43pm

but this sould work isn't it

Source code

1
2
3
4
5
for(set(i, 0), i LT plugin.count, inc(i),
      if(plugin[get(i)].tag == menu,
           tween(plugin[get(i)].x, -200,3);
      );
);


Tuur *thumbsup*

Posts: 1,857

Occupation: Virtual Tours - Photography - Krpano developer

  • Send private message

16

Wednesday, April 18th 2012, 8:46pm

it's not really a bug. You can't tween 2 objects at the same time or even 2 properties. you have to add a wait(blend) between it or use asyncfor.


Just my action only tweened 1 plugin...

Anyway, yes, it looks like you are right, you can not tween even with asycfor reliably more than one thing at the same time. Much better to use the parent system.
KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour

This post has been edited 1 times, last edit by "sachagriffin" (Apr 18th 2012, 9:21pm)


Tuur

Sage

  • "Tuur" started this thread

Posts: 3,839

Location: Netherlands

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

  • Send private message

17

Wednesday, April 18th 2012, 9:15pm

i also tried with:

switch(destpos, -100, 0, +100); tween(x,get(destpos));

no succes..

Tuur *thumbsup*

Zephyr

Professional

Posts: 1,003

Location: Netherlands

Occupation: Web developer

  • Send private message

18

Wednesday, April 18th 2012, 11:31pm

Because everytime you loop, the destpos gets overwritten, back to 0.

Setting all visibility to a certain value is doable with the loop. But if you want to tween multiple things at the same time, then you need to use the parent system.

19

Thursday, April 19th 2012, 4:31pm

Hi,

Quoted

why does this not work?

for(set(i, 0), i LT plugin.count, inc(i),
if(plugin[get(i)].tag == menu,
tween(plugin[get(i)].x, -200,3);
);
);
here the variable - "plugin[get(i)].x" - will be tweened - but the problem here is the 'get(i)' it will be resolver every tween step, but at that time the 'i' variable has already a different value,

here a helper action would need to be used to pass the resolved 'i' variable,
e.g.

Source code

1
2
3
<action name="helperaction">
  tween(plugin[%1].x, -200,3);
</action>

and

Source code

1
2
3
4
5
for(set(i, 0), i LT plugin.count, inc(i),
      if(plugin[get(i)].tag == menu,
            helperaction(get(i));
      );
);  


best regards,
Klaus

Posts: 1,857

Occupation: Virtual Tours - Photography - Krpano developer

  • Send private message

20

Thursday, April 19th 2012, 6:32pm

That's awesome Klaus!
It works great!
So you can tween multiple plugins/hotspots at the same time. It was just an issue of understanding the frames in which actions and tweens work.
KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour