[Tool Script] - Prices of ALL wares in your game

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

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

Post Reply
B-O'F
Posts: 719
Joined: Sat, 21. Feb 04, 03:15
x3tc

[Tool Script] - Prices of ALL wares in your game

Post by B-O'F » Sat, 17. Jun 06, 18:37

Hi,

A couple of scripts that list out the Type, Subtype, Average, Minimum and Maximum prices of all wares in your game to a logfile 12345.txt in the Reunion folder.

The output is formatted, and will vary from person to person depending on which scripts/mods they have installed.

It lists out ALL items in the game - even those with no price, and on my machine is 145kbytes.

There are two scripts - one is used to format the prices, the other to cycle through all the ware types and subtypes.

Script 1 - just run it

Code: Select all

Script a.Ware.Prices3
Version: 0
for Script Engine Version: 32

Description
Av Min Max prices
Arguments
Source Text

001   * list ave, min and max prices for a ware
002   $msga = '%s'
003   $msgware = ' %s'
004   $space = ' '
005   
006   $wtype = 0
007   $wsub = -1
008   while $wtype < 33
009    write to log file #12345  append=[TRUE]  printf: fmt=' ', null, null, null, null, null
010    write to log file #12345  append=[TRUE]  printf: fmt='Ware Type = %s', $wtype, null, null, null, null
011    while $wsub < 2000
012     inc $wsub = 
013     $ware = null
014     $ware =  get ware from maintype $wtype and subtype $wsub
015     if $ware != null
016      $aveprice = get average price of ware $ware
017      $minprice = get min price of ware $ware
018      $maxprice = get max price of ware $ware
019   * Format subtype
020      gosub subtype
021      
022   * Format average, minimum and maximum prices
023 @    $msgave = [THIS] -> call script 'a.Ware.Prices3.format' :  Number to be formatted=$aveprice
024 @    $msgmin = [THIS] -> call script 'a.Ware.Prices3.format' :  Number to be formatted=$minprice
025 @    $msgmax = [THIS] -> call script 'a.Ware.Prices3.format' :  Number to be formatted=$maxprice
026      
027      $message = $msgsubtype + $msgave + $msgmin + $msgmax + $msgware
028      write to log file #12345  append=[TRUE]  printf: fmt=$message, $wsub, $aveprice, $minprice, $maxprice, $ware
029     end
030    end
031    inc $wtype = 
032    $wsub = -1
033   end
034   return null
035   
036   * Format Subtype
037   subtype:
038   $msgsubtype = $msga
039   if $wsub > 99
040    $msgsubtype = $msga
041    $msgtype = $msga
042    endsub
043   end
044   if $wsub > 9
045    $msgsubtype = $space + $msga
046   else
047    $msgsubtype = $space + $space + $msga
048   end
049   endsub
050   
051   return null
Script 2 - used to format the prices

Code: Select all

Script a.Ware.Prices3.format
Version: 0
for Script Engine Version: 32

Description
Format Av Min Max prices
Arguments
1: number , Value , 'Number to be formatted' 
Source Text

001   * format ave, min and max prices for a ware
002   $msga = ' %s'
003   $space = ' '
004   $space2 = '  '
005   $space3 = $space2 + $space
006   $space4 = $space2 + $space2
007   $space5 = $space2 + $space3
008   $space6 = $space3 + $space3
009   $space7 = $space4 + $space3
010   $space8 = $space4 + $space4
011   
012   $fmtmsg = $msga
013   if $number > 99999999
014    $fmtmsg = $msga
015    return $fmtmsg
016   end
017   
018   if $number > 9999999
019    $fmtmsg = $space + $msga
020    return $fmtmsg
021   end
022   
023   if $number > 999999
024    $fmtmsg = $space2 + $msga
025    return $fmtmsg
026   end
027   
028   if $number > 99999
029    $fmtmsg = $space3 + $msga
030    return $fmtmsg
031   end
032   
033   if $number > 9999
034    $fmtmsg = $space4 + $msga
035    return $fmtmsg
036   end
037   
038   if $number > 999
039    $fmtmsg = $space5 + $msga
040    return $fmtmsg
041   end
042   
043   if $number > 99
044    $fmtmsg = $space6 + $msga
045    return $fmtmsg
046   end
047   
048   if $number > 9
049    $fmtmsg = $space7 + $msga
050   else
051    $fmtmsg = $space8 + $msga
052    return $fmtmsg
053   end
054   
055   return $fmtmsg
A sample of the output

Code: Select all

 
Ware Type = 5
  0  29929912  22447434  37412390 Free Argon Trading Station
  1  29215752  21911814  36519690 Split Trading Port
  2  29800064  22350048  37250080 Paranid Trading Dock
  3  30514228  22885671  38142785 Royal Boron Trading Station
  4  28241892  21181419  35302365 Teladi Trading Station
  5 129847780 140335507 119360053 Xenon Station
  6  51160024  38370018  63950030 Argon Equipment Dock
  7  48043676  36032757  60054595 Split Equipment Dock
  8  48368296  36276222  60460370 Paranid Equipment Dock
  9  48692916  36519687  60866145 Boron Equipment Dock
 10  49991396  37493547  62489245 Teladi Space Equipment Dock
 11 181786888 179289839 184283937 Xenon Station
 12 194771668 189028424 200514912 Goner Temple
 13 116863000 130596922 103129078 Pirate Base
 14  77908668  58431501  97385835 Kha'ak Station
 15  51160024  38370018  63950030 *** UNDEFINED ***
 16  48692916  36519687  60866145 *** UNDEFINED ***
 17  48368296  36276222  60460370 *** UNDEFINED ***
 18  48043676  36032757  60054595 *** UNDEFINED ***
 19  49991396  37493547  62489245 *** UNDEFINED ***
Maybe this will be of use to someone,

Boron - Ol Fh'art
Public Service announcement

Growing old is not a disease - it is a delayed symptom of birth trauma.

Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 20610
Joined: Mon, 15. Nov 04, 00:26
x4

Post by Cycrow » Sat, 17. Jun 06, 18:55

just a few notes

i see ur using 2000 as a standard number for subwares, when you dont need to

u can use

Code: Select all

$wsub = get number of subtypes of maintype $wtype
while $wsumb
  dec $wsub =
and the formating, you do release you can do it via a text file ?

Code: Select all

<t id="1">%10s %10s %10s %s\n</t>

$message = sprintf: page id = $page.id, id = 1, $aveprice, $minprice, $maxprice, $ware
Last edited by Cycrow on Sat, 17. Jun 06, 19:05, edited 1 time in total.

DesertEagle
Posts: 117
Joined: Thu, 2. Feb 06, 06:32
x3

Post by DesertEagle » Sat, 17. Jun 06, 18:59

Hey, really appreciate your effort. I will definitely use this if you release as an XML file. If you don't have hosting, send it to me at travis.godwin.good@gmail.com and I'll host it for you.

Best,
DE

Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 20610
Joined: Mon, 15. Nov 04, 00:26
x4

Post by Cycrow » Sat, 17. Jun 06, 19:07

also, if you really did want to use you own formatting, you can put it in a loop to cut down the script size

something like

Code: Select all

$string = sprintf: fmt '%s', $number, null, null, null, null
$len = get length of string $string
while $len < 10
  $string = ' ' + $string
  $len = get length of string $string
end

B-O'F
Posts: 719
Joined: Sat, 21. Feb 04, 03:15
x3tc

Post by B-O'F » Sat, 17. Jun 06, 21:56

Hi,

@Cycrow,

Thank you for the information, this is a modified script originally written for X2, so is 'quick and dirty'.

I didn't know that you could use the "%10s" type formatting - it will make life easier (and help anyone reading this post).

I found the "string to integer" command, but there isn't an "integer to string" command - didn't think of your way of doing it, much better.

Thank you for the information - I will note it for use... and modify these scripts.


@DesertEagle

Do you want the existing XML files, or do you want to wait until I try using Cycrow's information ?? 0r both ?? If I modify the code to use Cycrow's information, then a 't' file will be needed - no problem on my machine as I use a t file for quite a few of my mods and scripts (I use 44099, again, originally written for X2) - I am not sure which number to use for general use.....

Either way, the scripts show some rather interesting things (in the output, not my coding), and are available for general usage.

I believe that information should be shared, that way we all learn (as long as you learn, you are not dead - thankfully I have learned from Cycrow, so I am not dead yet).....

Boron - Ol Fh'art
Public Service announcement

Growing old is not a disease - it is a delayed symptom of birth trauma.

Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 20610
Joined: Mon, 15. Nov 04, 00:26
x4

Post by Cycrow » Sat, 17. Jun 06, 22:09

yeah there isn't really an specific interger to string command, but the sprintf one works perfectly fine for it.

of course, u could use the %10s in the sprintf: fmt command if you dont want to use a t file, i've not tested it, but it should work.

the 10 is basically the number of characters it should be

DesertEagle
Posts: 117
Joined: Thu, 2. Feb 06, 06:32
x3

Post by DesertEagle » Sat, 17. Jun 06, 23:05

Hi B-O'F,
if you are going to mod it up a little, I'll wait until you get a chance to do that, then mirror. Looking forward.

Cheers,
DesertEagle
B-O'F wrote:Hi,

@DesertEagle

Do you want the existing XML files, or do you want to wait until I try using Cycrow's information ?? 0r both ?? If I modify the code to use Cycrow's information, then a 't' file will be needed - no problem on my machine as I use a t file for quite a few of my mods and scripts (I use 44099, again, originally written for X2) - I am not sure which number to use for general use.....

Either way, the scripts show some rather interesting things (in the output, not my coding), and are available for general usage.

I believe that information should be shared, that way we all learn (as long as you learn, you are not dead - thankfully I have learned from Cycrow, so I am not dead yet).....

Boron - Ol Fh'art

B-O'F
Posts: 719
Joined: Sat, 21. Feb 04, 03:15
x3tc

Post by B-O'F » Sun, 18. Jun 06, 00:04

Hi,

Sorry for the delay, I have been testing all the suggested options.. gone from version 3 to version 7 - all worked.

@Cycrow
Hi Cycrow,
The '%10s' option worked (and is the easiest) - I am sure that it didn't work last time I tried it (possibly X2), which is why I didn't use it originally... oh well, more learning.

@DesertEagle
This is now reduced to just one, much shorter, script. I m sending you a copy, and I am posting it here for other people to look at/use.

There are no waits in this code, as it is meant to be run only once, and is not for gameplay, just to gather information.

Code: Select all

Script a.Ware.Prices7
Version: 0
for Script Engine Version: 32

Description
Av Min Max prices
Arguments
Source Text

001   * list ave, min and max prices for a ware
002   
003   $wtype = 0
004   $wsub = -1
005   while $wtype < 33
006    write to log file #12345  append=[TRUE]  printf: fmt=' ', null, null, null, null, null
007    write to log file #12345  append=[TRUE]  printf: fmt='Ware Type = %s', $wtype, null, null, null, null
008    $wsubmax =  get number of subtypes of maintype $wtype
009    while $wsub < $wsubmax
010     inc $wsub = 
011     $ware = null
012     $ware =  get ware from maintype $wtype and subtype $wsub
013     if $ware != null
014      $aveprice = get average price of ware $ware
015      $minprice = get min price of ware $ware
016      $maxprice = get max price of ware $ware
017      
018      write to log file #12345  append=[TRUE]  printf: fmt='%3s %10s %10s %10s %s', $wsub, $aveprice, $minprice, $maxprice, $ware
019     end
020    end
021    inc $wtype = 
022    $wsub = -1
023   end
024   return null
Thanks to you both,

Boron - Ol Fh'art
Public Service announcement

Growing old is not a disease - it is a delayed symptom of birth trauma.

DesertEagle
Posts: 117
Joined: Thu, 2. Feb 06, 06:32
x3

Fyi

Post by DesertEagle » Mon, 19. Jun 06, 18:42

BOF's scripts are now mirrored at:
http://www.travisgood.com/X3/BOF/

Post Reply

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