Getting scene name knowing scene.index

  • Is there a way to get scene name if you know the scene index parameter?

    I have come to solution with looping through all scenes:

    Code
    add(newsceneindex, scene[get(xml.scene)].index, %1);
    for(set(i,0), i LT scene.count, inc(i), 
       if(scene[get(i)].index == newsceneindex, 
          set(newscenename, get(scene[get(i)].name)); 
       );
    );

    But as it is supposed to run on every scene load when pressing next/previous buttons, i think it is pretty heavy algorithm.

    Is there any easier way how to achieve this?

  • Well, i guess i should explain more about the rest of the code.

    • In the tour i have some buttons which are meant as Categories.
    • Each scene has a parameter "group".
    • Scenes are scattered, like: scene[0].group = 'CAT1'; scene[1].group = 'CAT2'; scene[2].group = 'CAT1' ...
    • When pressing on a Category button, code filters all corresponding scenes and sets their scene.index consecutively starting from 0 to count of these scenes. The rest (other category) scene indexes are set to a number higher than total scene count not to interfere with anything.
    • Basically scene.index != scene[index] anymore.


    So, knowing this,
    i can not really set the variable let's say 'sequence' as correct scene[index] number and work with it because scenes are not in sequence.
    Let's say, in category 'CAT1' there are scenes [0],[2],[14],[15],[17]. So, if the current scene is [0] and i press "NEXT", i need to move to the scene[2].

    I was wondering maybe sorting scenes by groups could bring up to something,
    but i'm having also an idea in the future that one scene could be in 2 groups (like variables 'group1' and 'group2'). In that case this solution wouldn't work..

    I hope i did explain it understandable.

  • Don't have time to type you the code but generaly this is feasable:
    - at start you need action that will make groups for you based on scene categories stored in some data structure
    - than you need to iterate through indexes of grouped data

    Cat 1
    1 scene_real_index="3"
    2 -||- 5
    3 -||- 7

    Cat 2
    1 scene_real_index="1"
    2 -||- 2
    3 -||- 4
    4 -||- 6
    5 -||- 8

    Try to make this on your own and come back with results. Should be not complicated.
    Something similar you can find here. Not exactly but part of the code can be reused. Don't forget to use .count ;)
    Link

  • Thanks Umalo, but i can't really figure it out.

    Let's say: Scene[ID] - ID should be unique, right?
    In your example:

    Cat 1
    1 scene_real_index="3"
    2 -||- 5
    3 -||- 7

    Cat 2
    1 scene_real_index="1"
    2 -||- 2
    3 -||- 4
    4 -||- 6
    5 -||- 8"

    i understand these IDs are not unique.

    My next_scene action now looks like this:

  • ah, now going in next dimension listing category based thumbs is completely different story but can relate to my proposal.
    You would than need to recreate thumbs on scroll area whenever active category is changed.
    Best would be you send me your code on mail and I will give you my proposal directly in the code but can't promise instant response due to other projects. How urgent this is for you?

Participate now!

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