Keith's LUA Help thread.

Help creating logic scripts for Air Manager Instruments

Moderators: Ralph, russ

Message
Author
User avatar
Sling
Posts: 4426
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: Keith's LUA Help thread.

#261 Post by Sling » Sat Feb 13, 2021 2:51 pm

I looked at those datarefs and all of the ones i had in there were simple integer values. What you showed was an alpha numeric tail number. I don't see how you go from INT's to tail numbers unless i'm missing something. Which is quite possible because its getting late. :)

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

Re: Keith's LUA Help thread.

#262 Post by Keith Baxter » Sat Feb 13, 2021 3:00 pm

Sling wrote:
Sat Feb 13, 2021 2:51 pm
I looked at those datarefs and all of the ones i had in there were simple integer values. What you showed was an alpha numeric tail number. I don't see how you go from INT's to tail numbers unless i'm missing something. Which is quite possible because its getting late. :)
Tony,

You know you are not going to sleep. :D Going to need this info soon maybe... ;) ;)
So lay awake wondering what those datarefs indicate. :lol: :lol:

We will chat after a refreshed night.

I would have hoped that that @Ralph or @Corjan would have an Idea as well.
In the meantime I will look up the aircraft numbers I have within the AI traffic selected and see if I can correlate any resemblance to those datarefs.

I need to be honest. I have not spent any time searching Xplane forum. Thought there would be a quick resolve here.

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 

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

Re: Keith's LUA Help thread.

#263 Post by Keith Baxter » Sat Feb 13, 2021 6:24 pm

Hi,

Ok I did some Pi work on these two datarefs and it would seem that there is no correlation between these values and the aircraft ID .

So to.... LR for an explanation on how these values are determined and interpreted .

Will revert on their answer if I get one.

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 

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

Re: Keith's LUA Help thread.

#264 Post by Keith Baxter » Sun Feb 14, 2021 11:28 am

Hay Tony,

Got this response from "philipp" @xplane.org .
The link, in the link below is very informative and something to take note of.
https://forums.x-plane.org/index.php?/f ... 36479_menu

  1. As you can read here: https://developer.x-plane.com/article/overriding-tcas-and-providing-traffic-information/
  2.  
  3. The modeS ID "hex code" is simply a random number, unique per aircraft, for AI aircraft spawned by X-Plane. If the aircraft is spawned by another AI traffic provider, such as Traffic Global or Live Traffic, they can make their own rules and potentially use real IDs from actual aircraft out there.
  4.  
  5.  
  6.  
  7. The mode C code is assigned in ascending order as new aircraft are spawned by X-Plane AI traffic. Again, if the aircraft are spawned by a third-party provider, they can  assign the mode C code according to their own ideas.



So now the conversion to make that code mean something other than a a bunch of calculator digits.

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 

User avatar
Sling
Posts: 4426
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: Keith's LUA Help thread.

#265 Post by Sling » Sun Feb 14, 2021 4:11 pm

Yes I saw that on the org. The bit I didn’t get was the mention of optional flight Id but no further explanation of how it’s implemented. Either way the tcas generation is aimed at hird party plugins so I guess all you can do I’d display whatever is in the datarefs. The code I posted will do the decimal to hex conversion of the 24 bit codes.

Tony

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

Re: Keith's LUA Help thread.

#266 Post by Keith Baxter » Tue Feb 16, 2021 1:46 am

Hi,

I am getting a lot of <Error in timer callback: mod_nrst_pages.lua:1031: attempt to index a nil value (field '?')>

This is because the nav feature field is missing or the value in the field is nil,

I cannot believe that for each field within the nav data one has to add a ....
<If AIRPORT[i]["NAME"] ~= nil then> and then a <If AIRPORT[i]["ICAO"] ~= nil then> and then another <If AIRPORT[i]["SURFACE_LONGEST"] ~= nil then> and so for every single field one wants to search,concat etc

Is there a global way to get around this?

Of course this would not happen if ALL the fields within the nav data had a value.

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 

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

Re: Keith's LUA Help thread.

#267 Post by Keith Baxter » Sat Mar 06, 2021 9:04 am

Hi,

How do you test a inf value?

This dataref returns inf when there is no time. I want to exclude ,

I tried this but it don't work. I also tried >=0 and that also don't work

Code: Select all

	ariB_28magR			    ="font:arimo_bold.ttf; size:28px; color: #ff00ff; halign:right;  valign:center;"
  nav_stat_pos4=txt_add("",ariB_28magR,828,53,120,20)
   
function nav_info(ete)
      if ete ~= inf then
	  print(ete)
         hrs = math.floor(ete/ 60)
         mins = math.floor(ete % 60)
         secs = var_round((ete %1)* 60)
         txt_set(nav_stat_pos4,hrs..":"..mins..":"..secs) 
       else
        txt_set(nav_stat_pos4,"_:_")
      end
end
xpl_dataref_subscribe("sim/cockpit2/radios/indicators/hsi_dme_time_min_pilot","FLOAT",nav_info)
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 

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

Re: Keith's LUA Help thread.

#268 Post by Keith Baxter » Sat Mar 06, 2021 10:59 am

Hi,

OK sorted it out. I get these doff moments sometimes. ;)

Code: Select all

if tostring(ete) ~= "inf" then
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 

Mike Horsten
Posts: 79
Joined: Tue Dec 01, 2020 8:50 am

MULTIPLE assignments to one pin

#269 Post by Mike Horsten » Fri Apr 23, 2021 1:00 pm

Hi Guru's.

Noob question, example question. I have a plane with 4 engines, 4 prop controls, 4 minxure controls. Can i assign engine 1/2/3/4 to one linear hardware pod and control alle engines with one. Same would go for the Mixture and Prop control. reason for asking, if i would like to fly a DC6 for example my current setup is a C172. The instruments i can change but the hardware is a bit more tricky.

Code wise it would be same as the tutorial. That has an error in it.
- For X-Plane we need to override the joystick input first NONONONONO this disables all Joystick input like the ruddel pedals, saitek yoke and all others !!!!!
xpl_dataref_write("sim/operation/override/override_joystick", "INT", 1) -- DONT USE this part of the example
[/b]



Mike
Last edited by Mike Horsten on Fri Apr 23, 2021 1:05 pm, edited 2 times in total.
Building a home Cessna 172SP Steam. X-plane/MFS2020
(ex Name on Airmanager forum Polarair)

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

Re: MULTIPLE assignments to one pin

#270 Post by Keith Baxter » Fri Apr 23, 2021 1:02 pm

Mike Horsten wrote:
Fri Apr 23, 2021 1:00 pm
Hi Guru's.

Noob question, example question. I have a plane with 4 engines, 4 prop controls, 4 minxure controls. Can i assign engine 1/2/3/4 to one linear hardware pod and control alle engines with one. Same would go for the Mixture and Prop control. reason for asking, if i would like to fly a DC6 for example my current setup is a C172. The instruments i can change but the hardware is a bit more trickey.

Mike
Mike,

Should be no problem.


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

Who is online

Users browsing this forum: No registered users and 4 guests