language/plurals code help please

Freeform discussion about anything related to modding Transcendence.
Post Reply
relanat
Militia Captain
Militia Captain
Posts: 941
Joined: Tue Nov 05, 2013 9:56 am

The next version of the Commander's Log mod lists ships for sale at ship brokers.
The 'Ships' dockscreen is accessed by an action which has a varying action description underneath it.
One of the action descriptions is "This station has n ships for sale."
I am currently using this code for the action description:

Code: Select all

(scrSetActionDesc gScreen 'actionShips
	(scrTranslate gScreen "actionShips:ShipCount" {
		shipCount: (count (@ (logGetBroker) stationID))
		})
	)
...
<Text id="actionShips:ShipCount">This station has %shipCount% ships for sale.</Text>
%shipCount% is a number, 1 or more, never zero.
It works fine unless there is only one ship for sale. Then the description reads "...1 ships..." instead of "...1 ship...".
I know that the language code can handle plurals so that it shows either "1 ship" or "2 ships" but I don't know how to do it.
Does anyone know the appropriate code for something like this? TIA.
Stupid code. Do what I want, not what I typed in!
NMS
Militia Captain
Militia Captain
Posts: 569
Joined: Tue Mar 05, 2013 8:26 am

Have separate texts for singular and plural. The code that sets the description selects which one to translate.
User avatar
DigaRW
Militia Captain
Militia Captain
Posts: 517
Joined: Thu Jul 30, 2015 3:10 pm
Location: The place where I belong
Contact:

You might should take a look at RPGCommonText.xml. Some language uses plural text.

Code: Select all

<Text id="nounHitPoints">hit point(s)</Text>
<Text id="nounMilitaryID">military ID(s)</Text>
Try trace where this language is used.
Download Transcendence mods from Reinvented Workbench Project!
Click this link!
NMS
Militia Captain
Militia Captain
Posts: 569
Joined: Tue Mar 05, 2013 8:26 am

You could also do that and use (fmtNoun (typTranslate gType nounID) quantity flags), substituting that for a wildcard in the phrase. Flags can be 8 for "a ship"/ "2 ships" or 0x1000 for "1 ship"/ "2 ships".
relanat
Militia Captain
Militia Captain
Posts: 941
Joined: Tue Nov 05, 2013 9:56 am

Thank you both. I can make it work now. Searching for the two text IDs led me to fmtNoun. There are enough examples of this function to allow me to work out how to use it with a "ship(s)" text ID. Good stuff! :D
Stupid code. Do what I want, not what I typed in!
relanat
Militia Captain
Militia Captain
Posts: 941
Joined: Tue Nov 05, 2013 9:56 am

Code used:

Code: Select all

<Text id="nounShip">ship(s)</Text>

Code: Select all

(scrSetActionDesc gScreen 'actionShips
	(scrTranslate gScreen "actionShips:ShipCount" {
		ships: (fmtNoun (typTranslate &baD789CommandersLogBase; 'nounShip) (count (@ (logGetBroker) stationID)) 'countAlways)
		})
)

Code: Select all

<Text id="actionShips:ShipCount">This station has %ships% for sale.</Text>
(count (@ (logGetBroker) stationID)) returns the number of ships available at that station.

I searched 1.9b4 Transcendence_Source and George uses this in the new squadron code!
Stupid code. Do what I want, not what I typed in!
Post Reply