[SCRIPT-LIBRARY]-(Updated 11-24-08) - Get Wares of Ship

The place to discuss scripting and game modifications for X³: Terran Conflict and X³: Albion Prelude.

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

Post Reply
WindsOfBoreas
Posts: 283
Joined: Sun, 3. Aug 08, 20:30

[SCRIPT-LIBRARY]-(Updated 11-24-08) - Get Wares of Ship

Post by WindsOfBoreas » Sat, 22. Nov 08, 12:00

Library Script: Get Wares of Ship

Download

Both FileFront

Library Script
Example Menu Script

What this does...

Returns an array of the selected type of wares on board a ship as well as several arrays with various information.

What this can do...

Returns thirteen arrays for use in any script or for a menu script.
  1. The Ware Array
    • Returns a list of the wares on a ship. If you were to look at the array when being used for a menu, it would be broken up by [FALSE] values where the ware type changes. This null value corresponds with the second array....
  2. The Description Array
    • Returns the headers for a menu. If you were to look at the array, it would be broken up by [TRUE] where there is a ware in the Ware Array.
  3. Ware Amount Array
    • Returns an array of the amount that the target ship is carrying of the wares. [FALSE] corresponds with a header in the Description Array
  4. Ware Amount Free Array
    • Returns an array of the free amount that the target ship can carry of the wares. [FALSE] corresponds with a header in the Description Array
  5. Ware Amount True Array
    • Returns an array of the true amount that the target ship is carrying of the wares. [FALSE] corresponds with a header in the Description Array
  6. Ware Amount Max Array
    • Returns an array of the maximum amount that the target ship can carry of the wares. [FALSE] corresponds with a header in the Description Array
  7. Ware Price Average Array
    • Returns an array of the average prices of the wares. [FALSE] corresponds with a header in the Description Array
  8. Ware Price Max Array
    • Returns an array of the maximum prices of the wares. [FALSE] corresponds with a header in the Description Array
  9. Ware Price Min Array
    • Returns an array of the minimum prices of the wares. [FALSE] corresponds with a header in the Description Array
  10. Ware Volume Array
    • Returns an array of the volume of the wares. [FALSE] corresponds with a header in the Description Array
  11. Ware Volume Free Array
    • Returns an array of the free volume of a ware in the ship. [FALSE] corresponds with a header in the Description Array
  12. Ware Volume True Array
    • Returns an array of the true volume of a ware in the ship. [FALSE] corresponds with a header in the Description Array
  13. Ware Transport Class Array
    • Returns an array of the transport class of the wares. [FALSE] corresponds with a header in the Description Array

How to use...
  1. Call the script "lib.wob.ship.getwares".
  2. Set the first parameter to the target ship.
  3. Set the second parameter an array of the ware types. Each position is set to either [TRUE] or [FALSE]
    1. 0th Position is Bio.
    2. 1st Position is Energy.
    3. 2nd Position is Food.
    4. 3rd Position is Minerals.
    5. 4th Position is Natural.
    6. 5th Position is Tech.
    7. 6th Position is Lasers.
    8. 7th Position is Missiles.
    9. 8th Position is Shields.
    To return Bio, Food, and Minerals the array would look like:

    Code: Select all

    [TRUE], [FALSE], [TRUE], [TRUE], [FALSE], [FALSE], [FALSE], [FALSE], [FALSE]
  4. Set the third parameter to [TRUE] to sort the ware array alphanumerically. Set to [FALSE] to leave the array unsorted.
  5. Set the fourth parameter to [TRUE] if you are going to use the ware array to create a menu. Set to [FALSE] to use the array normally.
  6. Set the fifth parameter to [TRUE] to return upgrades in the Ware Array. Set to [FALSE] to exclude upgrades.
  7. Set the sixth parameter to [TRUE] to return equipment in the Ware Array. Set to [FALSE] to exclude equipment.
  8. The returned value is an array with thirteen indexes.

    This is what the calling and return should look like:

    Code: Select all

    001   $Target =  get player tracking aim
    002   
    003   * ***** SET EACH VALUE TO [TRUE] TO USE OR [FALSE] TO NOT USE*****
    004   
    005   $Ware.Array.Types =  array alloc: size=9
    006   * 0 = Bio
    007   $Ware.Array.Types[0] = [TRUE]
    008   * 1 = Energy
    009   $Ware.Array.Types[1] = [TRUE]
    010   * 2 = Food
    011   $Ware.Array.Types[2] = [TRUE]
    012   * 3 = Minerals
    013   $Ware.Array.Types[3] = [TRUE]
    014   * 4 = Natural
    015   $Ware.Array.Types[4] = [TRUE]
    016   * 5 = Tech
    017   $Ware.Array.Types[5] = [TRUE]
    018   * 6 = Lasers
    019   $Ware.Array.Types[6] = [TRUE]
    020   * 7 = Missiles
    021   $Ware.Array.Types[7] = [TRUE]
    022   * 8 = Shields
    023   $Ware.Array.Types[8] = [TRUE]
    024   
    025   
    026 @ $Ware.Array.Super = [THIS] -> call script 'lib.wob.ship.getwares' :  Ship=$Target  Return Ware Types=$Ware.Array.Types  Sort Ware Array T/F?=[TRUE]  For Menu?=[TRUE]  Return Upgrades?=[TRUE]  Return Equipment=[TRUE]
    027   
    028   if not $Ware.Array.Super
    029   |return null
    030   end
    031   
    032   $Ware.Array = $Ware.Array.Super[0]
    033   $Ware.Array.Description = $Ware.Array.Super[1]
    034   $Ware.Array.Amount = $Ware.Array.Super[2]
    035   $Ware.Array.Amount.Free = $Ware.Array.Super[3]
    036   $Ware.Array.Amount.True = $Ware.Array.Super[4]
    037   $Ware.Array.Amount.Max = $Ware.Array.Super[5]
    038   $Ware.Array.Price.Average = $Ware.Array.Super[6]
    039   $Ware.Array.Price.Max = $Ware.Array.Super[7]
    040   $Ware.Array.Price.Min = $Ware.Array.Super[8]
    041   $Ware.Array.Volume = $Ware.Array.Super[9]
    042   $Ware.Array.Volume.Free = $Ware.Array.Super[20]
    043   $Ware.Array.Volume.True = $Ware.Array.Super[11]
    044   $Ware.Array.Class = $Ware.Array.Super[12]

    Example of Menu Usage

    If you are going to use the ware array in a menu, I suggest that you either use my example script to start with or at least look at it.
Image

    • I suggest that you download the example script too just to see how to call the library properly.

Enjoy
The North Wind
Last edited by WindsOfBoreas on Sun, 7. Jun 09, 11:36, edited 12 times in total.
"Humanity has the stars in its future, and that future is too important to be lost under the burden of juvenile folly and ignorant superstition." - Isaac Asimov

WindsOfBoreas
Posts: 283
Joined: Sun, 3. Aug 08, 20:30

Post by WindsOfBoreas » Mon, 24. Nov 08, 07:58

Updated

I have updated the library to include a ton of information in the multidimensional return array. This includes

The Wares
The Description Headers
The Amount of Each Ware on the Ship
The Free Amount of Each Ware on the Ship
The True Amount of Each Ware on the Ship
The Max Amount of Each Ware on the Ship
The Average Price of Each Ware on the Ship
The Max Price of Each Ware on the Ship
The Min Price of Each Ware on the Ship
The Volume of Each Ware on the Ship
The Free Volume of Each Ware on the Ship
The True Volume of Each Ware on the Ship
The Transport Class of Each Ware on the Ship

That should be all that I'll be updating of this script.

The North Wind
"Humanity has the stars in its future, and that future is too important to be lost under the burden of juvenile folly and ignorant superstition." - Isaac Asimov

Post Reply

Return to “X³: Terran Conflict / Albion Prelude - Scripts and Modding”