• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

FSX automatically put scenery into library

Messages
55
Country
germany
Hi all!

I'm looking for a way to write an addon scenery path directly to the FSX scenery library.

I created some addon scenery and like to put it in an "addon scenery" subdirectory, rather than mixing it with other scenery addon files.

It would be nice to be able to register scenery automatically because it might minimize user questions on how to do it manually and how to work around the Win7 bug.

Thanks for help!
Carsten
 
Last edited:
NSIS lets me include this in my installers -- one of the advantages of a scriptable installer, I guess.
 
Quick Update

Hello!
What I found out by now is that the scenery.cfg file contains the scenery areas and layer order.

I'm able to write a new section and values into that file with my setup script, but how can I get the next avaiable Layer/Area number for my scenery?

Thanks for help.
Carsten
 
Hello!
What I found out by now is that the scenery.cfg file contains the scenery areas and layer order.

I'm able to write a new section and values into that file with my setup script, but how can I get the next avaiable Layer/Area number for my scenery?

Thanks for help.
Carsten

I'm not sure how Inno does things, but I can give a rough idea of what my NSIS script does.

NSIS has 'ini' editing tools, which are quite useful here, you just treat the .cfg file as a .ini file, but as you've discovered it varies a bit from a normal ini file in that the area/layer numbers need to be incremented. To do this, I use NSIS's normal file reading, which just reads a single line, then I use a script to figure out if it is a layer or area.

Once I know the highest layer and area numbers, I can then use the ini instructions to check to see if the scenery already exists, and if not add the new entry.

Here's a description of one of the ini instructions from the manual:

4.9.2.10 ReadINIStr
user_var(output) ini_filename section_name entry_name
Reads from entry_name in [section_name] of ini_filename and stores the value into user variable $x. The error flag will be set and $x will be assigned to an empty string if the entry is not found.

ReadINIStr $0 $INSTDIR\winamp.ini winamp outname

If it helps, here's the first part of my script which determines the highest area and layer numbers:

Code:
 FileOpen $SceneryCfgFile "$APPDATA\Microsoft\FSX\Scenery.CFG" "r"
  ${If} ${Errors}
        Messagebox MB_ICONEXCLAMATION "Could not open $APPDATA\Microsoft\FSX\Scenery.CFG, so unable to activate the scenery. Refer to the install manual for details."
  ${Else}

	StrCpy $AreaCount 0
	StrCpy $SceneryexistingArea 0
	StrCpy $SceneryLocalisOK 0
	StrCpy $AddtoAreaNumber 1
	StrCpy $NonFatalErrorFlag 0

	${Do} ; this loop runs through scenery.cfg to determine highest Area and Layer numbers
             FileRead $SceneryCfgFile $cfgline
             ${If} ${Errors}
                   ${ExitDo}
	     ${Else}
		StrCpy $AreaString $cfgline 6
		StrCmp $AreaString "[Area." 0 NotAnArea
		StrCpy $AreaNumber $cfgline 3 6
	        ${If} $AreaNumber > $AreaCount
	             StrCpy $AreaCount $AreaNumber
	        ${EndIf}

  	    ${EndIf}
NotAnArea:
          StrCmp $AreaString "Layer=" 0 NotLayerEither
          StrCpy $LayerNumber $cfgline 3 6
          ${If} $LayerNumber > $LayerCount
                StrCpy $LayerCount $LayerNumber
                ${EndIf}
        NotLayerEither:
	${Loop}

If Inno offers similar instructions, then you should be able to make a start.

I'm not a coder, I just stumble through the manuals looking for solutions, so don't judge my skills too harshly!
 
Hi Rob!

I'm not a coder, I just stumble through the manuals looking for solutions, so don't judge my skills too harshly!


Same here ;).

Your help is highly appreciated and it looks like Inno is quite similar to NSIS.
I’ll try to adapt your script to Inno and to my scenery.
I think it will be at the weekend and I keep reporting about my progress.

Thanks!
Carsten
 
Back
Top