static data load(): PATH limited to resource folder ONLY?

Help creating logic scripts for Air Manager Instruments

Moderators: russ, Ralph

Message
Author
JackZ
Posts: 2262
Joined: Mon Feb 22, 2016 1:02 pm

static data load(): PATH limited to resource folder ONLY?

#1 Post by JackZ »

Hi again

@Corjan
I am trying to retrieve a file located somewhere in the Xplane folder.
Since AM has no way I know of to retrieve the current XPlane installation path (such feature would be GREATLY useful), I ended up by writing a two line FlywithLua script to get the current path.
The FlywithLua is as follows

Code: Select all

install_string = create_dataref_table("JZ/install_path", "Data")
install_string[0]=AIRCRAFT_PATH
The result string I get is
"D:\XP11 BETA/X-Plane 11/Aircraft/T-6A Texan II/"

But when I try to reuse this path in static_data_load()

Code: Select all

data=static_data_load("D:\\XP11 BETA\\X-Plane 11\\Aircraft\\T-6A Texan II\\".."UHF_Presets.txt")
or

Code: Select all

data=static_data_load("D:/XP11 BETA/X-Plane 11/Aircraft/T-6A Texan II/".."UHF_Presets.txt")
I get the error Message:

Code: Select all

WARN - logic.lua:221: Static data file 'D:\XP11 BETA\X-Plane 11\Aircraft\T-6A Texan II\UHF_Presets.txt' not found in resource folder
Does that mean that the file HAS to be in the resource folder? This is not clear in the WIKI, and if that's the case, it is quite limiting, as one cannot access a config file of any addon like in my example.

Jacques
My YouTube Chanel on the A320 (Real SOPs by an Airline Pilot IRL):
https://www.youtube.com/playlist?list=P ... 0Q6SBASRqJ

User avatar
Corjan
Posts: 2933
Joined: Thu Nov 19, 2015 9:04 am

Re: static data load(): PATH limited to resource folder ONLY?

#2 Post by Corjan »

Hi,


Yeah, for portability, it is only possible to load it from the resources folder.
A file might be on your system, but might not be on other systems when you share it.

The wiki does say this in the argument list, but it is not very obvious. I will add extra clarification to the wiki.


Corjan

JackZ
Posts: 2262
Joined: Mon Feb 22, 2016 1:02 pm

Re: static data load(): PATH limited to resource folder ONLY?

#3 Post by JackZ »

Hmmm thanks @Corjan I was afraid of this answer.
IMHO this is very limiting for development to say the least, as there are some configuration files which are part of an addon or directly XPlane that one needs to access in a way or another for an instrument to work.
Here my problem is that I need to access a list of frequencies stored in a text file at the addon level, and there is no Dataref available otherwise.

This is an age old recurring problem: I know already that all file access has been removed from the AM LuaJit interpreter (for safety reasons?), and was hoping that the relatively recent static data load() functions would allow some workaround.

The only solution I see now is to ask the user to manually create a copy of the desired file into the resource directory, which is obviously the same problem you wanted to avoid and cumbersome to say the least.
I think it should be up to the developer to handle the case of a non existing file appropriately, and hint the user for a fix with an action like « file xxx is missing, read the f… g manual! », instead of locking everything.

I know that people can’t be trusted, but FlywithLua scripts exist for a long time and are shared all over the Internet without major issue, and they allow file access!

Sorry about my ranting, but as said, this an age old issue. I can understand limiting Lua access via AM to the whole system, but accessing the sim folder structure in a way or another should be allowed for development purposes.

Jacques
My YouTube Chanel on the A320 (Real SOPs by an Airline Pilot IRL):
https://www.youtube.com/playlist?list=P ... 0Q6SBASRqJ

Tetrachromat
Posts: 236
Joined: Sun Feb 14, 2021 6:55 pm

Re: static data load(): PATH limited to resource folder ONLY?

#4 Post by Tetrachromat »

Hi Jaques,

Did you try to place a symbolic link to that file into the ressource folder? I would expect that accessing a file through the link should work as this is handled on the O/S level.

Cloning might not work with a link.

Paul

User avatar
Corjan
Posts: 2933
Joined: Thu Nov 19, 2015 9:04 am

Re: static data load(): PATH limited to resource folder ONLY?

#5 Post by Corjan »

Hi,


Yeah, can imagine this can be annoying.

But any instrument shouldn't rely on anything but itself and Air Manager.
If that is not enforced, there is no way to be able to run instrument on multiple platforms.


Corjan

JackZ
Posts: 2262
Joined: Mon Feb 22, 2016 1:02 pm

Re: static data load(): PATH limited to resource folder ONLY?

#6 Post by JackZ »

@Corjan
I strongly disagree, but I understand this can be a problem with the tablet version, where there is no way to access the resource folder anyways. So in any case my instrument would not be deemed suitable for the store on that respect, since it would require the user to place a file in the resource folder?

For the XPlane path, FlywithLua has two features that allow to overcome the OS problem (XPlane is cross platform as everyone knows, even on the Mac):
- A variable that returns the current XPlane directory
- A variable that returns the current separator in use by the Os(guess it’s either / or \ for Linux vs Windows)
- A variable that returns the current aircraft directory

Guess with that few features it got you covered on the OS compatibility side?

Take for example the adjustable airspeed gauge devised by Russ. There are some informations about the aircraft that it would be highly desirable to get from the acf or other xml file located in the XPlane or FSX/P3D directory.
This kind of gauge can’t be fully automated for this very reason.

The access to the installation folder where the sim is located would definitely be a plus.


Jacques
@Tetrachromat Thanks for the idea I will try, but nonetheless this requires an manual intervention by the end user which I wanted to avoid.
The only workaround I can see is to create a SASL or Flywithlua script to read the file, create a Dataref or another file in the resource folder for it to be accessed by AM.
Kinda a waste of resource IMHO.
My YouTube Chanel on the A320 (Real SOPs by an Airline Pilot IRL):
https://www.youtube.com/playlist?list=P ... 0Q6SBASRqJ

User avatar
Corjan
Posts: 2933
Joined: Thu Nov 19, 2015 9:04 am

Re: static data load(): PATH limited to resource folder ONLY?

#7 Post by Corjan »

Hi,


The resource folder is available on tablets, same way as on Desktop systems.

There is no way to develop instruments though.


Corjan

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

Re: static data load(): PATH limited to resource folder ONLY?

#8 Post by Keith Baxter »

Corjan wrote: Mon Jul 26, 2021 1:18 pm
But any instrument shouldn't rely on anything but itself and Air Manager.
If that is not enforced, there is no way to be able to run instrument on multiple platforms.

Corjan
Hmm.. My thoughts Corjan.
Most of us only run our instruments on ONE platform.
Majority of these requests stem from instruments for a specific AirFrame from a specific Dev house. So IF they find their way to the store (I think this is your concern) they are indicated to be comparable for a sim, AirFrame and dev house and use custom datarefs and commands anyway.. This is the current situation and very acceptable.

IRL a instrument relies on data. That data can be sourced from many sources. Air Manager, IMO should be able to access any data necessary to operate correctly. Not only data available from the sim but the whole sim environment.

SI has gone a long way to try and help by adding features such as maps and nav data etc which is not sim type dictated. Accessing other options would be a huge benefit and welcomed.

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
Corjan
Posts: 2933
Joined: Thu Nov 19, 2015 9:04 am

Re: static data load(): PATH limited to resource folder ONLY?

#9 Post by Corjan »

Hi,


That is not true, developers run it on one platform. But the majority of the people run it on different platforms that it was developed on.

I understand that the limitation is annoying, but I still feel there is a good reason for it.
This was also our intention from the start way back when. A lot of tools require you to move with files or set file paths to get going. We are stricktly against that, since most people don't know how.

An important question to ask here I think is what data is required from X-plane. It might be possible to source that data from the plugin to AM.


Corjan

JackZ
Posts: 2262
Joined: Mon Feb 22, 2016 1:02 pm

Re: static data load(): PATH limited to resource folder ONLY?

#10 Post by JackZ »

In my particular problem, there is an XPlane addon (as Keith said, most of the current development is done for specific addons, the stock planes are already covered.
This addon has a Radio Management Unit which allows to use frequencies stored into memory from 1 to 20 for UHF, VHF and NAv radios.
The addon uses for this three text files in the XPlane Aircraft folder that can be modified by the user to offer for each memory slot the desired frequency. The stored frequencies are nowhere available in the sim from any dataref.
So the only way for me to access these user frequencies is to actually READ these three text files.

But now I have to ask the user to CLONE the files from their XPlane folder into the AM resource folder
My YouTube Chanel on the A320 (Real SOPs by an Airline Pilot IRL):
https://www.youtube.com/playlist?list=P ... 0Q6SBASRqJ

Post Reply