Benutzerinformationen überspringen
Wohnort: La Paz, Baja California Sur, México
Beruf: KRpano programmer at www.imagen360.com
Hello everyone. I'm trying to build an action that can, from a list of scenes (each one with a category="something" or "null" variable), know how many categories there are in the list, create new variables for every type of category and within those variables count how many of each category there are. I'll give you an example:
FROM THE LIST:
<scene name="0" category="null"/>
<scene name="1" category="A"/>
<scene name="2" category="B"/>
<scene name="3" category="A"/>
<scene name="4" category="A"/>
<scene name="5" category="A"/>
<scene name="6" category="C"/>
<scene name="7" category="B"/>
In the end the action would have to create these variables with these values (Note that I wish the action to create the variables without me having to tell it which categories there are, and that the order of the scenes is irrelevant):
A="4" B="2" C="1"
I've been trying to build it with a for action but so far I have been unsuccessful, ¿any ideas?
|
|
Quellcode |
1 2 3 4 5 6 7 8 9 10 11 |
<action name="set_param"> for(sub(i,%1.count,1), i GE 0, dec(i), if(%1[get(i)].%2 == %3, copy(category[%4].count, i); ); ); </action> set_param(scene,category,A); trace(category[A].count); trace(category[B].count); trace(category[C].count); |
|
|
Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 |
<action name="get_categories">
for(set(i,0), i LT scene.count, inc(i),
if(get(scene[get(i)].category),
inc(get(scene[get(i)].category));
,
set(get(scene[get(i)].category), 1);
);
);
trace("a ", a);
trace("b ", b);
trace("c ", c);
</action>
|
Benutzerinformationen überspringen
Wohnort: La Paz, Baja California Sur, México
Beruf: KRpano programmer at www.imagen360.com
|
|
Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
<action name="report_categories">
for(set(i,0), i LT scene.count, inc(i),
if(category[get(scene[get(i)].category)].sum,
inc(category[get(scene[get(i)].category)].sum);
,
set(category[get(scene[get(i)].category)].sum, 1);
);
);
for(set(i,0), i LT category.count, inc(i),trace(category[get(i)].name,': ',category[get(category[get(i)].name)].sum););
</action>
<scene name="0" category="X"/>
<scene name="1" category="A"/>
<scene name="2" category="B"/>
<scene name="3" category="A"/>
<scene name="4" category="A"/>
<scene name="5" category="A"/>
<scene name="6" category="C"/>
<scene name="7" category="B"/>
<scene name="8" category="D"/>
<scene name="9" category="D"/>
|
|
|
Quellcode |
1 2 3 4 5 6 7 8 |
for(set(i,0), i LT scene.count, inc(i),
copy(current, scene[get(i)].category);
if(get(current),
inc(get(current));
,
set(get(current), 1);
);
);
|
Benutzerinformationen überspringen
Wohnort: La Paz, Baja California Sur, México
Beruf: KRpano programmer at www.imagen360.com
|
|
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 |
for(set(i,0);, i LT scene.count, inc(i);, if(get(scene[get(i)].cat), inc(get(scene[get(i)].cat)); , set(get(scene[get(i)].cat), 1); txtadd(container_scrollarea,'container_',get(scene[get(i)].cat)); addlayer(get(container_scrollarea)); layer[get(container_scrollarea)].loadstyle(style_container_cat); ); ); <!--AFTER GENERATING THE CONTAINERS, IT RUNS A NEW LOOP AND ASSIGNS THE LAYERS OF EACH SCENE TO THEM (BUTTONS)--> for(set(i,0);, i LT scene.count, inc(i);, txtadd(scrollarea_button, get(scene[get(i)].cat),'_',get(scene[get(i)].name),'_button'); addlayer(get(scrollarea_button)); layer[get(scrollarea_button)].loadstyle(textstyle_bar_escenas); set(layer[get(scrollarea_button)].html,get(scene[get(i)].title)); txtadd(container_cat,'container_',get(scene[get(i)].cat)); set(layer[get(scrollarea_button)].parent,get(container_cat)); ); |
|
|
Quellcode |
1 2 3 |
inc(get(scene[get(i)].cat)); , set(get(scene[get(i)].cat), 1); |
Benutzerinformationen überspringen
Wohnort: La Paz, Baja California Sur, México
Beruf: KRpano programmer at www.imagen360.com
Benutzerinformationen überspringen
Wohnort: La Paz, Baja California Sur, México
Beruf: KRpano programmer at www.imagen360.com