Advanced custom flags
Please have read and completed the first steps on custom flags in the post above.
in the previous post we installed the database writer and database editor plugins to allow us to choose custom silhouettes and flags on a plane by plane basis. As useful and cool as that is, there is more that we can do. This post goes into two methods to connect various aircraft to custom flags and silhouettes, one automatic and one semi-manual but still better than one-plane-at-a-time. There may be further tutorials in the future, but let's get this done.
Fully automatic linking
in the operator code field, then his program links in a custom operator flag based on several options:
- If there is a file in the flags folder with the tail number of the plane, then that is displayed as the flag. For example: if you see N486RW the flag will show you a red CocaCola flag.
- If there's no file matching the tail number, it looks for a file with the same name as the manufacturer of the plane, so a Falcon 900B gets a pretty Dassault flag while a G550 gets a Gulfstream flag and a Legacy 600 has a blue Embraer flag.
It's really nice. Complete instructions, and all the files can be found at my Github repository
or at Andre's Github repository
Batch database updating - but still manual...
Let's pretend that you live, like I do, in eastern Kansas near four airforce bases that have US Air Force KC135 tankers of various versions flying in and out of them (Omaha, Topeka, Wichita and Tulsa), and you have either created yourself, or asked someone on radarspotting to create for you a custom silhouette for the KC135 with tail colors indicating if it is a Kansas Coyote US Air National Guard plane flying out of Topeka or an multi-role tanker, electronic surveilance plane flying out of Omaha, or, or or and you have not three or four but DOZENS of planes that need to have their model code changed to a custom string like oh, I don't know, KSANG-KC135 or something.
You COULD go in with the database editor one-by-one and update them, or you could take advantage of the fact that the Basestation.sqb file is a SQLite ( SQL -lite ) file and can be updated, modified, and etc using the SQLite program. SQLite is the most used database engine in the world and the SQLite file format is stable, cross-platform, and backwards compatible and the developers pledge to keep it that way through at least the year 2050.
MAKE A BACKUP OF Basestation.sqb before doing anything to it. If you don't and you mess it up, it's not my fault. I will laugh.
Go to the SQLite home page and download the latest version of the Windows PreCompiled Binary Tools package. The file name starts: sqlite-tools-win32
. Unzip it, and copy the three exe files into the folder your Basestation.sqb file is in.
Now, make a backup copy of Basestation.sql.
Now. Copy it somewhere safe, or I swear
I will laugh when you complain that you destroyed your file.
Open a command window. Yes, SQLite is a command line tool and you'll have to type nasty, horrible SQL commands.
Change directories to the folder where your Basestation.sqb file is. You'll type something like cd \VirtualRadar\
or something like that.
Type SQLite3 Basestation.sqb
that wil run the SQLite program and present you with a prompt having opened your database.
and enter and you'll see a list of the tables in the database. There are a lot of cool programmer-y things you can do with this, but for now, we're interested in the table called "Aircraft".
It has the following fields: AircraftID|FirstCreated|LastModified|ModeS|ModeSCountry|Country|Registration|CurrentRegDate|PreviousID|FirstRegDate|Status|DeRegDate|Manufacturer|ICAOTypeCode|Type|SerialNo|PopularName|GenericName|AircraftClass|Engines|OwnershipStatus|RegisteredOwners|MTOW|TotalHours|YearBuilt|CofACategory|CofAExpiry|UserNotes|Interested|UserTag|InfoURL|PictureURL1|PictureURL2|PictureURL3|UserBool1|UserBool2|UserBool3|UserBool4|UserBool5|UserString1|UserString2|UserString3|UserString4|UserString5|UserInt1|UserInt2|UserInt3|UserInt4|UserInt5|OperatorFlagCode
We're going to ignore most of them, but I hope you can see some opportunities, especially the unused-by-VRS "user" fields...
Now, I'm not going to teach you SQL. If you've never used it, go find any of the excellent SQL tutorials out there. In my case, I have a problem. All the variations of the KC-135 use the same ICAO model code ( K35R ) and I would very much like to have different silhouettes for KC-135R
and U and also RC-135's in their varients and so forth. Oddly, the type NAME distinguishes them, but the ICAO type code doesn't. So, I'm going to type in several commands. Note that each one that doesn't start with a . (dot) ends in a semi-colon and that each is followed by hitting enter.
--- that turns on column headers.
Select * from Aircraft where Type like '%KC135T%;
-- this prints out a list of all the rows where the string "KC135T" is contained in the "Type" field so that I can check that these are the ones I want. And, indeed they are. They all have an ICAOTypeCode of K35R -- which is just wrong. Now, on to doing an update. Did I mention you should have made a backup?
Update Aircraft set ICAOTypeCode = 'KC135T' where Type like '%KC135T%';
-- if you've ever done any work with databases at all, that line should be self explanitory. If not, go find a copy of SQL for Dummys.
Hopefully you can see how you can do all sorts of cool things updating the various fields with values based on stuff in the Type or Callsign or Operator fields.
Have fun, but stay safe.