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.

Tuur

Sage

  • "Tuur" started this thread

Posts: 3,164

Location: Netherlands

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

  • Send private message

1

Wednesday, May 5th 2010, 10:19pm

if / else

Hi ,

I like to do an if /else thing (in xml)... so that it gets if a certain panorama (xml) is loaded...

Is that possible??

for example:

Source code

1
2
3
4
<action name="areasur">
set(area4,get(pano[3.xml].visible));
		if(area4  == false, set(plugin[surounding].visible,false);, set(plugin[surounding].visible,true);
</action>


any idea?

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

2

Friday, May 7th 2010, 12:24pm

Hi,

the url of the current xml is stored in the "xml.url" variable,
so you could do:

Source code

1
if(xml.url == '3.xml', ...);


best regards,
Klaus

Tuur

Sage

  • "Tuur" started this thread

Posts: 3,164

Location: Netherlands

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

  • Send private message

3

Friday, May 7th 2010, 12:26pm

GREAT!!

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

4

Friday, May 7th 2010, 4:49pm

RE: if / else

Hi ,

I like to do an if /else thing (in xml)... so that it gets if a certain panorama (xml) is loaded...

for example:

Source code

1
2
3
4
<action name="areasur">
set(area4,get(pano[3.xml].visible));
		if(area4  == false, set(plugin[surounding].visible,false);, set(plugin[surounding].visible,true);
</action>



Tuur,

In your code example, you're trying to use an array and addressing it with the xml name. Great idea, but unfortunately this won't work for a couple of reasons: 1) names of array elements can't contain a period 2) in your example, names of array elements can't start with a number.

Problem 1 could be addressed by using the basename of the xml file name (the part of the name before the .xml). Problem 2 could be addressed by prepending the names of the array with a character or string (for instance _1 or pano_1).

As far as I know, extracting the basename for your xml.url cannot be done in the krpano action language without going into javascript. It would be nice if Klaus provided a xml.basename attribute and/or a %BASENAME% macro that would resolve everywhere (not just in url attributes). I actually use this technique and preprocess the xml files using perl to get the basenames.

Some other ways to accomplish this:

1) Write an onxmlcomplete function which uses if statements to set the visible attribute:

Source code

1
2
3
	if (xml.url == "3.xml",set(plugin[surrounding].visible,true));
	if (xml.url == "4.xml",set(plugin[surrounding].visible,false));
	...


This is a little harder to maintain because you're hardcoding file names into your function, but it will work...

2) Include the surrounding plugin only in the xmls you in which you want it to appear and set keep="false"

3) Include a variable in the krpano tag which you use to set the visibility

Source code

1
2
3
4
5
6
7
8
<krpano version="1.0.9" surroundingvis="true" >

<events onxmlcomplete="onxmlcomplete()" />

<action name="onxmlcomplete">
	copy(plugin[surrounding].visible,surroundingvis);
</action>
</krpano>

Of course, you'll need to remember to put the surroundingvis attribute in the krpano tag for every xmlfile.

Hope this helps.

steve

Tuur

Sage

  • "Tuur" started this thread

Posts: 3,164

Location: Netherlands

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

  • Send private message

5

Friday, May 7th 2010, 6:40pm

Hi Steve,

Thanx for the explanation.. i try to understand...

I also get crazy to understand the %Basename % thing sand the %1 , %2 things.. but that is an other thing..

What i try to achieve is that i want to make a plugin only visible when a certain pano is loaded...
But then not triggered by an action.. So is this (for example) drumset pano is loaded, in the code,
that i say. Ahhh that one is loaded so let's make the plugin visible...

actualy i like to make a hotspot, keep false.. with an x and y option and no atv ath
and a parent stage position (also when no stage is set) so that when i turn the pano that it stay at the same screen spot.. like you can do with a plugin..
but a plugin needs to be triggered when visible false by an action..
I need the hotspot/plugin to be triggered when 'the code' knows that we are looking to a specific panorama,

plugin keep = false would do also the trick but i don'y want it loaded before this pano is visited ( we are talking a lot of pano's)

so keep is false but also visible is true and just loaded with the pano when visited.. as an hotspot does..






So when i understand you guys well i can do..


Source code

1
2
3
4
5
6
7
8
9
<action name="tuur">
...


if(xml.url == '3.xml', set(plugin[pinsane].visible,true);, set(plugin[pinsane].visible,false);


...
</action>



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

This post has been edited 1 times, last edit by "Tuur" (May 7th 2010, 11:05pm)