Config/script.js |
"use strict";
this.name = "Stars";
this.version = "0.5.1";
/* ====================================================================================
SPECTROSCOPE
Converts values set in planetinfo.plist and found in system.info.sun_color
into descriptive text strings. These are not computed values, so...
Setting sun_color = "1.0 0.0 0.0" in planetinfo.plist returns null, even though
it creates the same colour star in the game as setting sun_color = "redColor".
======================================================================================= */
this.$spectroscope = function(colour)
{
if (!colour) colour = system.info.sun_color;
if (!colour) return false;
switch (colour)
{
case "magentaColor":
case "redColor": colour = "class M star"; break;
case "orangeColor": colour = "class K star"; break;
case "yellowColor": colour = "class G star"; break;
case "whiteColor": colour = "class F star"; break;
case "cyanColor": colour = "class A star"; break;
case "blueColor": colour = "class B star"; break;
default: colour = null;
}
return colour;
}
/* ====================================================================================
EXAMPLE USE - ADD LINE TO SYSTEM DATA SCREEN
======================================================================================= */
this.guiScreenChanged = function()
{
if (guiScreen === "GUI_SCREEN_SYSTEM_DATA")
{
var info = System.infoForSystem(galaxyNumber, player.ship.targetSystem);
if (info.sun_gone_nova) return;
var name = info.name;
var sunName = info.sun_name;
var colour = info.sun_color;
if (colour) var colourText = this.$spectroscope(colour);
if (colourText && sunName) mission.addMessageText("The planet " + name + " orbits the " + colourText + " " + sunName + ".");
else if (colourText) mission.addMessageText("The planet " + name + " orbits a " + colourText + ".");
else if (sunName) mission.addMessageText("The planet " + name + " orbits the star " + sunName + ".");
}
}
/* ====================================================================================
THE END
======================================================================================= */
|