It stays consitant and does not save anything to your save file as the OXP works by reading the systemID of the system you are currently in. This is the same for all players and on all versions of the game. In code only the system you are actually in at the moment exists. When you load the game or make a hyperspace jump the OXP checks to see what stations, planets, moons and asteroids are present in your personal game. It then names them using the name in that object's array in the OXP's script file correstponding to the system number you are at.
Lave for example is System 7. So if a black monk station (as an example) was present at Lave, then for all players of the game it will be named with the name from position 7 in the array for Black Monk Stations (monkpool in the script). If a second black monk station was present at Lave then it is named with the name from position 8 in the array. And so on. Because the system ID is the same each time you vist a particular system, any stations present always have the same name both for you and for all players. Naturally if you do not have a particular OXP installed then that particular station, moon or planet it would have added doesn't exist in your game and so isn;t named. If you later install it then it would be. If you remove it then it will go back to not existing and so wouldn't be named in your game.
The code to do it is faily straightforward. On start up it counts the number of each type of object the OXP names and then assignes them names based on their position in the array. Omce it has does that the code goes to sleep until you make another jump or load a new game as the code only needs to do anything when the system is being populated. So under this.Ship.Spawned the code checks like this:-
Code: Select all
// Name Black Monk Stations.
if(ship.hasRole("blackmonk_monastery")) {
missionVariables.random_station_names_local_monk_count ++;
if (missionVariables.random_station_names_local_monk_count ===1) ship.displayName = ship.displayName+": "+monkpool[system.ID&255]; // Name the Station.
if (missionVariables.random_station_names_local_monk_count ===1) ship.beaconLabel = "Monastery: "+monkpool[system.ID&255]; // Add Station Name to the ASC display.
// As the first station is named by its system ID, we want the next to be named by the next name in the array. So take off 1 from System ID so the next name is always SystemID+ number of extra stations.
var monkGrid = Math.floor(system.ID-1+missionVariables.random_station_names_local_monk_count);
if (missionVariables.random_station_names_local_monk_count > 1 )ship.displayName = ship.displayName+": "+monkpool[monkGrid&255];// If more than one is unexpectedly present name from the next name in the pool.
if (missionVariables.random_station_names_local_monk_count > 1) ship.beaconLabel = "Monastery: "+monkpool[monkGrid&255]; // Add Station Name to the ASC display.
}
The OXP is just adding text to the display names of the stations / stars / moons / planets / gas giants which Oolite is loading anyway on start up to populate the system you are in based on your personal install of OXPs. For example if you have the Lave OXP installed, it will add a moon and a SIRIF station to Lave. For all players the name at position 7 in the SIRIF array is "Status Quo". If your game adds a SIRIF at Lave then it will always be called "Status Quo". No names need to be saved as the adding is done on start up and is consitant due to the systemID for any system always being consitant.
Once the OXP has done it's count on loading or jumping, the temporay counting variable isn't needed anymore and I tidy up by deleting them all.
The arrays for the diffent types of Object are stored in the script file like this:-
Code: Select all
this.monkpool = ["Clerical Mace", "Tome of Debt", "Debtor's Rosary", "Joy of Debt" "and so on with how ever many names you want to put in the pool"]
Some names I hand wrote and some are generated procedurally in the same way Random Ship Names does. However I have to roll off my names in advance so the stay the same, where as Random Ship Names can do its dice rolls on the fly (as you want the names of ships to change but you don't want the names of stations to change). The OXP contains code to generate the names. So to whip up a batch of 256 names for a station you would like to name, you set the word lists in the Descriptions file like this:-
Code: Select all
"named_stations_custom_template" =
(
"[named_stations_list_of_people_names] [named_stations_ending_list1],
);
The descriptions file is just a massive list of words lists you can combine.
When you fire up Oolite it will drop 256 names into your latest log like this:-
Code: Select all
The Galactic Almanac OXP has generated the following array: "Port Bleriot", "Dornier Bay", "Lankester Spaceport", "and so on with 256 names"
Copy that into your script file and give it an unique name:-
Code: Select all
this myspecialnameslist = ["Port Bleriot", "Dornier Bay", "Lankester Spaceport", "and so on with 256 names"]
In the same way as you would with Random Ship Names, tell the OXP you want your station to be named by adding a script line in your shipdata entry.
Code: Select all
"script_info" = {
"randomstationnames" = "myspecialnameslist";
};
If you don't want to roll off your own names then you can set the sctipt info to plain / poetic / military etc and your station will be given a persitant name in the style you selected in the same way Random Ship Names does if you specify a particular style the OXP contains.
For V1 of the OXP I have pre-rolled 80 pools of names which are assigned to the existing stations currently released, to give the OXP backward comptability. Each of the existing stations therefore has its own style of names. The OXP also looks at the type of system you are in, so stations in Anarchies have more aggressive names, Fedual systems often have names referencing Castles, Commie systems have worlds named after famous soviet leaders and their stations have a commie theam (and so on with the differnt types of inhabitants, govenments and the description of the system given on the F7 screen). Again this is consitant for all players as the OXP is reading the planetinfor for the system which is the same for all players. If another OXP changes a system, then the code reads the changes made by the other OXP. So if someone released an OXP which changed Lave to a commie system, the stations and worlds would be named approprately and would be the same for all players with that OXP installed.
For Stars, planets, gas giants or moons released after the OXP is released then it will name the object with whatever name the author gave it in planetinfo when adding the object. If no name was specified (so it would otherwise appear as Undefined) then Random Station Names will assine it a persitant name automatically from its own pools of 40,000 names for planets and moons and 2,048 for Stars (as they can only be one star per system). Main Planets are named by the name of the system. So Lave will be named Lave I (Capital Planet). If another OXP changes the name of Lave to My Special Name, the it will be named "My Special Name I (Capital Planet)".
For Stations, if you don't tell Random Station Names to name your station then the OXP will assume that you do not wish it to be named as you are giving it your own name or it is a unique station. If you want Random Station Names to name it, then just add the key in shipdata for the style you want your station to be named in and the OXP will assign it a persitant name fom the style you chose either from a custom list in your OXP (if you told it to use your custom list in script info) or if you specify it or a style list from Random Station Names, then a persistant name will be assigned to all your stations in the style you chose in script info.