[MOD] Format Thousands - formats money and amounts in thousands v0.05 (14th Dec 2015)
Moderators: Scripting / Modding Moderators, Moderators for English X Forum
-
- Posts: 296
- Joined: Tue, 3. Jan 06, 23:31
[MOD] Format Thousands - formats money and amounts in thousands v0.05 (14th Dec 2015)
14th December 2015
I have just uploaded version 0.05 to the Nexus mod site and Steam.
Version 0.05 provides a different work around for a patching problem that took out cargo collection.
Also now uses silent="true" on patch commands that are meant to fail in X Rebirth 4 which reduces the debug.log messages by 23
Apart from these two changes in the patch loading mechanism v0.05 is the same as v0.03
Now formats $AMOUNT$ in thousands for all ai scripts
Version 0.03 introduces support for X Rebirth 4.00 beta 2 as well as X Rebirth 3.61
It will skip any thousands formatting that Egosoft have already done for Money and Price in 4.00 beta 2
www.nexusmods.com/xrebirth/mods/461/
http://steamcommunity.com/sharedfiles/f ... =542981251
Contents
Was that fifty four thousand ? five thousand ? or five hundred thousand ? that just popped up on the screen. Its difficult to tell in the few seconds that it was there. Why not get it formatted properly and get a decent idea of the size ?
Converts 54287 into 54,287 or 54 287 or 54.287 depending on viewing language
This mod patches multiple Egosoft files to change the money and amount messages in the logbook and the event monitor
For X Rebirth - 3.61 and 4.00 beta 2
Now formats $AMOUNT$ in thousands for all ai scripts
The event monitor messages can come from either md or ai scripts
ai move.refuel.xml - Transferring funds for refueling
The logbook entries can come from either md or ai scripts
ai move.refuel.xml - Transferred $MONEY$ Cr to $ENTITY$ to buy $AMOUNT$ Fuel Cells.\nLocation: $SHIP$ in sector $SECTOR$ - tested
ai trade.performplayertraderun - Arrived at destination but cannot buy $AMOUNT$ units of $WARE$
ai trade.performplayertraderun - Arrived at destination but cannot sell $AMOUNT$ units of $WARE$
ai trade.performplayertraderun - $AMOUNT$ $WARE$ were lost in this transaction
ai trade.performplayertraderun - Bought $AMOUNT$ $WARE$ for $PRICE$ Cr - tested
ai trade.performplayertraderun - Sold $AMOUNT$ $WARE$ for $PRICE$ Cr - tested
Formatting fixes
ai move.refuel.xml - Logbook - removed extra "Cr" from "Transferred $MONEY$ Cr Cr to $ENTITY$ ..."
For X Rebirth 3.61 it will also
Patches multiple Egosoft files to change the $MONEY$ and $PRICE$ messages
The money messages are primarily in the logbook and the event monitor but there is one in a mission briefing too
The event monitor messages can come from either md or ai scripts
md Notifications.xml - Account updated - Debit withdrawal:
md Notifications.xml - Account updated - Payment received:
ai move.refuel.xml - Transferring funds for refueling
ai trade.performplayertraderun - Bought $AMOUNT$ $WARE$ for $PRICE$ Cr
ai trade.performplayertraderun - Sold $AMOUNT$ $WARE$ for $PRICE$ Cr
The logbook entries can come from either md or ai scripts
md Notifications - Received surplus of $MONEY$ Credits from $TRADER$.
ai move.refuel.xml - Transferred $MONEY$ Cr to $ENTITY$ to buy $AMOUNT$ Fuel Cells.\nLocation: $SHIP$ in sector $SECTOR$
ai player.interaction.budget - The account of $STATION$ in $ZONE$ has dropped to $MONEY$ Credits.
ai player.interaction.budget - $STATION$ in $ZONE$ has had $AMOUNT$ transfered to its account. New balance is $MONEY$.
ai trade.performplayertraderun - Bought $AMOUNT$ $WARE$ for $PRICE$ Cr
ai trade.performplayertraderun - Sold $AMOUNT$ $WARE$ for $PRICE$ Cr
Formatting fixes
ai move.refuel.xml - Logbook - removed extra "Cr" from "Transferred $MONEY$ Cr Cr to $ENTITY$ ..."
Mission briefing
md RML_Transfer_Money - Transfer $MONEY$ credits to $NPC$ - not tested but the fix is in there and is patching without error messages
Provides a library and aiscript that formats amounts in thousands separated by commas
Regards
jth
PS Before I do that, does anything else do this or is there anything that I might upset by doing it ?
I have just uploaded version 0.05 to the Nexus mod site and Steam.
Version 0.05 provides a different work around for a patching problem that took out cargo collection.
Also now uses silent="true" on patch commands that are meant to fail in X Rebirth 4 which reduces the debug.log messages by 23
Apart from these two changes in the patch loading mechanism v0.05 is the same as v0.03
Now formats $AMOUNT$ in thousands for all ai scripts
Version 0.03 introduces support for X Rebirth 4.00 beta 2 as well as X Rebirth 3.61
It will skip any thousands formatting that Egosoft have already done for Money and Price in 4.00 beta 2
www.nexusmods.com/xrebirth/mods/461/
http://steamcommunity.com/sharedfiles/f ... =542981251
Contents
Was that fifty four thousand ? five thousand ? or five hundred thousand ? that just popped up on the screen. Its difficult to tell in the few seconds that it was there. Why not get it formatted properly and get a decent idea of the size ?
Converts 54287 into 54,287 or 54 287 or 54.287 depending on viewing language
This mod patches multiple Egosoft files to change the money and amount messages in the logbook and the event monitor
For X Rebirth - 3.61 and 4.00 beta 2
Now formats $AMOUNT$ in thousands for all ai scripts
The event monitor messages can come from either md or ai scripts
ai move.refuel.xml - Transferring funds for refueling
The logbook entries can come from either md or ai scripts
ai move.refuel.xml - Transferred $MONEY$ Cr to $ENTITY$ to buy $AMOUNT$ Fuel Cells.\nLocation: $SHIP$ in sector $SECTOR$ - tested
ai trade.performplayertraderun - Arrived at destination but cannot buy $AMOUNT$ units of $WARE$
ai trade.performplayertraderun - Arrived at destination but cannot sell $AMOUNT$ units of $WARE$
ai trade.performplayertraderun - $AMOUNT$ $WARE$ were lost in this transaction
ai trade.performplayertraderun - Bought $AMOUNT$ $WARE$ for $PRICE$ Cr - tested
ai trade.performplayertraderun - Sold $AMOUNT$ $WARE$ for $PRICE$ Cr - tested
Formatting fixes
ai move.refuel.xml - Logbook - removed extra "Cr" from "Transferred $MONEY$ Cr Cr to $ENTITY$ ..."
For X Rebirth 3.61 it will also
Patches multiple Egosoft files to change the $MONEY$ and $PRICE$ messages
The money messages are primarily in the logbook and the event monitor but there is one in a mission briefing too
The event monitor messages can come from either md or ai scripts
md Notifications.xml - Account updated - Debit withdrawal:
md Notifications.xml - Account updated - Payment received:
ai move.refuel.xml - Transferring funds for refueling
ai trade.performplayertraderun - Bought $AMOUNT$ $WARE$ for $PRICE$ Cr
ai trade.performplayertraderun - Sold $AMOUNT$ $WARE$ for $PRICE$ Cr
The logbook entries can come from either md or ai scripts
md Notifications - Received surplus of $MONEY$ Credits from $TRADER$.
ai move.refuel.xml - Transferred $MONEY$ Cr to $ENTITY$ to buy $AMOUNT$ Fuel Cells.\nLocation: $SHIP$ in sector $SECTOR$
ai player.interaction.budget - The account of $STATION$ in $ZONE$ has dropped to $MONEY$ Credits.
ai player.interaction.budget - $STATION$ in $ZONE$ has had $AMOUNT$ transfered to its account. New balance is $MONEY$.
ai trade.performplayertraderun - Bought $AMOUNT$ $WARE$ for $PRICE$ Cr
ai trade.performplayertraderun - Sold $AMOUNT$ $WARE$ for $PRICE$ Cr
Formatting fixes
ai move.refuel.xml - Logbook - removed extra "Cr" from "Transferred $MONEY$ Cr Cr to $ENTITY$ ..."
Mission briefing
md RML_Transfer_Money - Transfer $MONEY$ credits to $NPC$ - not tested but the fix is in there and is patching without error messages
Provides a library and aiscript that formats amounts in thousands separated by commas
Regards
jth
PS Before I do that, does anything else do this or is there anything that I might upset by doing it ?
Last edited by jth on Mon, 21. Dec 15, 13:33, edited 16 times in total.
-
- Posts: 2963
- Joined: Tue, 18. Nov 14, 16:23
Re: Logbook money formatting in thousands
Don't think so. Sounds useful.jth wrote:Before I do that, does anything else do this or is there anything that I might upset by doing it ?
-
- Posts: 1842
- Joined: Tue, 2. Nov 10, 02:20
That sounds like a great idea -- how did you end up going about the conversion? I really struggled for a way to do this in mdscript myself.
(In the Lua there's a function called ConvertIntegerString that takes care of it automatically. I did some experiments with trying to run it in Lua then export the result back to mdscript, but those turned out to be a lol-tastic mess.)
What I came up with for Human Resources was this:
It'll handle currency up into the quadrillions with 5 cycles on the do_all, but mostly it's designed to break the loop earlier than that.
You can see what the output looks like here after "Current Balance" -- this was a little spin-off mod I did that uses script identical to the code above except for the button label.
If there's a better way to do this sort of thing, I'd love to know.
(In the Lua there's a function called ConvertIntegerString that takes care of it automatically. I did some experiments with trying to run it in Lua then export the result back to mdscript, but those turned out to be a lol-tastic mess.)
What I came up with for Human Resources was this:
Code: Select all
<!-- we finally have commas! there's probably an easier way to do this but right now I don't care!-->
<set_value name="$raw_money" exact="player.money/1Cr" />
<do_all exact="5" counter="$i">
<do_if value="$raw_money ge 1000">
<set_value name="$top_money" exact="$raw_money/1000" />
<set_value name="$bottom_money" exact="$raw_money - ($top_money*1000)" />
<set_value name="$raw_money" exact="$top_money" />
<set_value name="$filler_zeros" exact="''" />
<do_if value="$bottom_money lt 100">
<set_value name="$filler_zeros" exact="'0'" />
<do_if value="$bottom_money lt 10">
<set_value name="$filler_zeros" exact="'00'" />
</do_if>
</do_if>
<do_if value="$temp_moneystring?" >
<set_value name="$temp_tempstring" exact="',%1%2%3'.[$filler_zeros, $bottom_money, $temp_moneystring]" />
<set_value name="$temp_moneystring" exact="$temp_tempstring" />
</do_if>
<do_else>
<set_value name="$temp_moneystring" exact="',%1%2'.[$filler_zeros, $bottom_money]" />
</do_else>
</do_if>
<do_else>
<do_if value="$temp_moneystring?" >
<set_value name="$display_money" exact="'%1%2'.[$raw_money, $temp_moneystring]" />
<remove_value name="$temp_moneystring" />
<break />
</do_if>
<do_else>
<set_value name="$display_money" exact="'%1'.[$raw_money]" />
<break />
</do_else>
</do_else>
</do_all>
<add_player_choice_sub text="{643345,1158}.[$display_money]" section="gMainInfo_player" position="top_right" baseparam="event.param2" comment="player status" />
You can see what the output looks like here after "Current Balance" -- this was a little spin-off mod I did that uses script identical to the code above except for the button label.
If there's a better way to do this sort of thing, I'd love to know.
-
- Posts: 2774
- Joined: Tue, 29. Oct 13, 21:59
I think, but can't check on this tablet, that wysiwygs enhanced money transfer mod http://forum.egosoft.com/viewtopic.php?t=372630 does this for the output. Even if not it will likely be a good start point for demo lua.
X Rebirth - A Sirius Cybernetics Corporation Product
Split irritate visiting pilot with strange vocal patterns.
Split irritate visiting pilot with strange vocal patterns.
-
- Posts: 296
- Joined: Tue, 3. Jan 06, 23:31
There are two implementations one for use in md scripts and the other for ai scripts. I have found that the Egosoft ai scripts also write to the logbook and that a lot of it is not in Notifications.xmlVim Razz wrote:That sounds like a great idea -- how did you end up going about the conversion? I really struggled for a way to do this in mdscript myself.
(In the Lua there's a function called ConvertIntegerString that takes care of it automatically. I did some experiments with trying to run it in Lua then export the result back to mdscript, but those turned out to be a lol-tastic mess.)
What I came up with for Human Resources was this:It'll handle currency up into the quadrillions with 5 cycles on the do_all, but mostly it's designed to break the loop earlier than that.Code: Select all
<!-- we finally have commas! there's probably an easier way to do this but right now I don't care!--> <set_value name="$raw_money" exact="player.money/1Cr" /> <do_all exact="5" counter="$i"> <do_if value="$raw_money ge 1000"> <set_value name="$top_money" exact="$raw_money/1000" /> <set_value name="$bottom_money" exact="$raw_money - ($top_money*1000)" /> <set_value name="$raw_money" exact="$top_money" /> <set_value name="$filler_zeros" exact="''" /> <do_if value="$bottom_money lt 100"> <set_value name="$filler_zeros" exact="'0'" /> <do_if value="$bottom_money lt 10"> <set_value name="$filler_zeros" exact="'00'" /> </do_if> </do_if> <do_if value="$temp_moneystring?" > <set_value name="$temp_tempstring" exact="',%1%2%3'.[$filler_zeros, $bottom_money, $temp_moneystring]" /> <set_value name="$temp_moneystring" exact="$temp_tempstring" /> </do_if> <do_else> <set_value name="$temp_moneystring" exact="',%1%2'.[$filler_zeros, $bottom_money]" /> </do_else> </do_if> <do_else> <do_if value="$temp_moneystring?" > <set_value name="$display_money" exact="'%1%2'.[$raw_money, $temp_moneystring]" /> <remove_value name="$temp_moneystring" /> <break /> </do_if> <do_else> <set_value name="$display_money" exact="'%1'.[$raw_money]" /> <break /> </do_else> </do_else> </do_all> <add_player_choice_sub text="{643345,1158}.[$display_money]" section="gMainInfo_player" position="top_right" baseparam="event.param2" comment="player status" />
You can see what the output looks like here after "Current Balance" -- this was a little spin-off mod I did that uses script identical to the code above except for the button label.
If there's a better way to do this sort of thing, I'd love to know.
The algorithm is identical in both and they work up to 4 billion credits which is the maximum amount of money that the player can have. It does positive and negative numbers.
I am hoping to kind of open source this code if anyone else wants to use it. The idea is to patch the library into Notifications.xml from where it can be called by anyone and stick the ai script in the aiscripts folder where it can be called by anyone. I thought that I might distribute it as two diff files and allow other people to pop the diff file in with their own code. As opposed to making it a dependency. Thats why I was asking the diff question.
I will also be publishing a mod that uses the library and aiscript to reformat money amounts that appears in the logbook and notification screen. Initially this will not be everything as there is $MONEY$ and $AMOUNT$ in a lot of places. I am intending to release v0.01 to prove the concept and then catch up later with the mass of places in ai scripts that write to the debug log
Code: Select all
<library name="FormatThousands" version="1">
<actions>
<set_value name="$MoneyIn" exact="$Thousands"/>
<set_value name="$FThousands" exact="''"/>
<do_while value="($MoneyIn ge 1000) or ($MoneyIn le -1000)">
<set_value name="$Remainder" exact="$MoneyIn%1000"/>
<do_if value="$Remainder lt 0">
<set_value name="$Remainder" exact="-$Remainder"/>
</do_if>
<do_if value="$Remainder lt 10" comment="add leading zeros">
<set_value name="$FThousands" exact="',00' + $Remainder + $FThousands"/>
</do_if>
<do_elseif value="$Remainder lt 100" comment="add leading zero">
<set_value name="$FThousands" exact="',0' + $Remainder + $FThousands"/>
</do_elseif>
<do_else>
<set_value name="$FThousands" exact="',' + $Remainder + $FThousands"/>
</do_else>
<set_value name="$MoneyIn" exact="($MoneyIn/1000)i"/>
</do_while>
<set_value name="$FThousands" exact="$MoneyIn + $FThousands"/>
<remove_value name="$MoneyIn"/>
<debug_text text="'In ' + $Thousands + ' Out ' + $FThousands"/>
</actions>
</library>
Code: Select all
<set_value name="$Thousands" exact="-5553350"/>
<include_actions ref="FormatThousands"/>
and
Code: Select all
<?xml version="1.0" encoding="iso-8859-1" ?>
<aiscript name="format.thousands" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="aiscripts.xsd" priority="10">
<params>
<param name="Thousands"/>
</params>
<attention min="unknown">
<actions>
<set_value name="$MoneyIn" exact="$Thousands"/>
<set_value name="$FThousands" exact="''"/>
<do_while value="($MoneyIn ge 1000) or ($MoneyIn le -1000)">
<set_value name="$Remainder" exact="$MoneyIn%1000"/>
<do_if value="$Remainder lt 0">
<set_value name="$Remainder" exact="-$Remainder"/>
</do_if>
<do_if value="$Remainder lt 10" comment="add leading zeros">
<set_value name="$FThousands" exact="',00' + $Remainder + $FThousands"/>
</do_if>
<do_elseif value="$Remainder lt 100" comment="add leading zero">
<set_value name="$FThousands" exact="',0' + $Remainder + $FThousands"/>
</do_elseif>
<do_else>
<set_value name="$FThousands" exact="',' + $Remainder + $FThousands"/>
</do_else>
<set_value name="$MoneyIn" exact="($MoneyIn/1000)i"/>
</do_while>
<set_value name="$FThousands" exact="$MoneyIn + $FThousands"/>
<remove_value name="$MoneyIn"/>
<debug_text text="'In ' + $Thousands + ' Out ' + $FThousands"/>
<return value="$FThousands"/>
</actions>
</attention>
</aiscript>
Code: Select all
<run_script name="'format.thousands'" result="$Amount">
<param name="Thousands" value="$Amount / 1Cr" />
</run_script>
regards
jth
-
- Posts: 1842
- Joined: Tue, 2. Nov 10, 02:20
-
- Posts: 296
- Joined: Tue, 3. Jan 06, 23:31
It appears to work although its a bit of a pig to test. If you add a number greater than max 32 bit signed integer (2G) via set_value it wraps even if coerced to 64 bit signed integer. So the only way to really test it is to <reward_player money="1000000000"/> (1Bn Credits) several times which is how I found the max player creditsVim Razz wrote:Very nice!
For some reason I'd been under the impression that do_while was only valid in the aiscript environment. I'm feeling kind of derpy at the moment for not ever trying it out in mdscript to make sure.. >.< So it works ok,then?
jth
-
- Posts: 296
- Joined: Tue, 3. Jan 06, 23:31
27th October 2015 version 0.01
The initial release contains patches to multiple Egosoft files to change the money messages in the logbook and the event monitor
The money messages are primarily in the logbook and the event monitor but there is one in a mission too
The event monitor messages can come from either md or ai scripts
md Notifications.xml - Account updated - Debit withdrawal:
md Notifications.xml - Account updated - Payment received:
ai move.refuel.xml - Transferring funds for refueling
ai trade.performplayertraderun - Bought $AMOUNT$ $WARE$ for $PRICE$ Cr
ai trade.performplayertraderun - Sold $AMOUNT$ $WARE$ for $PRICE$ Cr
The logbook entries can come from either md or ai scripts
md Notifications - Received surplus of $MONEY$ Credits from $TRADER$.
ai move.refuel.xml - Transferred $MONEY$ Cr to $ENTITY$ to buy $AMOUNT$ Fuel Cells.\nLocation: $SHIP$ in sector $SECTOR$
ai player.interaction.budget - The account of $STATION$ in $ZONE$ has dropped to $MONEY$ Credits.-
ai player.interaction.budget - $STATION$ in $ZONE$ has had $AMOUNT$ transfered to its account. New balance is $MONEY$.
ai trade.performplayertraderun - Bought $AMOUNT$ $WARE$ for $PRICE$ Cr
ai trade.performplayertraderun - Sold $AMOUNT$ $WARE$ for $PRICE$ Cr
Formatting fixes
ai move.refuel.xml - Logbook - removed extra "Cr" from "Transferred $MONEY$ Cr Cr to $ENTITY$ ..."
Mission briefing
md RML_Transfer_Money - Transfer $MONEY$ credits to $NPC$ - not tested but the fix is in there and is patching without error messages
jth
The initial release contains patches to multiple Egosoft files to change the money messages in the logbook and the event monitor
The money messages are primarily in the logbook and the event monitor but there is one in a mission too
The event monitor messages can come from either md or ai scripts
md Notifications.xml - Account updated - Debit withdrawal:
md Notifications.xml - Account updated - Payment received:
ai move.refuel.xml - Transferring funds for refueling
ai trade.performplayertraderun - Bought $AMOUNT$ $WARE$ for $PRICE$ Cr
ai trade.performplayertraderun - Sold $AMOUNT$ $WARE$ for $PRICE$ Cr
The logbook entries can come from either md or ai scripts
md Notifications - Received surplus of $MONEY$ Credits from $TRADER$.
ai move.refuel.xml - Transferred $MONEY$ Cr to $ENTITY$ to buy $AMOUNT$ Fuel Cells.\nLocation: $SHIP$ in sector $SECTOR$
ai player.interaction.budget - The account of $STATION$ in $ZONE$ has dropped to $MONEY$ Credits.-
ai player.interaction.budget - $STATION$ in $ZONE$ has had $AMOUNT$ transfered to its account. New balance is $MONEY$.
ai trade.performplayertraderun - Bought $AMOUNT$ $WARE$ for $PRICE$ Cr
ai trade.performplayertraderun - Sold $AMOUNT$ $WARE$ for $PRICE$ Cr
Formatting fixes
ai move.refuel.xml - Logbook - removed extra "Cr" from "Transferred $MONEY$ Cr Cr to $ENTITY$ ..."
Mission briefing
md RML_Transfer_Money - Transfer $MONEY$ credits to $NPC$ - not tested but the fix is in there and is patching without error messages
jth
-
- Moderator (English)
- Posts: 8074
- Joined: Tue, 30. Mar 04, 12:28
Nice one! 
As an English-speaker, I think this is a great improvement.
Only thing that occurred to me was that some countries (France, Italy, maybe others) use a comma as a decimal point. Perhaps using a space instead could help them (e.g. "1 000 000"), although maybe they are familiar with seeing commas as thousand separators.

As an English-speaker, I think this is a great improvement.
Only thing that occurred to me was that some countries (France, Italy, maybe others) use a comma as a decimal point. Perhaps using a space instead could help them (e.g. "1 000 000"), although maybe they are familiar with seeing commas as thousand separators.
-
- Posts: 296
- Joined: Tue, 3. Jan 06, 23:31
Good point and a very interesting linkSparky Sparkycorp wrote:Nice one!
As an English-speaker, I think this is a great improvement.
Only thing that occurred to me was that some countries (France, Italy, maybe others) use a comma as a decimal point. Perhaps using a space instead could help them (e.g. "1 000 000"), although maybe they are familiar with seeing commas as thousand separators.
Here are a few thoughts off the top of my head
Format Thousands is for signed integers so I should be able to ignore decimal points which makes it easier

Looking at the http://www.statisticalconsultants.co.nz ... igits.html
It looks like I could cover everyone except Switzerland, China and India with either Style A: 10,000,000,000 or Style B: 10 000 000 000
The Swiss format is very similar to the UK with quotes instead of commas and there is no Egosoft translation (as they speak multiple languages depending on region) so I am going to assume that they can cope with either.
There is no Egosoft localisation for India and English is pretty common so I think that India would probably be OK with commas too.
I haven't attempted to do any translations into Chinese, Unified or otherwise so far, and nobody has come forward with any translations for me so I think that now is not the time to start
It looks like Europe is Style B and UK and North America are Style A
It might be possible to do it by detecting the country that the game is set to
So I could default Style A (commas) except when detecting French, German, Spanish and Italian where I would need to switch to spaces
The $64,000 dollar question is how many people think that this is important .........
EDIT
Just started to check API calls then found that Egosoft have a (thousands separator), {1001,106} in the multi lingual support
Looks like I should just use it and let Egosoft do the work

jth
-
- Posts: 296
- Joined: Tue, 3. Jan 06, 23:31
-
- Moderator (English)
- Posts: 8074
- Joined: Tue, 30. Mar 04, 12:28
Hi jth,
It looks like you've inspired Egosoft, or at the least there's been a funny coincidence.
In the new beta, there are thousands separators in Event Monitor messages and the Logbook
Not documented in the draft notes but it's one of several such changes:
https://www.egosoft.com:8444/confluence ... atch+notes
Regards,
Sparks
It looks like you've inspired Egosoft, or at the least there's been a funny coincidence.
In the new beta, there are thousands separators in Event Monitor messages and the Logbook

Not documented in the draft notes but it's one of several such changes:
https://www.egosoft.com:8444/confluence ... atch+notes
Regards,
Sparks
-
- Posts: 296
- Joined: Tue, 3. Jan 06, 23:31
Thanks for warning meSparky Sparkycorp wrote:Hi jth,
It looks like you've inspired Egosoft, or at the least there's been a funny coincidence.
In the new beta, there are thousands separators in Event Monitor messages and the Logbook
Not documented in the draft notes but it's one of several such changes:
http://www.egosoft.com:8292/confluence/ ... atch+notes
Regards,
Sparks
I have just spotted it too, interesting timing
I am guessing that they are trying to publish before Christmas but exactly when is probably top secret
Would have been nice to be warned


The subscriptions for the mod have been pretty good over the last few days which is nice. So at least I am pinching some of the glory

Still working out if they got everything that I did. So far its 1 : 0 to them as they got the crate message in Notifications that I missed. My excuse is that it didn't have $MONEY$ in it.
They don't seem to have formatted the amount in Bought $AMOUNT$ $WARE$ for $PRICE$ Cr and thats in my todo list
It might be worth a message in the beta forum to see if they will tell me if they are intending to format $AMOUNT$ for 4.00 or not
So there may still be a need for this mod. At least I called it format thousands not format money

So far the existing version might still work, it will just throw away Egosoft's new formatting and replace it with mine and it should look identical. I will be testing this

Alternatively I will need to issue another version simply to turn off the formatting changes if they are not needed. I can do this line by line or with max ver if version 4 totally supercedes this mod.
For the moment I am going through the files and making the diff matching tighter so that it will only patch old style lines. That should allow people to roll over to 4.00 smoothly. It also lets me see if they got everything that I found.
One file down five to go ...
I will post a message when I know where this is going
Regards
jth
-
- Posts: 486
- Joined: Thu, 22. Aug 13, 17:12
-
- Posts: 296
- Joined: Tue, 3. Jan 06, 23:31
I have now been through all the files and Egosoft appear to have altered the MONEY formatting in the same places as I have plus that one crate message. Their formatting is the same as mine or vice versa.
Egosoft do not appear to have formatted any of the $AMOUNT$
I have updated the diff files so that they will only patch if they see the old style formatting. That should allow it to be run on either 3.61 or 4.00 beta 2. The new version should be 0.03 when I release it
I have added in some additional features too
Now formats $AMOUNT$ for all ai scripts which should take care of the player log
The event monitor messages can come from either md or ai scripts
ai move.refuel.xml - Transferring funds for refueling
The logbook entries can come from either md or ai scripts
ai move.refuel.xml - Transferred $MONEY$ Cr to $ENTITY$ to buy $AMOUNT$ Fuel Cells.\nLocation: $SHIP$ in sector $SECTOR$ - tested
ai trade.performplayertraderun - Arrived at destination but cannot buy $AMOUNT$ units of $WARE$
ai trade.performplayertraderun - Arrived at destination but cannot sell $AMOUNT$ units of $WARE$
ai trade.performplayertraderun - $AMOUNT$ $WARE$ were lost in this transaction
ai trade.performplayertraderun - Bought $AMOUNT$ $WARE$ for $PRICE$ Cr - tested
ai trade.performplayertraderun - Sold $AMOUNT$ $WARE$ for $PRICE$ Cr - tested
Formatting fixes
ai move.refuel.xml - Logbook - removed extra "Cr" from "Transferred $MONEY$ Cr Cr to $ENTITY$ ..." I have changed how I do this so that it will work on 3.61 and 4.00 beta 2 as its needed for both.
Format Thousands v0.03 seems to be fine on 3.61 but needs some testing on 4.00 beta 2
Unfortunately it takes quite a while to exercise the logic and try out all the messages
There are a load of mission md scripts that also need the $AMOUNT$ done but I am saving those for later
jth
Egosoft do not appear to have formatted any of the $AMOUNT$
I have updated the diff files so that they will only patch if they see the old style formatting. That should allow it to be run on either 3.61 or 4.00 beta 2. The new version should be 0.03 when I release it
I have added in some additional features too

Now formats $AMOUNT$ for all ai scripts which should take care of the player log
The event monitor messages can come from either md or ai scripts
ai move.refuel.xml - Transferring funds for refueling
The logbook entries can come from either md or ai scripts
ai move.refuel.xml - Transferred $MONEY$ Cr to $ENTITY$ to buy $AMOUNT$ Fuel Cells.\nLocation: $SHIP$ in sector $SECTOR$ - tested
ai trade.performplayertraderun - Arrived at destination but cannot buy $AMOUNT$ units of $WARE$
ai trade.performplayertraderun - Arrived at destination but cannot sell $AMOUNT$ units of $WARE$
ai trade.performplayertraderun - $AMOUNT$ $WARE$ were lost in this transaction
ai trade.performplayertraderun - Bought $AMOUNT$ $WARE$ for $PRICE$ Cr - tested
ai trade.performplayertraderun - Sold $AMOUNT$ $WARE$ for $PRICE$ Cr - tested
Formatting fixes
ai move.refuel.xml - Logbook - removed extra "Cr" from "Transferred $MONEY$ Cr Cr to $ENTITY$ ..." I have changed how I do this so that it will work on 3.61 and 4.00 beta 2 as its needed for both.
Format Thousands v0.03 seems to be fine on 3.61 but needs some testing on 4.00 beta 2
Unfortunately it takes quite a while to exercise the logic and try out all the messages

There are a load of mission md scripts that also need the $AMOUNT$ done but I am saving those for later
jth
-
- Posts: 296
- Joined: Tue, 3. Jan 06, 23:31
[11.11.2015 - V0.03 Public Beta]
Now formats $AMOUNT$ for all ai scripts which should cover all player log entries
Supports X Rebirth 3.61 and 4.00 beta 2
Added comments in diff files to select statement XPath to identify what each diff element does. This helps to spot patching errors across multiple versions of X Rebirth
jth
Now formats $AMOUNT$ for all ai scripts which should cover all player log entries
Supports X Rebirth 3.61 and 4.00 beta 2
Added comments in diff files to select statement XPath to identify what each diff element does. This helps to spot patching errors across multiple versions of X Rebirth
jth
-
- Posts: 296
- Joined: Tue, 3. Jan 06, 23:31
Re: Logbook money formatting in thousands
Hi reddog0000reddog0000 on Steam wrote:Nice, I asked for this years ago ....
Could you add a 'setup' option to use standard multipes instead of all those damn numbers?
For instance : k M G
Current number Option k Option M Option G
912345678 912,345 k 912 M 0.912 G
Now that would much better !
I will think about it.
At the moment I am waiting for Egosoft to publish XRebirth 4.00 which has the same number formatting that is currently in this mod. I am not sure whether the amount formatting will suddenly appear too (it isn't in 4.00 beta 2). At which point the number of people still wanting to use this mod will have a rather large effect on its priority for extra features. If you look at the Steam usage graphs for this mod you can see when 4.00 was released

My current recommendation for users is to keep on using this mod until Egosoft release 4.00 wait a bit and then make a decision. That will make the game easier to use in the meantime and get the formatting into the player log. There is no retrospective reformatting of the player log, it is text and its formatted as its written.
The move.refuel logbook formatting fix has been reported and I don't think that it will be there much longer.
XRebirth 4.00 now has API support for a lot of printing options including k, M and G. I had to write my own formatting routine to get this mod working with 3.61 That makes it particularly messy during the transition from 3.61 to 4.00 as I have to maintain the old method for 3.61, the old method during transition to 4.00 and then potentially rewrite it later using the new 4.00 formatting commands.
I have isssued the version that will work on 3.61 and 4.00 using my formatting routine (where needed) and I was going to wait 3 months or so after the release of 4.00 to see whether there was still a need for this mod before doing the native 4.00 version
I hadn't considered alternate number formatting so thanks for the idea

The problem that I now have is knowing how many other people would like to see the extra formatting options ....
jth
PS I may well issue one more release to use the new XML patching silent="true" option to avoid spamming the debug log file when running 4.00 with the transition patch. Where it skips all number formatting for 4.00 as its already been done by Egosoft, producing over a dozen un-necessary messages.
-
- Posts: 452
- Joined: Mon, 7. May 07, 05:17
Hi mate,
I have not yet tested this great mod, but i already have a question
...
talking about mods and its messages here and there. For example using the show_help, show_notification or write_to_logbook to write a message with money/numbers. Will this mod works too? Or i need to use that special variables on the code (messages) to it work? (like $MONEY$, $AMOUNT$, $PRICE$, etc)
Thanks in any advice!
I have not yet tested this great mod, but i already have a question

talking about mods and its messages here and there. For example using the show_help, show_notification or write_to_logbook to write a message with money/numbers. Will this mod works too? Or i need to use that special variables on the code (messages) to it work? (like $MONEY$, $AMOUNT$, $PRICE$, etc)
Thanks in any advice!
-
- Posts: 296
- Joined: Tue, 3. Jan 06, 23:31
Lets treat this as a multi lingual and general string formatting tutorial.Rubini wrote:Hi mate,
I have not yet tested this great mod, but i already have a question
...
talking about mods and its messages here and there. For example using the show_help, show_notification or write_to_logbook to write a message with money/numbers. Will this mod works too? Or i need to use that special variables on the code (messages) to it work? (like $MONEY$, $AMOUNT$, $PRICE$, etc)
Thanks in any advice!
Egosoft have provided a series of standard message strings that they translate into multiple languages for you.
Here is an example from Notifications.xml line 2022
Code: Select all
<substitute_text text="$logtext" source="{1016,40}" comment="Received surplus of $MONEY$ Credits from $TRADER$.">
<replace string="'$TRADER$'" with="$tradenpc.name" />
<replace string="'$MONEY$'" with="-$result / 1Cr" />
</substitute_text>
Lets start with the source. If you look in 001-L044.xml under the t folder then you will find a section called 1016 and under that the following line
<t id="40">Received surplus of $MONEY$ Credits from $TRADER$.</t> looks rather like the comment

if you looked in 001-L049.xml then you will see this
<t id="40">Mehrbetrag über $MONEY$ Credits erhalten von $TRADER$.</t> and its in German
So that is multi lingual covered

$TRADER$ and $MONEY$ are place holders and have runtime values popped into them
At the end of this you have a variable called $logtext that has a string in it but it has no specific formatting apart from what was in {1016,40}
Now lets talk strings
Egosoft tend to use $MONEY$, $AMOUNT$, $PRICE$ for certain things but they are just place holders, the names are useful to the coder and reverse engineer. They have no magic properties the $...$ are just handy string start and end markers.
You can then take the $logtext string and use show_help, show_notification or write_to_logbook to output it to the help, event monitor or logbook.
Lets now introduce some number formatting. Here is the same code in 4.00
Code: Select all
<substitute_text text="$logtext" source="{1016,40}" comment="Received surplus of $MONEY$ Credits from $TRADER$.">
<replace string="'$TRADER$'" with="$tradenpc.name" />
<replace string="'$MONEY$'" with="(-$result).formatted.default" />
</substitute_text>
The format is identical to what this mod does. It knows that $result is a number and applies the default format
The formatted option is new to 4.00.
To do the same thing in 3.61 I had to write my own string formatting routine which is what Format Thousands is.
Code: Select all
<set_value name="$Thousands" exact="-$result / 1Cr"/>
<include_actions ref="md.Notifications.FormatThousands"/>
<substitute_text text="$logtext" source="{1016,40}" comment="Received surplus of $MONEY$ Credits from $TRADER$.">
<replace string="'$TRADER$'" with="$tradenpc.name" />
<replace string="'$MONEY$'" with="$FThousands" />
</substitute_text>
It takes one variable $Thousands and produces another variable called $FThousands and the include_actions runs it
There is a also a version of the library for ai scripts its is an actual aiscript itself as you can't call libraries from ai scripts
Code: Select all
<run_script name="'format.thousands'" result="$result">
<param name="Thousands" value="this.money / 1Cr" />
</run_script>
and the substitute_text gets
<replace string="'$MONEY$'" with="$result" />

The big question is how much of a hurry you are in. I really wasn't expecting Egosoft to suddenly release string formatting in 4.00 which is why I made the offer to other developers to use the library if they needed some thousands formatting
If you are not in a hurry I suggest waiting for 4.00 and use theirs
If you want something that works in 3.61 and potentially later (it works fine but as the functionality is now in the core then I would probably deprecate it in 4.00 and later) then use mine
jth
-
- Moderator (Script&Mod)
- Posts: 14571
- Joined: Sun, 20. Nov 05, 22:45
If you want some more ideas for additional functions: (made a lib with these functions in X3, but don't have any intention of implementing it in XR yet)
what about formatting numbers as roman numerals?
Or counting with A, B, C etc.? (OK, these two are only suited for small numbers)
and what about formatting it using a different base (e.g binary, octal, hexadecimal, or maybe even nonal
) - and possibly with a different characters than usual by passing a Page ID and a starting text id
I know - especially the last one may see not much usage but when adding the possibility of arbitrary bases by cleverly (ab)using the lang file its trivial to add
what about formatting numbers as roman numerals?
Or counting with A, B, C etc.? (OK, these two are only suited for small numbers)
and what about formatting it using a different base (e.g binary, octal, hexadecimal, or maybe even nonal

I know - especially the last one may see not much usage but when adding the possibility of arbitrary bases by cleverly (ab)using the lang file its trivial to add

if not stated otherwise everything i post is licensed under WTFPL
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter
I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help
