• hi.. this is a beginners question / or just something i didnt understand, yet...

    as far as i know variables in krpano are generally global.
    but doesnt that mean that using variables in actions is highly delicate?

    the following simple example kills krpano,
    because the 2nd for loop (in the called action) also uses i as index.

    <action name="someaction">for(set(i,0), i LT 5, inc(i), trace('i2=',i));</action>
    for(set(i,0), i LT scene.count, inc(i), trace('i1=',i); someaction());

    of course this can be avoided in easy code like above,
    but what if code gets more complex?

    then how can i be sure, that an event (action) doesnt break my code because it uses a variable with the same name?
    as i have seen an assigned event action like layer[5].onhover does get the layers properties as variables
    does this mean using a variable name like 'width' is highly unsafe for other actions?

    and how can i be sure, that the vtourskin code doesn't break my code,
    for example when i click on some button and the executed vtourskin code changes variables that i am in midst of using.

    i m pretty confused about this subject...
    i hope somebody can bring a bit light to the mist here!
    index

  • of course, I believe that every developer should decide to follow the correct use of the names of the variables in your code, I believe that every developer should decide to follow the correct use of the names of the variables in your code

    I think that would be very helpful to have a list of so-called "reserved" variable names that are used "inside" krpano
    I was faced with the fact that my code not work correctly when moving from old version to the newer krpano, and the problem was solved by replacing the variable name

  • Hi,

    yes, there is no scope for actions, so all is global...

    The action script system wasn't originally intended to be a kind of programming language.
    It was just an interpreted script and designed to be as simple as possible to be as fast as possible parse- and execute-able.

    It would be possible to add scopes for actions of course, but this would - 1. break existing code, 2. make things more complicated (=potentially slower due more parsing and evaluating code), 3. be another vector for bugs and side-effects...


    Quote

    I think that would be very helpful to have a list of so-called "reserved" variable names that are used "inside" krpano
    I was faced with the fact that my code not work correctly when moving from old version to the newer krpano, and the problem was solved by replacing the variable name

    Normally all krpano variables should be listed in the documentation...
    When such happens please report it and will look for fixing that.

    Best regards,
    Klaus

  • Normally all krpano variables should be listed in the documentation...
    When such happens please report it and will look for fixing that.


    work correctly in 1.17.4 and not in 1.19pr5

    Code
    lift[lift_1].my_parametre
    lift[lift_2].my_parametre
    ..
    Code
    lif[lift_1].my_parametre
    lif[lift_2].my_parametre
    ..


    work correctly in 1.19pr5

Participate now!

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