Sie sind nicht angemeldet.

Lieber Besucher, herzlich willkommen bei: krpano.com Forum. Falls dies Ihr erster Besuch auf dieser Seite ist, lesen Sie sich bitte die Hilfe durch. Dort wird Ihnen die Bedienung dieser Seite näher erläutert. Darüber hinaus sollten Sie sich registrieren, um alle Funktionen dieser Seite nutzen zu können. Benutzen Sie das Registrierungsformular, um sich zu registrieren oder informieren Sie sich ausführlich über den Registrierungsvorgang. Falls Sie sich bereits zu einem früheren Zeitpunkt registriert haben, können Sie sich hier anmelden.

1

Mittwoch, 19. Mai 2010, 16:35

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.

2

Mittwoch, 19. Mai 2010, 20:04

Hi maaike,

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

Quellcode

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

Mittwoch, 19. Mai 2010, 22:02

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!

Quellcode

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:

Quellcode

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:

Quellcode

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:

Quellcode

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

Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »pinsane« (19. Mai 2010, 22:43)


Tuur

Erleuchteter

Beiträge: 2 775

Wohnort: Netherlands

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

  • Nachricht senden

4

Donnerstag, 20. Mai 2010, 12:04

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
http://www.virtualtuur.com
Skype:studiotuur

Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »Tuur« (20. Mai 2010, 12:40)


5

Donnerstag, 20. Mai 2010, 13:12

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.

Zitat

<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" />
...

Zitat

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

Donnerstag, 20. Mai 2010, 15:52

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

Dienstag, 25. Mai 2010, 11:33

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

Mittwoch, 9. Juni 2010, 09:05

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

Mittwoch, 9. Juni 2010, 09:11

Sorry, stupid question :o.

10

Dienstag, 22. Juni 2010, 22:35

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!