Page 1 of 1

P3D Javascript Interface & HTML5

Posted: Sun Nov 08, 2020 12:19 pm
by Homer
Hi, does anyone know where I can find more info on building panels and addons for P3D v5.1 using HTML5 and Javascript Interface? The SDK documentation is very scarce, maybe because it's a new feature. And google doesn't give any meaningful results.
Using the info provided in the SDK docs, i can't get to work even the simpliest example, like "var alt = VarGet("Indicated Altitude", "feet");" doesn't return any results. I would be thankful for any info or suggestions for where to look for one.

Re: P3D Javascript Interface & HTML5

Posted: Sun Nov 15, 2020 12:13 pm
by gaab
I second this question !

Any clue will be welcome !

Gérard

Re: P3D Javascript Interface & HTML5

Posted: Mon Nov 23, 2020 1:42 am
by gaab
Homer wrote: Sun Nov 08, 2020 12:19 pm Using the info provided in the SDK docs, i can't get to work even the simpliest example, like "var alt = VarGet("Indicated Altitude", "feet");" doesn't return any results. I would be thankful for any info or suggestions for where to look for one.
I found the hard way that the example is wrong. You need to specify the variable type !

var alt = VarGet("A:Indicated Altitude", "feet");
var myloc = VarGet("L:mylocVar", "bool");

Still wondering how to set local vars.

Even if (L:mylocVar,bool) is non 0 in XML gauge, VarSet("L:mylocVar", 3); will give back 0 when VarGet("L:mylocVar", "bool");


Gérard

Re: P3D Javascript Interface & HTML5

Posted: Sun Dec 13, 2020 10:07 am
by Homer
You need to specify the variable type
Seems like they are using TypeScript behind the scenes. Thanks for the clues!

Re: P3D Javascript Interface & HTML5

Posted: Mon Jan 18, 2021 3:46 pm
by Beau Hollis
The type conversion might be more restrictive for JavaScript. Under the hood, L-vars are all stored a doubles. I'd suggest trying a numeric type.

Re: P3D Javascript Interface & HTML5

Posted: Tue Jan 19, 2021 3:20 pm
by gaab
Beau Hollis wrote: Mon Jan 18, 2021 3:46 pm The type conversion might be more restrictive for JavaScript. Under the hood, L-vars are all stored a doubles. I'd suggest trying a numeric type.
I tested a very simple script

Code: Select all

	var visual = VarGet("L:YokePilot" ,"number");
	if (visual != 0) { 
		document.getElementById('yoke').innerHTML = 'Hidden';
	}
	else {
		document.getElementById('yoke').innerHTML = 'Visible';		
	}		
The YokePilot is changed in an XML gauge, and I get the result expected.

Next step is to setup that variable

Code: Select all

	function changeVisible(newColor) 
	{		
	        if (newColor == 'red') { 
	        	VarSet("L:YokePilot", "0"); 
 			document.getElementById('yoke').style.color = newColor; 
 		}
	         if (newColor == 'blue') { 
	         	VarSet("L:YokePilot", "1");
 			document.getElementById('yoke').style.color = newColor; 
	          }
			  
	}	
In order to insure that the code is working, the display is set inside the color test...
Which is shown as expected.

As soon as we VarSet("L:YokePilot", any value), L:YokePilot is reset to zero (XML and Varget).

Nota : I tried a lot of VarSet variations
- VarSet("L:YokePilot", "1")
- VarSet("L:YokePilot", '1')
- VarSet("L:YokePilot", 1)
- VarSet("L:YokePilot", "number", "1")
I can say that something happens, as L:YokePilot is reset to zero...

Any other suggestion ?

Gérard

Re: P3D Javascript Interface & HTML5

Posted: Sun Jan 24, 2021 12:17 pm
by federico.sucari
I also want to understand how VarSet works. If it works?

VarSet needs to be functional and appreciate any insights on this.

If not, is there any way to communicate HTML code and C code other than a L:VAR and the VarGet/VarSet functions?

Thanks!

Federico

Re: P3D Javascript Interface & HTML5

Posted: Tue Apr 06, 2021 5:30 pm
by Beau Hollis
JavaScript VarSet should work correctly in the next release. Unfortunately there were some issues with the JS VarSet implementation which we didn't catch in beta. Sorry about the confusion this caused. The next release will ship with an SDK sample that uses VarSet.

Re: P3D Javascript Interface & HTML5

Posted: Tue Apr 06, 2021 7:14 pm
by gaab
Thanks for your feedback.

It would be great to have an example used in a panel (with explanations on the sizing of the windows)

Would you also consider making these "windows" usable with the aircraft.cfg kb_checklists and kb_reference.

HTML5 would be welcome to write checklist

Gérard

Re: P3D Javascript Interface & HTML5

Posted: Thu Jun 17, 2021 9:53 pm
by gaab
Beau Hollis wrote: Tue Apr 06, 2021 5:30 pm JavaScript VarSet should work correctly in the next release. Unfortunately there were some issues with the JS VarSet implementation which we didn't catch in beta. Sorry about the confusion this caused. The next release will ship with an SDK sample that uses VarSet.
I am very desapointed, as I on't see any new SDK HTML5 sample ?

Please HELP

Gérard