Sie sind nicht angemeldet.

Lieber Besucher, herzlich willkommen bei: krpano.com Forum. Falls dies Ihr erster Besuch auf dieser Seite ist, lesen Sie sich bitte die Hilfe durch. Dort wird Ihnen die Bedienung dieser Seite näher erläutert. Darüber hinaus sollten Sie sich registrieren, um alle Funktionen dieser Seite nutzen zu können. Benutzen Sie das Registrierungsformular, um sich zu registrieren oder informieren Sie sich ausführlich über den Registrierungsvorgang. Falls Sie sich bereits zu einem früheren Zeitpunkt registriert haben, können Sie sich hier anmelden.

milotimbol

Fortgeschrittener

  • »milotimbol« ist der Autor dieses Themas

Beiträge: 242

Wohnort: Philippines

Beruf: Software Developer

  • Nachricht senden

1

Sonntag, 26. Februar 2023, 13:10

Array is null after loadscene

Hi all, I declare custom xml elements to manage the menu of my tours like the one below.

Quellcode

1
2
3
4
5
6
7
8
9
	<scene_group name="name">
		<scene name="scene_1" />
		<scene name="scene_2" />
		<scene name="scene_3" />
		<scene name="scene_4" />
		<scene name="scene_5" />
		<scene name="scene_6" />
		<scene name="scene_7" />
	</scene_group>


I am able to loop through the content.

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
	<action name="skin_build_scene_groups">

		for(set(counter,0), counter LT scene_group.count, inc(counter),	

			set(group_id, get(scene_group[get(counter)].name) );	
			set(scenes_count, get(scene_group[get(counter)].scene.count) );	


			for(set(scene_counter,0), scene_counter LT scene_group[get(counter)].scene.count, inc(scene_counter),	
			

				set(scene_name, get(scene_group[get(counter)].scene[get(scene_counter)].name) );
<!-- do something here-->
				

			);
		);
	</action>


However the code above will only work before any "loadscene" calls, after loadscene it no longer works and when I try to do a check for the count its null

Quellcode

1
trace(*scene_group.count);


The debug code above when put before loadscene returns a number but after loadscene it returns null.

Trying to go through the docs and cant find an explanation. Can anyone enlighten me on what is happening?

2

Sonntag, 26. Februar 2023, 13:25

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<group name="group_1">
	<scene name="scene_1" />
	<scene name="scene_2" />
	<scene name="scene_3" />
	<scene name="scene_4" />
	<scene name="scene_5" />
	<scene name="scene_6" />
	<scene name="scene_7" />
</group>

<action name="build_groups" scope="local">
	trace("active scene = ",xml.scene);
	for(set(local.i,0), i LT group.count, inc(i),
		for(set(local.j,0), j LT group[get(i)].scene.count, inc(j),
			copy(local.name, group[get(i)].scene[get(j)].name);
			trace(name);
		);
	);
</action>

<events name="test" onnewscene="build_groups()" keep="true" />

this works without problem also after scene changes
maybe it is this ... get(scene_group[get(counter)].scene[get(scene_counter)].name)
i would avoid nesting too many get() calls

also in general..
- set(x, get(y)) is easier/better done by copy(x, y)
- use local scopes! with global variables like "counter" in multiple functions you easily run into problems

milotimbol

Fortgeschrittener

  • »milotimbol« ist der Autor dieses Themas

Beiträge: 242

Wohnort: Philippines

Beruf: Software Developer

  • Nachricht senden

3

Montag, 27. Februar 2023, 00:37

Thanks for the tip, will apply it in future code that I write. However my question is in general why is the object null after loadscene? See code below.

Quellcode

1
2
3
trace("group count is = ", *group.count); <!-- returns a number -->
loadscene(get(scene[%1].name), null, MERGE|KEEPVIEW, OPENBLEND(0.5, 0.0, 0.75, 0.05, linear) );
trace("group count is = ", *group.count);<!-- returns null -->


So I have many of these groups by the way

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<group name="group_1a">
	<scene name="scene_1" />
	<scene name="scene_2" />
	<scene name="scene_3" />
	<scene name="scene_4" />
	<scene name="scene_5" />
	<scene name="scene_6" />
	<scene name="scene_7" />
</group>
<group name="group_1b">
	<scene name="scene_1b" />
	<scene name="scene_2b" />
	<scene name="scene_3b" />
	<scene name="scene_4b" />
	<scene name="scene_5b" />
	<scene name="scene_6b" />
	<scene name="scene_7b" />
</group>


Is there a specific reason for this? Cant seem to find it in the documentation.

milotimbol

Fortgeschrittener

  • »milotimbol« ist der Autor dieses Themas

Beiträge: 242

Wohnort: Philippines

Beruf: Software Developer

  • Nachricht senden

4

Montag, 27. Februar 2023, 00:51

Oh shit Im stupid you are right I messed up my variables overriding the object. Thanks for the tip it lead me to the right direction!