I read that to mean that feeding this function something like "gemStones" would return something like "Gem-Stones", and assumed that offering it something like 1 would produce an error.displayNameForCommodity
function displayNameForCommodity(commodityName : String)
Returns the display name corresponding to the specified commodity. Useful in conjunction with localisation OXPs, or expansions that rename commodities depending on which station / system the player is at.
How do I make this work?> displayNameForCommodity(furs);
Exception: ReferenceError: furs is not defined
Active script: oolite-debug-console 1.76
oolite-debug-console.js, line 839:
}
> displayNameForCommodity("furs");
Furs
> displayNameForCommodity("gemStones");
gemStones
> displayNameForCommodity("gem-stones");
Gem-Stones
> displayNameForCommodity("Gem-Stones");
Gem-Stones
> displayNameForCommodity("1");
1
> displayNameForCommodity(2 + 2);
4
Addendum: I'm trying to use this function like this:-
Code: Select all
this.$previousGain = function(commodityName, gain)
{
var cargo = displayNameForCommodity(commodityName);
player.consoleMessage("The last time we traded " + cargo + " we gained " + gain + " credits.",7)
}
Code: Select all
this.cargoType = ["food", "textiles", "radioactives", "slaves", "liquorWines", "luxuries", "narcotics", "computers", "machinery", "alloys", "firearms", "furs", "minerals", "gold", "platinum", "gemStones", "alienItems"];