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)

    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.

    Edited once, last by Zephyr (May 12, 2009 at 10:52 AM).

  • 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?

    Quote

    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:

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


    or inside an action:

    Code
    set(myglobalvariable, 123);

    you could also declare custom nodes and structures,

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

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

    and then access it:

    Code
    ...
    <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:

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

    access to it:

    Code
    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

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!