Knob XP scripting

Support for KnobXP, share your experience and KnobXP modes.

Moderators: russ, Ralph

Message
Author
Kaellis991
Posts: 581
Joined: Mon Sep 07, 2020 8:49 am

Re: Knob XP scripting

#11 Post by Kaellis991 »

Something else I dont understand...
I created a completely new mode / script in the same modes folder, gave it a unique name and change the title at the top of the script.

To make sure all is starting from scratch, I quit out of Xplane and restarted.
After loading up the plugins settings menu, I do not see that new mode in the list.
That is making me think the KnobXP plugin is still running the very first scripts and nothing is changing.
It seems to me the Knobster is not reading the new / revised scripts.... but I cannot discern that for sure."

So why doesnt that new mode show in the settings list?

SimPassion
Posts: 5336
Joined: Thu Jul 27, 2017 12:22 am

Re: Knob XP scripting

#12 Post by SimPassion »

Kaellis991 wrote: Mon Sep 05, 2022 8:24 pm Something else I dont understand...
I created a completely new mode / script in the same modes folder, gave it a unique name and change the title at the top of the script.

To make sure all is starting from scratch, I quit out of Xplane and restarted.
After loading up the plugins settings menu, I do not see that new mode in the list.
That is making me think the KnobXP plugin is still running the very first scripts and nothing is changing.
It seems to me the Knobster is not reading the new / revised scripts.... but I cannot discern that for sure."

So why doesnt that new mode show in the settings list?
I'm on it, I will try to clarify

Indeed things have to be clarified, with an example from scratch added to the WIKI (@Ralph, just for memo)

SimPassion
Posts: 5336
Joined: Thu Jul 27, 2017 12:22 am

Re: Knob XP scripting

#13 Post by SimPassion »

Well, I have set it up, so the ACTIVE NAV2 Frequency is running using the Knobster in a Thranda aircraft bringing a basic radio/nav

PA-28_Arrow_III_NAV2_Behavior_KnobXP_03.jpg

I've created a NAV2_THRD.json file with this in it :

Code: Select all

{
	"name":	"NAV2 frequency Thranda",
	"minor_cw_cmd":	"sim/radios/actv_nav2_fine_up",
	"minor_ccw_cmd":	"sim/radios/actv_nav2_fine_down",
	"major_cw_cmd":	"sim/radios/actv_nav2_coarse_up",
	"major_ccw_cmd":	"sim/radios/actv_nav2_coarse_down",
	"button_released_cmd":	"sim/radios/nav2_standy_flip",
    "order": 304000
}
Edited default.json file to add the related line, notice NAV2_FREQ is deleted :

Code: Select all

		}, {
			"name":	"NAV1_FREQ",
			"enabled":	true
		}, {
			"name":	"NAV1_OBS",
			"enabled":	false
		}, {
			"name":	"NAV2_THRD",
			"enabled":	true
		}, {
			"name":	"NAV2_OBS",
			"enabled":	false
		}, {
			"name":	"SPEEDBRAKE",
			"enabled":	false
		}, {
So on Flight start with the JustFlight PA28 Arrow III, it creates the PA28 Arrow.json file (delete it if already existing, to start from scratch), with the part below in it, notice NAV2_FREQ is present, but disabled :

Code: Select all

		}, {
			"name":	"NAV1_FREQ",
			"enabled":	true,
			"order":	303000
		}, {
			"name":	"NAV2_FREQ",
			"enabled":	false,
			"order":	304000
		}, {
			"name":	"NAV2_THRD",
			"enabled":	true,
			"order":	304000
		}, {
			"name":	"ADF1_FREQ",
			"enabled":	false,
			"order":	305000
Last edited by SimPassion on Mon Sep 05, 2022 8:54 pm, edited 1 time in total.

SimPassion
Posts: 5336
Joined: Thu Jul 27, 2017 12:22 am

Re: Knob XP scripting

#14 Post by SimPassion »

 
PA-28_Arrow_III_NAV2_Behavior_KnobXP_04.jpg
PA-28_Arrow_III_NAV2_Behavior_KnobXP_05.jpg
PA-28_Arrow_III_NAV2_Behavior_KnobXP_06.jpg

It works, however, we still have to share with @Ralph, @russ and @Corjan, as there's some condition which trigger X-Plane CTDs while using KnobXP with improper configuration files

Kaellis991
Posts: 581
Joined: Mon Sep 07, 2020 8:49 am

Re: Knob XP scripting

#15 Post by Kaellis991 »

So what wasnt clear to me was that the PA28 Arrow.json file is where xplane / Knobster is reading from to populate the settings list.
Whenever, a new mode is created, there also have to be some code added to the aircraft.json file to make the connection to the appropriate new mode.

I had the right coding in the new mode I created, but I didnt understand how to remove the current codes and replace it with the new ones.

It's working now.
Thanks

SimPassion
Posts: 5336
Joined: Thu Jul 27, 2017 12:22 am

Re: Knob XP scripting

#16 Post by SimPassion »

Kaellis991 wrote: Mon Sep 05, 2022 9:09 pm So what wasnt clear to me was that the PA28 Arrow.json file is where xplane / Knobster is reading from to populate the settings list.
Whenever, a new mode is created, there also have to be some code added to the aircraft.json file to make the connection to the appropriate new mode.

I had the right coding in the new mode I created, but I didnt understand how to remove the current codes and replace it with the new ones.

It's working now.
Thanks
The default.json is the initial from which KnobXP is reading and the X-Plane / Plugins / KnobXP / Settings is allowing the selection for inclusion in the current aircraft

PA-28_Arrow_III_NAV2_Behavior_KnobXP_07.jpg

[EDIT] Just also added NAV2 Freq to the list by enabled it :

PA-28_Arrow_III_NAV2_Behavior_KnobXP_08.jpg

Kaellis991
Posts: 581
Joined: Mon Sep 07, 2020 8:49 am

Re: Knob XP scripting

#17 Post by Kaellis991 »

So that's the procedure...
1. Create the New mode in modes folder with the appropriate dataref / commands
2. Delete specific [aircraft].json file
3. Add the code for the new mode in the default.json file
4. Restart Xplane....and a new specific [aircraft].json file will be created

Now I can add Com2 to my Knobster

User avatar
Keith Baxter
Posts: 4671
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: Knob XP scripting

#18 Post by Keith Baxter »

Hi,

Loading a .json is simply loading a table. You can have many different tables and call any table at any time.

You need to note that .json files need to be available at runtime. They do not have to be loaded at runtime. Only when called. Always check if any table or .json has a value.

A table can be created within code and used to "OVERWRITE" the static_data_load() data.
For this you will need to understand the LUA table functions.

Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

Kaellis991
Posts: 581
Joined: Mon Sep 07, 2020 8:49 am

Re: Knob XP scripting

#19 Post by Kaellis991 »

Keith Baxter wrote: Mon Sep 05, 2022 9:36 pm Hi,

Loading a .json is simply loading a table. You can have many different tables and call any table at any time.

You need to note that .json files need to be available at runtime. They do not have to be loaded at runtime. Only when called. Always check if any table or .json has a value.

A table can be created within code and used to "OVERWRITE" the static_data_load() data.
For this you will need to understand the LUA table functions.

Keith
Lua is still a challenge. My simplistic outline is about as good as my understanding gets right now...

User avatar
Keith Baxter
Posts: 4671
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: Knob XP scripting

#20 Post by Keith Baxter »

Hi

Lua is not that complex when you start to understand.

Lets do a simple table. my_table = {"Jack", "Fred", Jane"}
If this was a .json, then after the static_data_load(), my_table would = {"Jack", "Fred", Jane"}

Now lets change the value of the 2nd index "Fred" to "Tom"
my_table = {"Jack", "Tom", Jane"}

If we call ....print(my_table[2]) we would receive a print value of Tom.
This would not change the value in the .json. Only the value in the loaded table my_table()

Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

Post Reply