Setup Factory (Indigo Rose)

#1
I'm working on re-building all my installers with Setup Factory and I'm kind of needing some help as well as thinking a thread that can help other developers build their installers for FSX and P3D would also be helpful.

I have several issues I need to address at the moment that are blocking me from moving forward and I am having issues with getting into the software developers forums to ask questions.

  1. I can't seem to find a way to get the installers to install my folders/subfolders into an FSX/P3D directory. It defaults to %AppFolder% but there doesn't seem to be anything in the documentation to install to a certain directory.

  2. For step 1 above to be successful I also need to read the registry value of the FSX/P3D registry values for the "AppPath" and somehow hand it off to Setup Factory somewhere. I have set it to get registry values for FSX/FSX:SE/ESP/P3D/P3Dv2 respectively but I need to somehow hand that off to a value that would replace %AppFolder%

  3. I need to be able to ask a user which simulator they are installing the scenery into.
I have a few other things I need to do as well such as software keys etc but those can wait till I get the above 3 things working.
 
#4
It's been a while since I've dug around in Setup Factory but here it goes...

You need to define a session variables for the folders. I did this in the 'actions' tab 'on startup' with this (note the double slashes):

SessionVar.Set("%FSXFiles%", Registry.GetValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Microsoft Games\\Flight Simulator\\10.0", "AppPath", true));
SessionVar.Set("%P3DFiles%", Registry.GetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wow6432Node\\Lockheed Martin\\Prepar3D v2", "AppPath", true));
(or however many you need to setup...)

Then make a radio button page to select which installation is required and use this code to validate and set the correct packages for installation:
(be sure to name your radio buttons and call them correctly)


local nSelectedControl = String.ToNumber(SessionVar.Expand("%RadioSelection%"));

if (nSelectedControl == CTRL_RADIO_BUTTON_01) then
SetupData.SetPackageProperties("FSX", {Install=true});
SetupData.SetPackageProperties("P3D", {Install=false});
-- advance to the next screen (fsx inthis case)
Screen.Next();
elseif (nSelectedControl == CTRL_RADIO_BUTTON_02) then
SetupData.SetPackageProperties("FSX", {Install=false});
SetupData.SetPackageProperties("P3D", {Install=true});
-- jump to the p3d screen
Screen.Jump("Select Install Folder P3D");

else
Dialog.Message("Error", "Invalid selection");
end


You will need to make as many 'select install folder' screens as packages you need to install - in this case 2.
To have the install page correctly show the file path it pulled from the registry use the %FSXFiles% (or whatever you call it) variable in the default folder under screen properties/settings.
Make sure you have set up the packages under 'project' and assigned the various files and folders to the correct package in archive tab.
Then you should be good to go. Or not... let me know
Cheers,
Ian
 
#5
NSIS is powerful, but unfortunately way too complicated extremely code based, far too complicated. Plus I've recently invested $400-500 in Setup Factory due to it meeting my needs of powerful but simple. :D

I'm moving away from Install creator as there's a hard 2GB limit on file sizes and can't do all that needs to be done unfortunately. It served me for a long time but on 64GB sized addons it unfortunately has some limits... :(

Ian, thanks so much, I had about half of that put together in terms of pulling registry values and radio buttons, that code should hopefully help me to hook it all together :D I'll give it a shot. Once I have it complete I'll set up a template installer other developers can use (for scenery first) and possibly aircraft :)
 
Last edited:
#6
Alrighty, this is my "On Startup" actions code...

Code:
SessionVar.Set("%FSXSEFiles%", Registry.GetValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Microsoft Games\\Flight Simulator - Steam Edition\\10.0", "AppPath", true));
SessionVar.Set("%FSXFiles%", Registry.GetValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Microsoft Games\\Flight Simulator\\10.0", "AppPath", true));
SessionVar.Set("%P3Dv2Files%", Registry.GetValue(HKEY_CURRENT_USER, "SOFTWARE\\Lockheed Martin\\Prepar3D v2", "AppPath", true));
SessionVar.Set("%P3Dv1Files%", Registry.GetValue(HKEY_CURRENT_USER, "SOFTWARE\\LockheedMartin\\Prepar3D", "AppPath", true));
SessionVar.Set("%ESPFiles%", Registry.GetValue(HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\Microsoft ESP", "AppPath", true));
Okay I've then pasted this code into the "On Next" tab and I've got it assigning the folders all correctly...

Code:
-- These actions are performed when the Next button is clicked.
-- Tip: this is where you could add actions to validate the
--      user's input before proceeding

-- advance to the next screen
local nSelectedControl = String.ToNumber(SessionVar.Expand("%RadioSelection%"));

if (nSelectedControl == CTRL_RADIO_BUTTON_01) then
SetupData.SetPackageProperties("FSX:SE", {Install=true});
SetupData.SetPackageProperties("FSX", {Install=false});
SetupData.SetPackageProperties("P3Dv2", {Install=false});
SetupData.SetPackageProperties("P3Dv1", {Install=false});
SetupData.SetPackageProperties("ESP", {Install=false});
-- advance to the next screen (FSX:SE in this case)
Screen.Next();

elseif (nSelectedControl == CTRL_RADIO_BUTTON_02) then
SetupData.SetPackageProperties("FSX:SE", {Install=false});
SetupData.SetPackageProperties("FSX", {Install=true});
SetupData.SetPackageProperties("P3Dv2", {Install=false});
SetupData.SetPackageProperties("P3Dv1", {Install=false});
SetupData.SetPackageProperties("ESP", {Install=false});
-- jump to the FSX screen
Screen.Jump("Select FSX Install Folder");

elseif (nSelectedControl == CTRL_RADIO_BUTTON_03) then
SetupData.SetPackageProperties("FSX:SE", {Install=false});
SetupData.SetPackageProperties("FSX", {Install=false});
SetupData.SetPackageProperties("P3Dv2", {Install=true});
SetupData.SetPackageProperties("P3Dv1", {Install=false});
SetupData.SetPackageProperties("ESP", {Install=false});
-- jump to the P3Dv2 screen
Screen.Jump("Select P3Dv2 Install Folder");

elseif (nSelectedControl == CTRL_RADIO_BUTTON_04) then
SetupData.SetPackageProperties("FSX:SE", {Install=false});
SetupData.SetPackageProperties("FSX", {Install=false});
SetupData.SetPackageProperties("P3Dv2", {Install=false});
SetupData.SetPackageProperties("P3Dv1", {Install=true});
SetupData.SetPackageProperties("ESP", {Install=false});
-- jump to the P3Dv1 screen
Screen.Jump("Select P3Dv1 Install Folder");

elseif (nSelectedControl == CTRL_RADIO_BUTTON_05) then
SetupData.SetPackageProperties("FSX:SE", {Install=false});
SetupData.SetPackageProperties("FSX", {Install=false});
SetupData.SetPackageProperties("P3Dv2", {Install=false});
SetupData.SetPackageProperties("P3Dv1", {Install=false});
SetupData.SetPackageProperties("ESP", {Install=true});
-- jump to the ESP screen
Screen.Jump("Select ESP Install Folder");

else
Dialog.Message("Error", "Invalid selection");
end
I also had to add an extra step I'll outline below...

On each of the "Select *** Install Folder" pages I had to change "Screen.Next();" to "Screen.Jump("Ready to Install");"

This was to ensure that when I clicked on next it didn't just go to the next "Select *** Install Folder" screen.

Code:
-- These actions are performed when the Next button is clicked.

-- from _SUF70_Global_Functions.lua:
-- make sure the install folder path is formatted properly (i.e. is a valid UNC or DOS path string)
if(g_IsValidPath(strInstallFolderPath)) then

    -- if there's enough space on the selected drive, proceed to the next screen
    if(_SpaceAvailable >= _SpaceRequired) then
        -- there's enough space on the drive...so
        -- proceed to the next screen
        Screen.Jump("Ready to Install");
    else
        -- there isn't enough space on the drive...
       
        -- from _SUF70_Global_Functions.lua:
        -- ask the user if they want to continue anyway
        if g_ConfirmFreeSpaceOverride() then
            -- user said to install anyway...so
            -- advance to the next screen
        Screen.Jump("Ready to Install");
        end
    end
else
    -- the install folder path isn't valid...
   
    local strTitle = SetupData.GetLocalizedString("MSG_INVALID_ENTRY");
    local strPrompt;

    -- from _SUF70_Global_Functions.lua:
    -- check whether the install folder path contains only valid path characters
    if(g_ContainsValidPathChars(strInstallFolderPath)) then
        -- the string is just formatted wrong
        strPrompt = SetupData.GetLocalizedString("ERR_INVALID_PATH");
    else
        -- the string contains invalid characters
        strPrompt = SetupData.GetLocalizedString("ERR_INVALID_CHARACTERS") .. "\r\n/ * ? \" < > |";       
    end

    -- tell the user to smarten up :)
    Dialog.Message(strTitle, strPrompt, MB_OK, MB_ICONEXCLAMATION);
end
I've just set it all up and had a successful test on FSX:SE, FSX and P3Dv2 (and P3Dv1 and ESP should both work as well).

Now to add code to add entries to each scenery.cfg file o_O
 
Last edited:
#7
I have code for the scenery.cfg entry addition and removal on uninstall if you have any trouble figuring it out, Let me know.
Cheers,
Ian
 
#9
I use a button screen for the scenery.cfg entry asking the user if they would like it added - since there are some who do not.
You would have to change the paths for P3DV1 & V2 and have separate screens for them.
On the screen 'pre load' tab I have the installer check to see if the entry already exists, if it does it skips the whole step and moves on:

-- load INI file
fsx_sections = INIFile.GetSectionNames("%ApplicationDataFolderCommon%\\Microsoft\\FSX\\Scenery.CFG");

-- Check to see if any error occurred.
error = Application.GetLastError();

-- If an error occurred, display the error message.
if (error ~= 0) then
Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION);
else
found = false;
-- Check to see if any sections are present.
if (fsx_sections ~= nil) then
-- Go through each section and try to get a value.
for index_section, section in pairs(fsx_sections) do
-- Try to get the data of the value you want.
value_data = INIFile.GetValue("%ApplicationDataFolderCommon%\\Microsoft\\FSX\\Scenery.CFG", section, "Title");

-- If the value was found, skip the process.
if value_data == "[put your scenery name here]" then
Screen.Next();

-- Check to see if any error occurred.
error = Application.GetLastError();
-- If an error occurred, display the error message.
if (error ~= 0) then
Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION);
end

found = true;
break;
end
end
end

end



Assuming the entry wasn't present and the user clicks 'yes' then I use this code to load the file, count the sections, determine the number of the highest section and assign that number + 1 to our scenery entry.
This is on the 'on ctrl message' tab of the same screen



if (e_MsgID == MSGID_CLICKED) then
-- a control was clicked...

if (e_CtrlID == CTRL_BUTTON_01) then

-- Yes button handling code here




-- create a backup copy
File.Copy(SessionVar.Expand("%ApplicationDataFolderCommon%\\Microsoft\\FSX\\Scenery.CFG"), SessionVar.Expand("%ApplicationDataFolderCommon%\\Microsoft\\FSX\\Scenery_Before_[put your scenery name here].CFG"), false, true, true, true, nil);
-- get the sections, sorts and counts
section_names = INIFile.GetSectionNames("%ApplicationDataFolderCommon%\\Microsoft\\FSX\\Scenery.CFG");
Table.Sort(section_names, nil);
y=Table.Count(section_names);
layer=String.Mid(section_names[y-1],6,String.Length(section_names[y-1])-5)+1;


table_two = section_names;
removed_item = Table.Remove(table_two, y);
max_value=0;
for j,k in pairs(table_two) do
value = INIFile.GetValue("%ApplicationDataFolderCommon%\\Microsoft\\FSX\\Scenery.CFG", k, "Layer")+0;


if value>max_value then max_value=value;
end

end

if max_value > layer then layer=max_value+1; end

-- creates the area and layer
area_layer = String.Concat("Area.", layer);


-- adds a blank line
TextFile.WriteFromString("%ApplicationDataFolderCommon%\\Microsoft\\FSX\\Scenery.CFG", "\r", true);
-- adds scenery entry
INIFile.SetValue("%ApplicationDataFolderCommon%\\Microsoft\\FSX\\Scenery.CFG", area_layer, "Title","[put your scenery name here]");
INIFile.SetValue("%ApplicationDataFolderCommon%\\Microsoft\\FSX\\Scenery.CFG", area_layer, "Local","Addon Scenery\\[put your scenery name here]");
INIFile.SetValue("%ApplicationDataFolderCommon%\\Microsoft\\FSX\\Scenery.CFG", area_layer, "Active","TRUE");
INIFile.SetValue("%ApplicationDataFolderCommon%\\Microsoft\\FSX\\Scenery.CFG", area_layer, "Required","FALSE");
INIFile.SetValue("%ApplicationDataFolderCommon%\\Microsoft\\FSX\\Scenery.CFG", area_layer, "Layer",layer);



Dialog.Message("Yes","Scenery.cfg entry has been added", MB_OK, MB_ICONEXCLAMATION);
Screen.Next();

end

if (e_CtrlID == CTRL_BUTTON_02) then

-- No button handling code here

Dialog.Message("No","Scenery.cfg entry has NOT been added. Please be sure to manually add the entry or the scenery will not appear.", MB_OK, MB_ICONEXCLAMATION);
Screen.Next();
end

end
 
#10
I have code for the scenery.cfg entry addition and removal on uninstall if you have any trouble figuring it out, Let me know.
Cheers,
Ian
Thanks Ian, I did have some code, but the one who sent it through to me is away from home for until October. I have my old VB6 code but no way to re-compile it. I'll add these in.

I'll send you a PM as well once I get it all hooked up ;)
 

n4gix

Resource contributor
#11
NSIS is powerful, but unfortunately way too complicated extremely code based, far too complicated. Plus I've recently invested $400-500 in Setup Factory due to it meeting my needs of powerful but simple. :D
I found your comment rather puzzling, given that the script 'language' used by Setup Factory is pretty darn near identical to the script 'language' that NSIS uses... :confused:

As for Click Team, their "program" is nothing more than a shell that uses NSIS as its' core engine. It is a very clever albeit somewhat inflexible shell, but nonetheless a good bit of kit for basic needs. :twocents:

It's good to read that you're close to getting your installer sorted though! :cool:
 
#12
Bill it's more that I am a creative and visual person ;) , when it's primarily code I go cross eyed and it nearly fries my brain. For a program to work for me it needs to have form and function and be intuitive. i.e. work primarily visually and then work on the code on a deeper level later ;)

I'm almost there with the installers, next stage is I need to add in email functions and try and sort out if I can FTP in files during the install, however I don't seem to be able to find where to get the plugins anymore for that particular function.

This has been a very long journey for me. From 16 bit Unix servers that could only handle 2GB files originally, to now has been a real challenge. I can't wait to get up to speed with setting up the installer scripts and then being able to automate that part of the process as well.
 
Last edited:
#13
Ian I decided to change the buttons to a radio button, to make sure users couldn't skip the step choice by pressing next. :)

Code:
-- These actions are performed when the Next button is clicked.
-- Tip: this is where you could add actions to validate the
--      user's input before proceeding

-- advance to the next screen
local nSelectedControl = String.ToNumber(SessionVar.Expand("%RadioSelection%"));

if (nSelectedControl == CTRL_RADIO_BUTTON_01) then

-- Add to scenery.cfg

-- Yes button handling code here

-- create a backup copy
File.Copy(SessionVar.Expand("%ApplicationDataFolderCommon%\\Microsoft\\FSX-SE\\Scenery.CFG"), SessionVar.Expand("%ApplicationDataFolderCommon%\\Microsoft\\FSX-SE\\Scenery_Before_[put your scenery name here].CFG"), false, true, true, true, nil);

-- get the sections, sorts and counts
section_names = INIFile.GetSectionNames("%ApplicationDataFolderCommon%\\Microsoft\\FSX-SE\\Scenery.CFG");
Table.Sort(section_names, nil);
y=Table.Count(section_names);
layer=String.Mid(section_names[y-1],6,String.Length(section_names[y-1])-5)+1;


table_two = section_names;
removed_item = Table.Remove(table_two, y);
max_value=0;
for j,k in pairs(table_two) do
value = INIFile.GetValue("%ApplicationDataFolderCommon%\\Microsoft\\FSX-SE\\Scenery.CFG", k, "Layer")+0;


if value>max_value then max_value=value;
end

end

if max_value > layer then layer=max_value+1; end

-- creates the area and layer
area_layer = String.Concat("Area.", layer);


-- adds a blank line
TextFile.WriteFromString("%ApplicationDataFolderCommon%\\Microsoft\\FSX-SE\\Scenery.CFG", "\r", true);
-- adds scenery entry
INIFile.SetValue("%ApplicationDataFolderCommon%\\Microsoft\\FSX-SE\\Scenery.CFG", area_layer, "Title","[put your scenery name here]");
INIFile.SetValue("%ApplicationDataFolderCommon%\\Microsoft\\FSX-SE\\Scenery.CFG", area_layer, "Local","Addon Scenery\\[put your scenery name here]");
INIFile.SetValue("%ApplicationDataFolderCommon%\\Microsoft\\FSX-SE\\Scenery.CFG", area_layer, "Active","TRUE");
INIFile.SetValue("%ApplicationDataFolderCommon%\\Microsoft\\FSX-SE\\Scenery.CFG", area_layer, "Required","FALSE");
INIFile.SetValue("%ApplicationDataFolderCommon%\\Microsoft\\FSX-SE\\Scenery.CFG", area_layer, "Layer",layer);


Dialog.Message("Yes","Scenery.cfg entry has been added", MB_OK, MB_ICONEXCLAMATION);
Screen.Jump("Ready to Install");

elseif (nSelectedControl == CTRL_RADIO_BUTTON_02) then

-- No button handling code here

Dialog.Message("No","Scenery.cfg entry has NOT been added. Please be sure to manually add the entry or the scenery will not appear.", MB_OK, MB_ICONEXCLAMATION);
Screen.Jump("Ready to Install");
end
I just noticed though, my users will often need to have the full file path such as "F:\\Addon Scenery\[put your scenery name here]"

With the above settings it'll only give the relative path to FSX... I'm trying to dig into the documentation to see how I can provide a full path to the scenery directory, but am going a bit cross eyed.

The following line is where I'm having issues...

INIFile.SetValue("%ApplicationDataFolderCommon%\\Microsoft\\FSX-SE\\Scenery.CFG", area_layer, "Local","Addon Scenery\\[put your scenery name here]");

I need it to read something like:

INIFile.SetValue("%ApplicationDataFolderCommon%\\Microsoft\\FSX-SE\\Scenery.CFG", area_layer, "Local","[%full path to scenery%]\\[put your scenery name here]");

Also I'm hoping to make life easier for myself by pulling the %ProductName% session variable to replace the [put your scenery name here] lines.

I'm not quite sure how to set a string that can pull in the %ProductName% to fill in those values.

e.g.

strProductName = %ProductName% ( <- this doesn't work :p )

INIFile.SetValue("%ApplicationDataFolderCommon%\\Microsoft\\FSX-SE\\Scenery.CFG", area_layer, "Title",strProductName);
 
Last edited:
#14
Hi Dean,
Not a bad idea, in fact one I think I'm going to use;) - here's how it's done:

You have:
INIFile.SetValue("%ApplicationDataFolderCommon%\\Microsoft\\FSX-SE\\Scenery.CFG", area_layer, "Local","[%full path to scenery%]\\[put your scenery name here]");

%ProductName% and %AppFolder% (now the full path to the base fs folder) are session variables and need expanding. It becomes this:

INIFile.SetValue("%ApplicationDataFolderCommon%\\Microsoft\\FSX\\Scenery.CFG", area_layer, "Title",SessionVar.Expand("%ProductName%"));
INIFile.SetValue("%ApplicationDataFolderCommon%\\Microsoft\\FSX\\Scenery.CFG", area_layer, "Local",SessionVar.Expand("%AppFolder%\\Addon Scenery\\%ProductName%"));
 
#15
Awesome Ian, thanks so much, just added that code in and tweaked the backup of the scenery.cfg to:

File.Copy(SessionVar.Expand("%ApplicationDataFolderCommon%\\Microsoft\\FSX-SE\\Scenery.CFG"), SessionVar.Expand("%ApplicationDataFolderCommon%\\Microsoft\\FSX-SE\\Scenery_Before_%ProductName%.CFG"), false, true, true, true, nil);

Now I have a session variable listed for each state in my project settings and all I have to do is change the state name variable, and now it builds the product names and scenery.cfg entries all automatically.

Next phase... Learning how to convert my projects to scripts I can then add into my scenery production routines and have them automatically build the installers once the scenery is rendered. After that, some other magic to take manual control away from me and then I can have time in my life to date my wife again :)
 
#17
Running a beta test and one of my users got the following on Win10 Home... All the installers work fine on my system...

Any ideas? The line referenced at 19 is:

Code:
Table.Sort(section_names, nil);
error.jpg


Oh I think the reason it failed was because it didn't locate the default location for FSX-SE on the users system. I'll double check if he's changed folders or something.

Yep, it was looking for the FSX-SE.cfg when the user had FSX.cfg on his system for SE.
 
Last edited:
#18
Discovered a little something peculiar today with Prepar3d v4 and scenery.cfg, and may need help to get the installers for SetUp Factory working to be able to read and change encoding on the scenery.cfg. I posted in the Prepar3d forum about the issue that affects everyone and have copied it here. The post here is to see if anyone has a solution on the installer side to be able to change the encoding of the scenery.cfg back to ANSI or to copy code in as UNICODE into the scenery.cfg file.

Discovered a little thing to be aware of with Prepar3d v4 today.

The scenery.cfg when installed clean is encoded as ANSI, as per previous versions of the sim. If users add scenery via installers into this it should all work fine.

However...

If you delete the scenery.cfg from P3D v4 and the sim regenerates a new one, it is encoded as UNICODE. Subsequently if you try and install some 3rd party software into it, you'll end up with chinese characters and the scenery.cfg losing all entries. (see attached)

So, if anyone is using Prepar3d v4 be aware of this issue. It is a simple fix to open the scenery.cfg file in notepad.exe and save as scenery.cfg and ensure the file is encoded to ANSI. This will ensure it should all work as before.

As for updating code for how to encode and update the scenery.cfg to UNICODE on the Setup Factory code side.
 

Attachments

#19
Hi,

I've been following your topic as I'm working in the same program to create my installer.

Your code helped me a lot, thank you. I've just got one problem, my scenery requires two entries to 'scenery.cfg' file, one with _LC and another with airport itself one over another.

Code:
-- These actions are performed when the Next button is clicked.
-- Tip: this is where you could add actions to validate the
--      user's input before proceeding

-- advance to the next screen
local nSelectedControl = String.ToNumber(SessionVar.Expand("%RadioSelection%"));

if (nSelectedControl == CTRL_RADIO_BUTTON_01) then

-- Add to scenery.cfg

-- Yes button handling code here

-- create a backup copy
File.Copy(SessionVar.Expand("%ApplicationDataFolderCommon%\\Lockheed Martin\\Prepar3D v4\\Scenery.CFG"), SessionVar.Expand("%ApplicationDataFolderCommon%\\Lockheed Martin\\Prepar3D v4\\Scenery_Before_MKFuerte2017_1.CFG"), false, true, true, true, nil);

-- get the sections, sorts and counts
section_names = INIFile.GetSectionNames("%ApplicationDataFolderCommon%\\Lockheed Martin\\Prepar3D v4\\Scenery.CFG");
Table.Sort(section_names, nil);
y=Table.Count(section_names);
layer=String.Mid(section_names[y-1],6,String.Length(section_names[y-1])-5)+1;


table_two = section_names;
removed_item = Table.Remove(table_two, y);
max_value=0;
for j,k in pairs(table_two) do
value = INIFile.GetValue("%ApplicationDataFolderCommon%\\Lockheed Martin\\Prepar3D v4\\Scenery.CFG", k, "Layer")+0;


if value>max_value then max_value=value;
end

end

if max_value > layer then layer=max_value+1; end

-- creates the area and layer
area_layer = String.Concat("Area.", layer);


-- adds a blank line
TextFile.WriteFromString("%ApplicationDataFolderCommon%\\Lockheed Martin\\Prepar3D v4\\Scenery.CFG", "\r", true);
-- adds scenery entry
INIFile.SetValue("%ApplicationDataFolderCommon%\\Lockheed Martin\\Prepar3D v4\\Scenery.CFG", area_layer, "Title","MYscenery_LC");
INIFile.SetValue("%ApplicationDataFolderCommon%\\Lockheed Martin\\Prepar3D v4\\Scenery.CFG", area_layer, "Local","Ecosystem\Myscenery_LC");
INIFile.SetValue("%ApplicationDataFolderCommon%\\Lockheed Martin\\Prepar3D v4\\Scenery.CFG", area_layer, "Active","TRUE");
INIFile.SetValue("%ApplicationDataFolderCommon%\\Lockheed Martin\\Prepar3D v4\\Scenery.CFG", area_layer, "Required","FALSE");
INIFile.SetValue("%ApplicationDataFolderCommon%\\Lockheed Martin\\Prepar3D v4\\Scenery.CFG", area_layer, "Layer",layer);


Dialog.Message("Yes","Scenery.cfg entry has been added", MB_OK, MB_ICONEXCLAMATION);
Screen.Jump("Ready to Install");


Dialog.Message("No","Scenery.cfg entry has NOT been added. Please be sure to manually add the entry or the scenery will not appear.", MB_OK, MB_ICONEXCLAMATION);
Screen.Jump("Ready to Install");
end
I need another layer +2 containing this:

Code:
-- adds a blank line
TextFile.WriteFromString("%ApplicationDataFolderCommon%\\Lockheed Martin\\Prepar3D v4\\Scenery.CFG", "\r", true);
-- adds scenery entry
INIFile.SetValue("%ApplicationDataFolderCommon%\\Lockheed Martin\\Prepar3D v4\\Scenery.CFG", area_layer, "Title","MYscenery");
INIFile.SetValue("%ApplicationDataFolderCommon%\\Lockheed Martin\\Prepar3D v4\\Scenery.CFG", area_layer, "Local","Ecosystem\Myscenery");
INIFile.SetValue("%ApplicationDataFolderCommon%\\Lockheed Martin\\Prepar3D v4\\Scenery.CFG", area_layer, "Active","TRUE");
INIFile.SetValue("%ApplicationDataFolderCommon%\\Lockheed Martin\\Prepar3D v4\\Scenery.CFG", area_layer, "Required","FALSE");
INIFile.SetValue("%ApplicationDataFolderCommon%\\Lockheed Martin\\Prepar3D v4\\Scenery.CFG", area_layer, "Layer",layer);
Do you have any idea how this can be done? I'm not familiar with coding stuff at all. I tried to add another radio button operation but it doesn't seem to be working well.

[EDIT]

There's one more thing that my installer needs to do.
It should edit SIM\Autogen\Default.XML and under entry <CODE>J</CODE> add this entry:

Code:
<CLASS>
            <NAME>LIGHTS</NAME>
            <GUID>1fcb6ae7493f1ce73b85b784efad33e4</GUID>
            <WIDTH>5</WIDTH>
            <DEPTH>5</DEPTH>
            <LIBRARYOBJECT>
                <NAME>LIGHT</NAME>
                <GUID>3dbc6d534bc56125c22ae0a08633a3b5</GUID>
            </LIBRARYOBJECT>
        </CLASS>
Do you think it's possible?

Thanks!
Mateusz
 
Last edited:
#20
Hi,

I've been following your topic as I'm working in the same program to create my installer.

Your code helped me a lot, thank you. I've just got one problem, my scenery requires two entries to 'scenery.cfg' file, one with _LC and another with airport itself one over another.


Do you think it's possible?

Thanks!
Mateusz
Hi Matuesz,

This is the way I did it with mine, it's not a perfect system, but I get both entries into scenery.cfg

Code:
-- These actions are performed when the Next button is clicked.
-- Tip: this is where you could add actions to validate the
--      user's input before proceeding

-- advance to the next screen
local nSelectedControl = String.ToNumber(SessionVar.Expand("%RadioSelection%"));

if (nSelectedControl == CTRL_RADIO_BUTTON_01) then

-- Add to scenery.cfg

-- Yes button handling code here

-- create a backup copy
File.Copy(SessionVar.Expand("%ApplicationDataFolderCommon%\\Lockheed Martin\\Prepar3D v4\\scenery.cfg"), SessionVar.Expand("%ApplicationDataFolderCommon%\\Lockheed Martin\\Prepar3D v4\\Scenery_Before_%ProductName%.CFG"), false, true, true, true, nil);

-- get the sections, sorts and counts 
section_names = INIFile.GetSectionNames("%ApplicationDataFolderCommon%\\Lockheed Martin\\Prepar3D v4\\scenery.cfg");
Table.Sort(section_names, nil);
y=Table.Count(section_names);
layer=String.Mid(section_names[y-1],6,String.Length(section_names[y-1])-5)+1;


table_two = section_names;
removed_item = Table.Remove(table_two, y);
max_value=0;
for j,k in pairs(table_two) do
value = INIFile.GetValue("%ApplicationDataFolderCommon%\\Lockheed Martin\\Prepar3D v4\\scenery.cfg", k, "Layer")+0;


if value>max_value then max_value=value;
end

end

if max_value > layer then layer=max_value+1; end

-- creates the area and layer
area_layer = String.Concat("Area.", layer);


-- adds a blank line
TextFile.WriteFromString("%ApplicationDataFolderCommon%\\Lockheed Martin\\Prepar3D v4\\Scenery.CFG", "\r", true);
-- adds scenery entry
INIFile.SetValue("%ApplicationDataFolderCommon%\\Lockheed Martin\\Prepar3D v4\\Scenery.CFG", area_layer, "Title","MYscenery_LC");
INIFile.SetValue("%ApplicationDataFolderCommon%\\Lockheed Martin\\Prepar3D v4\\Scenery.CFG", area_layer, "Local","Ecosystem\Myscenery_LC");
INIFile.SetValue("%ApplicationDataFolderCommon%\\Lockheed Martin\\Prepar3D v4\\Scenery.CFG", area_layer, "Active","TRUE");
INIFile.SetValue("%ApplicationDataFolderCommon%\\Lockheed Martin\\Prepar3D v4\\Scenery.CFG", area_layer, "Required","FALSE");
INIFile.SetValue("%ApplicationDataFolderCommon%\\Lockheed Martin\\Prepar3D v4\\Scenery.CFG", area_layer, "Layer",layer);

-- get the sections, sorts and counts 
section_names = INIFile.GetSectionNames("%ApplicationDataFolderCommon%\\Lockheed Martin\\Prepar3D v4\\scenery.cfg");
Table.Sort(section_names, nil);
y=Table.Count(section_names);
layer=String.Mid(section_names[y-1],6,String.Length(section_names[y-1])-5)+1;


table_two = section_names;
removed_item = Table.Remove(table_two, y);
max_value=0;
for j,k in pairs(table_two) do
value = INIFile.GetValue("%ApplicationDataFolderCommon%\\Lockheed Martin\\Prepar3D v4\\scenery.cfg", k, "Layer")+0;


if value>max_value then max_value=value;
end

end

if max_value > layer then layer=max_value+1; end

-- creates the area and layer
area_layer = String.Concat("Area.", layer);


-- adds a blank line
TextFile.WriteFromString("%ApplicationDataFolderCommon%\\Lockheed Martin\\Prepar3D v4\\Scenery.CFG", "\r", true);
-- adds scenery entry
INIFile.SetValue("%ApplicationDataFolderCommon%\\Lockheed Martin\\Prepar3D v4\\Scenery.CFG", area_layer, "Title","MYscenery");
INIFile.SetValue("%ApplicationDataFolderCommon%\\Lockheed Martin\\Prepar3D v4\\Scenery.CFG", area_layer, "Local","Ecosystem\Myscenery");
INIFile.SetValue("%ApplicationDataFolderCommon%\\Lockheed Martin\\Prepar3D v4\\Scenery.CFG", area_layer, "Active","TRUE");
INIFile.SetValue("%ApplicationDataFolderCommon%\\Lockheed Martin\\Prepar3D v4\\Scenery.CFG", area_layer, "Required","FALSE");
INIFile.SetValue("%ApplicationDataFolderCommon%\\Lockheed Martin\\Prepar3D v4\\Scenery.CFG", area_layer, "Layer",layer);

Dialog.Message("Yes","Scenery.cfg entry has been added", MB_OK, MB_ICONEXCLAMATION);
Screen.Jump("Ready to Install");

elseif (nSelectedControl == CTRL_RADIO_BUTTON_02) then

-- No button handling code here

Dialog.Message("No","Scenery.cfg entry has NOT been added. Please be sure to manually add the entry or the scenery will not appear.", MB_OK, MB_ICONEXCLAMATION);
Screen.Jump("Ready to Install");
end
 
Top