[SCRIPT] Assets Summary, version 1.01

The place to discuss scripting and game modifications for X³: Reunion.

Moderators: Scripting / Modding Moderators, Moderators for English X Forum

User avatar
Carlo the Curious
Posts: 16999
Joined: Mon, 5. Mar 07, 22:03
x4

[SCRIPT] Assets Summary, version 1.01

Post by Carlo the Curious »

Assets Summary Report
Version: 1.01

Sends you a message giving a summary of your current ships, stations, funds, and net worth.


Download
SPK
ZIP


Description
Well, it produces a report!

[ external image ][ external image ]

The property summary includes everything you own, although some ship types may show up as 'Other' (e.g. nav beacons, drones). 'Fab' indicates any station which isn't a dock or HQ or in a complex. 'Complex Fab' is any station in a complex which isn't the hub.

The wares total includes all wares in stations and on movable ships (installed or not, including software).


Usage
After installing the script you need to define a hotkey (or two) to run it.

'Run asset summary' should be present in Options-Controls-Interface in the Extensions section. Hit your newly defined hotkey in flight and you should (after a short pause) get a report detailing your vast riches.

'Log asset summary' produces the same report but also writes a comma-separated logfile (log08411.txt) to your X3 directory, listing details for all your ships and stations. It takes considerably longer to run than the 'no log' version.

If you want to run the script directly from the editor the 'no logging' version is plugin.asset.summary.nolog and the 'logging' version is plugin.asset.summary.log.


Version history
1.01 - 07/08/2008
- fixed (somewhat) ship tunings ware value
1.0 - 05/08/2008
- fixed hub value
- fixed bug with ship ware value
- fixed deployed ship value (but see issues)
- added logfile
- added German text file (probably badly translated!)
Note: If you had an earlier version installed you will need to redefine your hotkey.
0.4 - 30/06/2007
- fixed TS count, moved static ships to separate count.
0.3 - 29/06/2007
- Initial release.


Known issues
1. If you don't own any ships of class 'LittleShip' (M5, M4, M3, TS, TL) the wares total will be wrong, as the script will think all of your stations are in a complex.
2. The value for engine/rudder tunings and cargo bay upgrades is not exact, due to rounding issues.
2. The reported total is slightly lower than the 2.5 Uplink reports. Uplink figures the ware value for deployed ships like lastertowers differently.


Other
Credit to Shovinus for the inspiration :).
Thanks to jlehtone for help with various bits.

Bugs, etc. - PM me or post in this thread.


Tech bits
Text files
8411, page 8411
Log files
08411
Globals
plugin.asset.summary.TextID
plugin.asset.summary.HotKey (no longer used)
plugin.asset.summary.HotKey.NoLogging
plugin.asset.summary.HotKey.Logging
Script files
plugin.asset.summary.main
plugin.asset.summary.log
plugin.asset.summary.nolog
Libraries
lib.crm.ship.warevalue
lib.crm.number.multi.convert
lib.crm.number.multi.calc
lib.crm.number.multi.format
lib.bof.format.number
Last edited by Carlo the Curious on Mon, 26. Jan 09, 14:24, edited 11 times in total.
jlehtone
Posts: 22475
Joined: Sat, 23. Apr 05, 21:42
x4

Post by jlehtone »

Unregognized ships? I've got a whopping -1 of them. :P

Aesthetically I've never liked the addition of satellites and towers into ship count.

Personally I rather start a script like this from the editor than bind a key to it. Anyway, it does print numbers. :D
Goner Pancake Protector X
Insanity included at no extra charge.
There is no Box. I am the sand.
User avatar
Carlo the Curious
Posts: 16999
Joined: Mon, 5. Mar 07, 22:03
x4

Post by Carlo the Curious »

You can still run it from the script editor if you want (plugin.asset.summary.main).

-1 is odd. My maths must be dodgy somewhere - unrecognised total is Total-Sats-LTs-Mines-(M1+M2+...).

EDIT: There's something wrong there, but damned if I can see what. Mine gives 2 unrecognised when there should be 4 (beacons). But the total is right according to the properties window, as are the individual counts. :?
User avatar
Carlo the Curious
Posts: 16999
Joined: Mon, 5. Mar 07, 22:03
x4

Post by Carlo the Curious »

Hmm...

Figured out why mine differs from the property menu.

The property menu reports 56 TS, but my code says 58, because that's what

Code: Select all

tsarray = get ship array: of race Player class/type= TS
$tscount = size of array $tsarray
reports. Somewhat strange - something odd about nav beacons placed by BMS maybe.

Don't think that's the same as Jheltone's issue though.
User avatar
Carlo the Curious
Posts: 16999
Joined: Mon, 5. Mar 07, 22:03
x4

Post by Carlo the Curious »

Sussed it, and it is the same issue.

Seems the TS count includes TPs. I was misled by the X2 MSCI manual! :p

Also moved static ships to their own total, just for Jlehtone :).
jlehtone
Posts: 22475
Joined: Sat, 23. Apr 05, 21:42
x4

Post by jlehtone »

:D
Carlo the Curious wrote:Seems the TS count includes TPs.
So one Toucan Hauler added to -1. :roll:


A question some may have, how does it cope with modded ship classes and stations?
Goner Pancake Protector X
Insanity included at no extra charge.
There is no Box. I am the sand.
User avatar
Carlo the Curious
Posts: 16999
Joined: Mon, 5. Mar 07, 22:03
x4

Post by Carlo the Curious »

I'm not running XTM or other mods so I don't know for sure, but it works by object class, so as long as they're a standard ship class (M1, etc) it should total them up correctly - otherwise it will stick them in 'other'.

Ditto for stations - anything you can't dock a littleship at is counted as 'complex fab', anything else that's not a hub, dock or shipyard is counted as 'fab'.
User avatar
Carlo the Curious
Posts: 16999
Joined: Mon, 5. Mar 07, 22:03
x4

Post by Carlo the Curious »

Updated to 1.0.

Should now be as accurate as I can get it, although the 'ware value' for installed tunings is not correct (I've no idea how you'd work it out properly).

Also, besides tuning values it still doesn't quite agree with Egosoft's uplink data as that adds a ware value to deployed ships (like satellites and lasertowers), which seems wrong to me. For example, the uplink data for a lasertower is:

Code: Select all

<ship subtype="73">
  <ware value="155880" /> 
  <price value="151608" /> 
  <sector x="5" y="6" /> 
  <sectorrace value="8" /> 
  <race value="1" /> 
  <shipclass value="7" /> 
</ship>
An LT sells for 151,608 - I assume the 155,880 is the shields and the LT weapon, but you don't actually get money for them.

The Assets Summary script uses the 'dock' price for the equivalent ware for LTs, satellites and SQUASH mines, and ignores any installed wares for those ships.
jlehtone
Posts: 22475
Joined: Sat, 23. Apr 05, 21:42
x4

Post by jlehtone »

Carlo the Curious wrote:Also, besides tuning values it still doesn't quite agree with Egosoft's uplink data ...
Well, the user can always sum up the numbers from PlayerStats.pck if he is not happy with the in-game report. Which leads to ... saving uplink data takes a while with empire, how does your accounting compare?

Tunings, can you get "max tunings" for shiptype? If yes, then it might be possible to calculate value since 'tuning price' is a "known" equation.
Goner Pancake Protector X
Insanity included at no extra charge.
There is no Box. I am the sand.
User avatar
Carlo the Curious
Posts: 16999
Joined: Mon, 5. Mar 07, 22:03
x4

Post by Carlo the Curious »

It's faster than uplink (I assume I'm gathering less overall data), at least for my empire and PC.

With ~1500 ships and ~600 stations on a Q6600 it takes about 2 seconds for no log, 10 seconds with log, and 20 seconds for uplink.

I had a (very brief) look for the tuning price equation(s), but I couldn't find any.
jlehtone
Posts: 22475
Joined: Sat, 23. Apr 05, 21:42
x4

Post by jlehtone »

Carlo the Curious wrote:I had a (very brief) look for the tuning price equation(s), but I couldn't find any.
I'm quite sure I've seen them during the years I've been on the forum. :roll:

If one cannot find, one reinvents the wheel. How hard can that be?

* When you buy the very first tuning, it costs 14cr for cargo, 21cr for rudder, and 35cr for engine.
* When you have fully tuned the ship, the next (unbuyable) tuning would cost 1000cr for cargo, 2000cr for rudder, and 3000cr for engine.
* Price increases linearly with every unit.

Code: Select all

B = price of first
M = price after last
N = max number of buyable tunings
k = number of tunings already bought

price = B + k * (M-B)/N
* if you have none (k=0), next will cost B
* if you have all (k=N), next would cost M

So what did you pay for j units?

Code: Select all

sum = j*B + j*(j-1)*(M-B)/(2*N)
Some rounding errors here and there, but this is my guess of the equations. This was from ingame prices. No idea what equation is used by the uplink. For that one should buy bare ships with various tunings and save the stats.
Goner Pancake Protector X
Insanity included at no extra charge.
There is no Box. I am the sand.
User avatar
Carlo the Curious
Posts: 16999
Joined: Mon, 5. Mar 07, 22:03
x4

Post by Carlo the Curious »

Curious thing, the prices it says it's charging in game aren't the prices it seems to actually charge you.

e.g. a Disco Hauler takes 54 cargo extensions. With 53 the listed charge is 25890 Cr, and the price is 981 Cr (which matches your equation). But, with 54 the listed charge is 26865 Cr, i.e. it was actually 975 Cr.

I should be able to come up with something though (or just use your equation :)) - I didn't realise the initial and final prices were fixed :oops:.
User avatar
Carlo the Curious
Posts: 16999
Joined: Mon, 5. Mar 07, 22:03
x4

Post by Carlo the Curious »

Bah.

Your equation works (more or less) in that it gives a value close to the Uplink value. Unfortunately, for big freighters with lots of cargo extensions (e.g. a Dolphin Sfr has 2200) there are overflow problems.

Oh well, it was about time I got around to finishing off my multiple-precision number library. Or I could just sum them up :).

EDIT: Close enough!

A half-tuned Octopus:

Code: Select all

<ship subtype="34">
  <ware value="21452" /> 
  <price value="39668" /> 
  <sector x="0" y="0" /> 
  <sectorrace value="2" /> 
  <race value="2" /> 
  <shipclass value="7" /> 
</ship>

ShipValue,39668
WareValue,21439
A fully tuned Dolphin SFr:

Code: Select all

<ship subtype="158">
  <ware value="1143160" /> 
  <price value="1393656" /> 
  <sector x="0" y="0" /> 
  <sectorrace value="2" /> 
  <race value="2" /> 
  <shipclass value="1" /> 
</ship>

ShipValue,1393656
WareValue,1142669
Thanks for the help, jlehtone.
dienekes
Posts: 87
Joined: Wed, 29. Jul 09, 14:50

Post by dienekes »

Thanks for this mod, really neat!

Return to “X³: Reunion - Scripts and Modding”