You are not logged in.

San7

Professional

Posts: 626

Occupation: coding in krpano

  • Send private message

21

Thursday, March 9th 2023, 8:20am

htsp01 - htsp03 belong to the same scene.
If you make hotspots in another scene, then
1. they must have other names and, accordingly, other variables in onloaded="if(tag_name...
2. In the counter, you need to specify the number of all clickable hotspots
if(global.hs_tag_count == №, ...

The counter layer is global and counts all clicked hotspots in the entire tour, not just in one scene

Again, how accurate the task originally set is how accurate the executing code will be *squint*

andrew22222

Intermediate

Posts: 397

Location: Australia

  • Send private message

22

Thursday, March 9th 2023, 9:50am

Got it. I'll enjoy going over the code and see what can be changed. I'm only making a children's 'look and find' tour for a few bored school kids.


Thanks again and PayPal gift sent *thumbsup*

San7

Professional

Posts: 626

Occupation: coding in krpano

  • Send private message

23

Thursday, March 9th 2023, 9:55am

Got it. I'll enjoy going over the code and see what can be changed. I'm only making a children's 'look and find' tour for a few bored school kids.


Thanks again and PayPal gift sent *thumbsup*

Thanks, andrew22222 *thumbup*
If the kids suddenly crack the code and outwit you - write, we'll come up with another one *thumbsup*

24

Thursday, March 9th 2023, 10:47am

Source code

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
26
27
28
29
30
31
32
33
34
35
36
37
38
<krpano logkey="true">

<preview type="grid" />

<layer name="hscount" type="text" font="arial"
	css="text-align:left;font-weight:bold;color:#0114DD;font-size:25px;padding-left:10px;"
	width="120" height="30" bgcolor="0xffffff" align="topleft" bgalpha="0.8"
	keep="true" x="15" y="15" onloaded="hs_tag_click();" onclick="hs_tag_click();" />

<style name="spot" type="text" width="50" height="50" bgcolor="0x888888" bgalpha="1" tag="game" />

<hotspot name="spot1" style="spot" ath="-20" atv="0" onclick="hs_tag_click(get(name));" />
<hotspot name="spot2" style="spot" ath="0" atv="0" onclick="hs_tag_click(get(name));" />
<hotspot name="spot3" style="spot" ath="20" atv="0" onclick="hs_tag_click(get(name));" />
<hotspot name="spot4" style="spot" ath="0" atv="20" onclick="hs_tag_click(get(name));" />
<hotspot name="spot5" style="spot" ath="0" atv="-20" onclick="hs_tag_click(get(name));" />

<action name="hs_tag_click" scope="local" args="name">
	if(name === null, // reset counter and list!
		set(global.hs_list, '');
		set(layer[hscount].html, 0);
	, hotspot[get(name)].tag === 'game', // else if tagged hotspot
		calc(local.id, xml.scene + '/' + name); // create an id for the clicked hs
		indexoftxt(local.index, get(hs_list), get(id)); // search in global
		if(index LT 0, // not found, then add the id
			if(hs_list, txtadd(hs_list, ',')); // add separator if count > 0
			txtadd(hs_list, get(id)); // add id
		);
		txtsplit(get(hs_list), ',', local.arr); // split to get actual count
		trace('id=',id,' list=',hs_list,' count=',arr.count);
		copy(layer[hscount].html, arr.count); // set count
		if(arr.count === 5,
			txtadd(layer[hscount].html, ' whee!')
		);
	);
</action>

</krpano>

my solution *squint*
each hotspot is only counted once, works across scenes, clicking the counter resets to 0,
see console output

notes:
the scene name is added to the id to allow same names in different scenes
as there is no scene in this example the id is "null/spotN", but it will work if you use scenes.

This post has been edited 6 times, last edit by "indexofrefraction" (Mar 9th 2023, 11:05am)


San7

Professional

Posts: 626

Occupation: coding in krpano

  • Send private message

25

Thursday, March 9th 2023, 11:36am

my solution
each hotspot is only counted once, works across scenes, clicking the counter resets to 0,
see console output

*thumbsup* I like that there is a list with the name of the scenes and the names of the hotspots, you can use it if necessary.
There is only one point left - you need to manually specify the number of clicked hotspots in order to display 'whee!'

andrew22222

Intermediate

Posts: 397

Location: Australia

  • Send private message

26

Thursday, March 9th 2023, 10:59pm

Thanks for the example with code indexofrefraction

Similar threads