Sie sind nicht angemeldet.

Zephyr

Profi

  • »Zephyr« ist der Autor dieses Themas

Beiträge: 1 003

Wohnort: Netherlands

Beruf: Web developer

  • Nachricht senden

1

Montag, 11. Mai 2009, 16:11

if statement and wait() bugged?

Hi,

I'm using the latest beta and there seems to be an issue with the combination of a if statement and a wait.
I made a little rotate animation, here's my code. (I've edited for easy reading, so the animation is way to fast, sorry for the sloppiness)

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<events onxmlcomplete="action(start);" />
<plugin name="startup" firstrun="1" showhelp="1" keep="true" />
<action name="start">         
		if(plugin[startup].firstrun EQ 1,
			action(rotate);
		)    
    </action>
	<action name="rotate">
		oninterrupt(action(returnaction));
	    lookat(50,50,85);
	    wait(2000000);
	    lookto(-100,-1,85);
		set(plugin[startup].firstrun, 0);
	</action>
	<action name="returnaction">
		lookat(50,50,85);
		set(plugin[startup].firstrun, 0); 
	</action>


Basicly, if it's the first location you're watching, perform a small rotation, else don't. The animation should/could be interupted if the user don't want to see it. I got this in a global xml which is included in every other panorama. When a user clicks on a direct link to a specific location, if will perform the animation, but if the user gets to that excact location by clicking hotspots in the tour, the animation doesn't get triggered. After the animation, the firstrun attribute is set to 0, and since keep is true, I will remember if a user first visits a location. Next step would be cookies, but for now this works fine.

Now the problem:
The thing is, you see that massive wait if put in there for testing? It gets ignored. It shoots right to the lookto part. BUT if I remove the If statement. It does the thing he's supposed to, sit right their and wait 2000000 seconds ;p. Somehow wait gets ignored in a if statement.

Another question, not related to the "bug"(?). As you can see I have this custom plugin (startup), with nothing in it, cept 3 attributes. And for me, it kinda hurts my eyes a little bit hehe :P Its not really OOP, creating an instance of plugin to hold variables. Because firstrun isn't a plugin, it's a boolean. Is it possible to declare global variables in the xml? Or atleast put the variables in the krpano attribute (not sure if it supports custom attributes and if MERGE doesn't clear them, thats why I used a plugin with keep=true) or is the data object reserved for that? I probally answered my own question somewhere in here :P =(

Edit: I temporary solved it by setting a delayedcall before the action delayedcall(0, action(firstrun_animation);); Now, the action can have wait() in it.

Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »Zephyr« (12. Mai 2009, 10:52)


2

Montag, 18. Mai 2009, 23:54

The thing is, you see that massive wait if put in there for testing? It gets ignored. It shoots right to the lookto part. BUT if I remove the If statement. It does the thing he's supposed to, sit right their and wait 2000000 seconds ;p. Somehow wait gets ignored in a if statement.
Hi, which krpano version have you used? beta7?
or - do you have a not working example online?

Zitat

Another question, not related to the "bug"(?). As you can see I have this custom plugin (startup), with nothing in it, cept 3 attributes. And for me, it kinda hurts my eyes a little bit hehe :P Its not really OOP, creating an instance of plugin to hold variables. Because firstrun isn't a plugin, it's a boolean. Is it possible to declare global variables in the xml? Or atleast put the variables in the krpano attribute (not sure if it supports custom attributes and if MERGE doesn't clear them, thats why I used a plugin with keep=true) or is the data object reserved for that? I probally answered my own question somewhere in here :P =(
yes, you could declare "global" variables (as attributes of the <krpano> node or just via set()),

e.g. just:

Quellcode

1
<krpano ... myglobalvariable="123"> 

or inside an action:

Quellcode

1
set(myglobalvariable, 123);


you could also declare custom nodes and structures,

e.g. declare any custom node with custom attributes in the xml:

Quellcode

1
<mysettings var1="abc" var2="xyz" />


and then access it:

Quellcode

1
2
3
4
...
<action ...>
  if(mysettings.var1 == abc, ....);
</action>


when a node inside the xml has a "name" attribute - it will be parsed as "Array",
e.g.
xml declare:

Quellcode

1
2
<mydata name="data1" val1="abc" val2="sdfsf" />
<mydata name="data2" val1="sdf" val2="sdfsdff" />


access to it:

Quellcode

1
2
if(mydata[data1].val1 == abc, ...);
if(mydata[data2].val1 == sdf, ...);



this global attributes will be kept when loading a other xml with MERGE,

best regards,
Klaus

Zephyr

Profi

  • »Zephyr« ist der Autor dieses Themas

Beiträge: 1 003

Wohnort: Netherlands

Beruf: Web developer

  • Nachricht senden

3

Dienstag, 19. Mai 2009, 11:11

I've made an example online. 2 button on the bottom, 1 calls a if statement with a wait in it, and the other a delayedcall. After a click, 2 seonds later a text should appear. Only the delayedcall does wait for it, the ifstatement with the wait(2) doesn't

example: www.darkgfx.com/buttons/buttons.html
source: www.darkgfx.com/buttons/global.xml

4

Dienstag, 19. Mai 2009, 12:55

Hi, thanks for the example, I will have a look at it,

it seems you have the IIS server problem with the license file, see here:
http://krpano.com/docu/iisservers/

best regards,
Klaus

Zephyr

Profi

  • »Zephyr« ist der Autor dieses Themas

Beiträge: 1 003

Wohnort: Netherlands

Beruf: Web developer

  • Nachricht senden

5

Dienstag, 19. Mai 2009, 14:33

thanks,

yeah the IIS bug is correct, I didnt bother fixing it for this example :) But it probally has nothing to do with the if wait stuff :)

6

Dienstag, 19. Mai 2009, 14:58

Hi,

you're right the IIS thing has nothing to do with it, I just want to be sure

I could fix this bug now, thanks!
the problems comes from the if() function,
with 1.0.8 beta 8 it will work correctly,

best regards,
Klaus

Ähnliche Themen