undocumented formatCredits()

For test results, bug reports, announcements of new builds etc.

Moderators: winston, another_commander, Getafix

Post Reply
User avatar
Capt. Murphy
Commodore
Commodore
Posts: 1127
Joined: Fri Feb 25, 2011 8:46 am
Location: UK South Coast.

undocumented formatCredits()

Post by Capt. Murphy »

Hi, I think this method of the global object was introduced back with 1.75, but doesn't appear to have made it as far as the wiki.

Is the text below a correct description of syntax? If so I'll add it to the wiki...
function formatCredits(credits : Number [,deciCredits : Boolean][,currencySymbol : Boolean]) : String
Returns a string with the credit value. If deciCredits is true the number will be formatted to 1 decimal place. If currencySymbol is true the string will terminate with the ₢ symbol.
[EliteWiki] Capt. Murphy's OXPs
External JavaScript resources - W3Schools & Mozilla Developer Network
Win 7 64bit, Intel Core i5 with HD3000 (driver rev. 8.15.10.2696 - March 2012), Oolite 1.76.1
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: undocumented formatCredits()

Post by Eric Walch »

Capt. Murphy wrote:
Hi, I think this method of the global object was introduced back with 1.75, but doesn't appear to have made it as far as the wiki.

Is the text below a correct description of syntax? If so I'll add it to the wiki...
Looks ok to me (except for one bracket). It was announced in progress some time ago.
User avatar
Capt. Murphy
Commodore
Commodore
Posts: 1127
Joined: Fri Feb 25, 2011 8:46 am
Location: UK South Coast.

Re: undocumented formatCredits()

Post by Capt. Murphy »

Thanks,

I've added both formatCredits and formatInteger to the wiki using Ahruman's terminology for the syntax.

http://wiki.alioth.net/index.php/Oolite ... matCredits
[EliteWiki] Capt. Murphy's OXPs
External JavaScript resources - W3Schools & Mozilla Developer Network
Win 7 64bit, Intel Core i5 with HD3000 (driver rev. 8.15.10.2696 - March 2012), Oolite 1.76.1
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: undocumented formatCredits()

Post by Eric Walch »

Capt. Murphy wrote:
Thanks,

I've added both formatCredits and formatInteger to the wiki using Ahruman's terminology for the syntax.

http://wiki.alioth.net/index.php/Oolite ... matCredits
Actually the ₢ is not fixed but can be overwritten with an other currency symbol in a localised version. The symbol is stored in 'descriptions.plist' under the key '@-credits'. That is why using this method of adding the currency symbol is better than the hardcoded way. Having said that, I must admit, I always hardcoded the currency symbols in my oxps.

Same is true for format integer. Formats can be localised with: number-decimal-separator and number-group-separator

For the wiki it would be enough to mention that formatting follows the localisation rules.
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Re: undocumented formatCredits()

Post by JensAyton »

Eric Walch wrote:
Actually the ₢ is not fixed but can be overwritten with an other currency symbol in a localised version.
In fact, formatCredits() is in JS specifically so that it can be overridden to display credits in completely different ways, if necessary, for localization OXPs.
User avatar
Capt. Murphy
Commodore
Commodore
Posts: 1127
Joined: Fri Feb 25, 2011 8:46 am
Location: UK South Coast.

Re: undocumented formatCredits()

Post by Capt. Murphy »

Wiki entries updated in light of both your posts.. :)
[EliteWiki] Capt. Murphy's OXPs
External JavaScript resources - W3Schools & Mozilla Developer Network
Win 7 64bit, Intel Core i5 with HD3000 (driver rev. 8.15.10.2696 - March 2012), Oolite 1.76.1
Post Reply