Re: Troubles with adding cargo space/Ways to solve them.
Posted: Tue Dec 08, 2015 9:15 pm
ocz, I was thinking about your issues with adding cargo space and I'd like to offer a suggestion on ways to implement the idea. I think it's fair to say that attempting to update max_cargo at "startUp" or "startUpComplete" is too late. Too many things have been set up, you can't tell the order in which things will be changed, and the likelihood of OXP conflicts are huge.
I think your best bet is to work with shipdata-overrides.plist. Be aware I haven't tested what follows, but it at least works in my head!
Make a change like this:
That will change the Adder's default max_cargo from 2 to 10.
Next, create a series of "filler" equipment items, that take up cargo space but are not visible on the F5 screen.
The "cargospace_conditions.js" would look like this:
With those things set up, it should be just a matter of adding the appropriate filler items to the player ship to take away the extra space. Because the shipdata-overrides.plist change happens before any cargo or passenger berths take place, you shouldn't have to worry about monitoring cargo or passengers and making sure they are added back if they get lost.
To purchase additional cargo space, it should be a simple matter to swap out the old filler item and putting a smaller one back. Instant extra space.
Anyway, as I said I haven't tested this, but it seemed like a viable way to add space without disrupting lots of other components of the system.
I think your best bet is to work with shipdata-overrides.plist. Be aware I haven't tested what follows, but it at least works in my head!
Make a change like this:
Code: Select all
// shipdata-overrides.plist
{
"oolite_template_adder-player" = {
max_cargo = 10;
}
}
Next, create a series of "filler" equipment items, that take up cargo space but are not visible on the F5 screen.
Code: Select all
// equipment.plist
{
(
0,
1,
"FillerSpace1",
"EQ_FILLERSPACE_1",
"Virtual filler space 1t",
{
"available_to_all" = yes;
"available_to_NPCs" = no;
"available_to_player" = yes;
"condition_script" = "cargospace_conditions.js";
"damage_probability" = 0.0;
"requires_cargo_space" = 1;
"visible" = no; // listed on the F5F5 screen.
}
),
// you'll need more of these items, from 1 to 10t, or more depending on how much additional space you will potentially want to add to ships
}
Code: Select all
"use strict";
this.name = "CargoSpace_Conditions";
this.allowAwardEquipment = function(equipment, ship, context) {
if (context == "scripted") return true;
return false;
}
To purchase additional cargo space, it should be a simple matter to swap out the old filler item and putting a smaller one back. Instant extra space.
Anyway, as I said I haven't tested this, but it seemed like a viable way to add space without disrupting lots of other components of the system.