always pluralize currency name 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 screen description of the currency dockscreen in the Taipan GodShip mod has the line of text:

Code: Select all

(cat "Enter amount of " (scrGetData gScreen 'currency) " to add or subtract.\n"
where scrGetData 'currency is the list entry of the dockscreen which shows 'map'ped type names from typFind '$. Examples are credit, rin, yuan and euro.

See image.

It would be better if the currencies showed as plurals but just adding "s" to the text causes yuan and rin to show as yuans and rins. Ideally some way of referring to the EconomyType currency= code would be best but I don't know how to do this.

Code: Select all

currency=		"rin|rin"
fmtCurrency always shows a integer even if Nil or zero are used as the count.

Possibly fmtNoun could be used but I can't make it work because I'm guessing. eg (fmtNoun (scrGetData gScreen 'currency) Nil Nil 0x0002) pluralizes everything, as does 0x40000 and 0x40002.

Or using the type or type name may be necessary, instead of the text from the list entry.

Any one got any ideas? The code needs to return "credits", "rin", "yuan", "euros" and, addtionally, "RUs".

Whole dockscreen code;

Code: Select all

	<Dockscreen UNID="&dsD789GodCurrencyDockscreen;"
			name=			"Currency"
			type=			"customPicker"
			backgroundID=	"&rsPointJunoHero;"
			nestedScreen=	"true"
			>

		<List
			rowHeight="44"
			>
			(map (typFind '$) theCurrency (typGetProperty theCurrency 'name))
		</List>

		<Panes>
			<Default
				showCounter="true"
				>
				<OnPaneInit>
<!--
	<EconomyType UNID="&ecCreditEconomy;"
			id=				"credit" 
			currency=		"credit(s)"
			conversion=		"100"
			/>
	<EconomyType UNID="&ecRinEconomy;"
			id=				"rin" 
			currency=		"rin|rin"
			conversion=		"500"
			/>
	<EconomyType UNID="&ecYuanEconomy;"
			id=				"yuan" 
			currency=		"yuan|yuan"
			conversion=		"50"
			/>
	<EconomyType UNID="&ecEuroEconomy;"
			id=				"euro" 
			currency=		"euro|euros"
			conversion=		"150"
			/>
	<EconomyType UNID="&ecRUEconomy;"
			id=				"ru" 
			currency=		"RU|RUs"
			conversion=		"85000"
			>
-->
					(block Nil
						(scrSetData gScreen 'currency (scrGetListEntry gScreen))
						(setq currList (typFind '$))
						(setq listLength (count currList))

								;(fmtNoun name nameFlags count formatFlags) - string
						(scrSetDesc gScreen
							(cat "Enter amount of " (scrGetData gScreen 'currency) " to add or subtract.\n"
								(if (@ currList 0)
									(cat (typGetProperty (@ currList 0) 'name) ": " (fmtNumber 'integer (plyGetCredits gPlayer (@ currList 0))) "\n")
								)
								(if (@ currList 1)
									(cat (typGetProperty (@ currList 1) 'name) ": " (fmtNumber 'integer (plyGetCredits gPlayer (@ currList 1))) "\n")
								)
								(if (@ currList 2)
									(cat (typGetProperty (@ currList 2) 'name) ": " (fmtNumber 'integer (plyGetCredits gPlayer (@ currList 2))) "\n")
								)
								(if (@ currList 3)
									(cat (typGetProperty (@ currList 3) 'name) ": " (fmtNumber 'integer (plyGetCredits gPlayer (@ currList 3))) "\n")
								)
								(if (@ currList 4)
									(cat (typGetProperty (@ currList 4) 'name) ": " (fmtNumber 'integer (plyGetCredits gPlayer (@ currList 4))) "\n")
								)
							)
						)
					)
				</OnPaneInit>

				<Actions>
					<Action id="actionMillionCurrency">
						(block Nil
							(plyCredit gPlayer (scrGetData gScreen 'currency) 1000000)
							(scrShowPane gScreen "Default")
						)
					</Action>

					<Action id="actionZeroCurrency">
						(block Nil
							(plyCharge gPlayer (scrGetData gScreen 'currency) (plyGetCredits gPlayer (scrGetData gScreen 'currency)))
							(scrShowPane gScreen "Default")
						)
					</Action>

					<Action id="actionAddCurrency">
						(block Nil
							(plyCredit gPlayer (scrGetData gScreen 'currency) (scrGetCounter gScreen))
							(scrShowPane gScreen "Default")
						)
					</Action>

					<Action id="actionSubtractCurrency">
						(block Nil
							(plyCharge gPlayer (scrGetData gScreen 'currency) (scrGetCounter gScreen))
							(scrShowPane gScreen "Default")
						)
					</Action>

					<Action id="actionBack" cancel="1">
						(scrExitScreen gScreen)
					</Action>
				</Actions>
			</Default>
		</Panes>

		<Language>
			<Text id="descDefault">
			</Text>

			<Text id="actionMillionCurrency">Add 1 [M]illion</Text>
			<Text id="actionZeroCurrency">Set To [Z]ero</Text>
			<Text id="actionAddCurrency">[A]dd Currency Amount</Text>
			<Text id="actionSubtractCurrency">[S]ubtract Currency Amount</Text>
			<Text id="actionBack">[B]ack</Text>
		</Language>
	</Dockscreen>
Attachments
currency use.jpg
currency use.jpg (93.13 KiB) Viewed 1904 times
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

Solved!
I was trying to think of ways to remove the zero from the beginning of, eg, 0 credits.

Code: Select all

(fmtCurrency (scrGetData gScreen 'currency) 0)
--> 0 credits
or
--> 0 yuan
Thinking back to a hideous piece of code I wrote a while ago trying to extract a decimal UNID from a list entry I had a look at 'subset'.
Taking a subset from position '2', which is the third character, fortunately gives the desired result.
This was even easier than anticipated because 'fmtCurrency' returns a string.

Code: Select all

	(fmtCurrency currency [amount]) -> string

(subset (fmtCurrency (scrGetData gScreen 'currency) 0) 2)
--> credits
or
--> rin
EDIT: But the even easier way is to use:

Code: Select all

(fmtCurrency (scrGetData gScreen 'currency) True)
--> credits
or
--> rin
D'oh. Found while working on another mod!
Stupid code. Do what I want, not what I typed in!
Post Reply