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

Wednesday, May 19th 2010, 4:35pm

variables in plugins

I think I can make this xml easier:

<plugin name="thumb2_blah" url="skin/thumbs/blah.jpg" keep="true" x="5" y="5" visible="false" />
<plugin name="thumb2_blah2" url="skin/thumbs/blah2.jpg" keep="true" x="5" y="5" visible="false" />
<plugin name="thumb2_blah3" url="skin/thumbs/blah3.jpg" keep="true" x="5" y="5" visible="false" />
<plugin name="thumb2_blah4" url="skin/thumbs/blah4.jpg" keep="true" x="5" y="5" visible="false" />
<plugin name="thumb2_blah5" url="skin/thumbs/blah.jpg5" keep="true" x="5" y="5" visible="false" />

In php I would use variables, but I don't know if that is also possible in krpano xml?

The way I 'call' the plugin is:
<plugin name="thumb_blah" url="skin/thumbs/blah.jpg" x="0" y="28" onhover="showtext(blabla);set(plugin[thumb2_blah].visible,true);" onout="set(plugin[thumb2_blah].visible,false);" onclick="loadpano(blah.xml);" />

Is it possible to use only one line instead of 5 (in my case 24)? If yes, how?

Thanks in advance! And it's a pity the documentation on the website is not so good / updated.

michel

Professional

Posts: 1,153

Location: ANDORRA

Occupation: TV

  • Send private message

2

Wednesday, May 19th 2010, 8:04pm

Hi maaike,

Perhaps you can define a generic thumb2_ plugin and set dynamically his url and visibility ...
Something like this:

Source code

1
2
3
4
5
6
7
<plugin name="thumb2_generic" url="" keep="true"  x="5" y="5" visible="false" />

<plugin name="thumb_blah" url="skin/thumbs/blah.jpg" x="0" y="28"
	onhover="showtext(blabla);"
	onover="set(plugin[thumb2_generic].url,skin/thumbs/blah.jpg);set(plugin[thumb2_generic].visible,true);"
	onout="set(plugin[thumb2_generic].visible,false);"
	onclick="loadpano(blah.xml);" />


SAlut.

3

Wednesday, May 19th 2010, 10:02pm

RE: variables in plugins

Is it possible to use only one line instead of 5 (in my case 24)? If yes, how?
Do this in one line? Sure!

Source code

1
<plugin name="thumb2_blah" url="skin/thumbs/blah.jpg" keep="true" x="5" y="5" visible="false" /><plugin name="thumb2_blah2" url="skin/thumbs/blah2.jpg" keep="true" x="5" y="5" visible="false" /><plugin name="thumb2_blah3" url="skin/thumbs/blah3.jpg" keep="true" x="5" y="5" visible="false" /><plugin name="thumb2_blah4" url="skin/thumbs/blah4.jpg" keep="true" x="5" y="5" visible="false" /><plugin name="thumb2_blah5" url="skin/thumbs/blah.jpg5" keep="true" x="5" y="5" visible="false" />

Just kidding... *g*

Here's how you would do it with variables and actions:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<krpano version="1.0.9" onstart="make_thumbs(thumb2_blah,skin/thumbs/blah,5);" >
<!--make_thumbs name_prefix.str url_prefix.str number.i-->
<action name="make_thumbs">
	if (%3 GT 0,
		addplugin(%1%3);
		set(plugin[%1%3].url,%2%3);
		set(plugin[%1%3].keep,true);
		set(plugin[%1%3].x,5);
		set(plugin[%1%3].y,5);
		set(plugin[%1%3].visible,false);
		sub(action[%0].tmp,%3,1);
		make_thumbs(%1,%2,get(action[%0].tmp));
	);
</action>
</krpano>

The action make_plugins takes 3 arguments. The name prefix, the url prefix, and the number of plugins to create. The syntax to call it is:

Source code

1
	make_plugins(thumb2_blah,skin/thumbs/blah,5);

This recursively makes the thumbs thumb2_blah5, thumb2_blah4, thumb2_blah3, thumb2_blah2, thumb2_blah1. I'm assuming that it is okay for the first thumb to be named thumb2_blah1 rather than thumb2_blah as you showed in your post. If you truly need it to be thumb2_blah (without the 1) simply add an if statement.

Here's a more complex version that uses an array to store the titles for the showtext, and sets the onhover, onout, and onclick values:

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
<krpano version="1.0.9" onstart="make_thumbs(thumb2_blah,skin/thumbs/blah,5);" >

<title name="title for zeroth pano __ never used because we start with one" />
<title name="title for first pano" />
<title name="title for second pano" />
<title name="title for third pano" />
<title name="title for fourth pano" />
<title name="title for fifth pano" />

<action name="make_thumbs">
	if (%3 GT 0,
		addplugin(%1%3);
		set(plugin[%1%3].url,%2%3);
		set(plugin[%1%3].keep,true);
		set(plugin[%1%3].align,leftbottom);
		set(plugin[%1%3].x,5);
		mul(action[%0].tmp,%3,28);
		set(plugin[%1%3].y,get(action[%0].tmp));
		set(plugin[%1%3].alpha,0.2);
		txtadd(action[%0].tmp,"showtext(",get(title[%3].name),");set(plugin[%1%3].alpha,1);");
		set(plugin[%1%3].onhover,get(action[%0].tmp));
		set(plugin[%1%3].onout,set(plugin[%1%3].alpha,0.2););
		set(plugin[%1%3].onclick,loadpano(blah%3.xml););
		sub(action[%0].tmp,%3,1);
		make_thumbs(%1,%2,get(action[%0].tmp));
	);
</action>
</krpano>


Hope this helps

steve

This post has been edited 1 times, last edit by "pinsane" (May 19th 2010, 10:43pm)


Tuur

Master

Posts: 2,251

Location: Netherlands

Occupation: Virtual Tours / Photography / Musician / Recording engineer

  • Send private message

4

Thursday, May 20th 2010, 12:04pm

Hi ,
i try to understand this for a while but i get crazy with tha %1 etc thing..
what does that exactely mean?..

and what when %1%3... how does it now what to get /do..

so i get this..

-------
when this is the action call:

test(abc,123,xyz);

and this the action:

<action name="test">
trace('name of the action=', %0);
trace('p1=', %1);
trace('p2=', %2);
trace('p3=', %3);
</action>

then the %0 - %9 placeholders will be replaced by
the given parameter,

e.g. for:

test(abc,123,xyz);

%0 = test
%1 = abc
%2 = 123
%3 = xyz

so the code will become:

<action name="test">
trace('name of the action=', test);
trace('p1=', abc);
trace('p2=', 123);
trace('p3=', xyz);
</action>
----

i understand.. almost but... how does it now which plugin... *confused*

Thanx
Tuur

This post has been edited 1 times, last edit by "Tuur" (May 20th 2010, 12:40pm)


5

Thursday, May 20th 2010, 1:12pm

Hi,
<plugin name="thumb2_blah" url="skin/thumbs/blah.jpg" keep="true" x="5" y="5" visible="false" />
<plugin name="thumb2_blah2" url="skin/thumbs/blah2.jpg" keep="true" x="5" y="5" visible="false" />
<plugin name="thumb2_blah3" url="skin/thumbs/blah3.jpg" keep="true" x="5" y="5" visible="false" />
<plugin name="thumb2_blah4" url="skin/thumbs/blah4.jpg" keep="true" x="5" y="5" visible="false" />
<plugin name="thumb2_blah5" url="skin/thumbs/blah.jpg5" keep="true" x="5" y="5" visible="false" />
you could use the <style> tag in the xml to share the same attributes,
e.g.

Quoted

<style name="xyz" keep="true" x="5" y="5" visible="false" />

<plugin name="thumb_blah" url="skin/thumbs/blah.jpg" style="xyz" />
<plugin name="thumb2_blah" url="skin/thumbs/blah.jpg" style="xyz" />
<plugin name="thumb3_blah" url="skin/thumbs/blah.jpg" style="xyz" />
...

Quoted

In php I would use variables, but I don't know if that is also possible in krpano xml?
if you want you could still use php to generate the xml,



Thanks in advance! And it's a pity the documentation on the website is not so good / updated.
at the moment I'm working really hard on it, it should have been released already last week

best regards,
Klaus

6

Thursday, May 20th 2010, 3:52pm

Thank you for the clear answers! It work very much like I'm used to ;). Thanks, I'll try. Also style makes it a lot easier!!

I know I can generate an xml with php, but I want to know more about the 'krpano scripting', because sometimes that's easier with clients.
And Klaus, I'm looking forward to the very good documentation ;). I know that's a lot of work.

7

Tuesday, May 25th 2010, 11:33am

Hi,

I have detached the very great tutorial from pinsane to a separate forum thread:
A Tutorial on Krpano Action Arguments (pt 1)

best regards,
Klaus

8

Wednesday, June 9th 2010, 9:05am

you could use the <style> tag in the xml to share the same attributes


This only works in the plugin tag? I tried it in the 'view'-tag, but I get an error.

9

Wednesday, June 9th 2010, 9:11am

Sorry, stupid question :o.

10

Tuesday, June 22nd 2010, 10:35pm

RE: RE: variables in plugins

Hope this helps


Thanks for your code! I let it go for a few weeks, but working on it now and re-read your answer. Great, thanks!