Strange behaviour adjusting player manifest

For test results, bug reports, announcements of new builds etc.

Moderators: winston, another_commander, Getafix

Post Reply
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4830
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Strange behaviour adjusting player manifest

Post by phkb »

Can I get someone to confirm this? I've been going round in circles for an hour and I need a second opinion.

So, in a completely pristine 1.87 install, I added the following script file:

Code: Select all

"use strict";
this.name        = "TestOXP";

this.startUpComplete = function() {
    player.ship.manifest["gold"] += 50;
}
this.$test = function() {
    player.ship.manifest["gold"] -= 50;
}
Start a new game, check the F8 screen to ensure our gold has been added, and launch.

Then, using the debug console, run this command to execute the $test function:

Code: Select all

worldScripts.TestOXP.$test()
If your experience is the same as mine, if you then go to the F8 screen, you will see that the 50kg of gold is still there. (Note: the function will work if you are still docked).

Let's change this up a bit. Adjust the script file so it looks like this:

Code: Select all

"use strict";
this.name        = "TestOXP";

this.startUpComplete = function() {
    player.ship.manifest["minerals"] += 1;
    player.ship.manifest["gold"] += 50;
}
this.$test = function() {
    player.ship.manifest["gold"] -= 50;
}
Then do the same thing: new game, launch, and run the $test function via the debug console.

This time it's different: now the gold has been successfully removed, leaving just the minerals.

I've tested this with a number of different "t" commodities, and with other "kg" or "g" variations, and in all cases, the "kg"/"g" types will not get removed if there is zero amount of any "t" type commodities on board.

Can someone else confirm this behaviour, or am I going mad? Or maybe it's a feature...
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6681
Joined: Wed Feb 28, 2007 7:54 am

Re: Strange behaviour adjusting player manifest

Post by another_commander »

I think we can call this a bug. Something happens during the conversion of g/kg to g/kg-in-tonne-canisters or with its handling.

I did a small variation of your test, which was just running the commodity removal command manually from the console and I noticed this pattern:
- You start with 50kg of gold awarded by your script at startup. This is gold stored in the ship's "safe".
- Launch. If you go to the F5/F5 screen you can see it is listed as 50 kg x Gold.
- If you execute PS.manifest["gold"] -= 50 from the console, nothing happens.
- Now execute PS.manifest["gold"] += 1 in the console. You will find that this works even when in space. Check your F5/F5. See the difference? It reports 51 kg x Gold (1TC). Now all the gold is stored in a canister.
- Do a PS.manifest["gold"] -= 51 from the console. All gold is now removed, most likely because it was considered a full canister. This is the current workaround if you want to remove g/kg quantities in-flight without any other 1t canisters present at the moment.

The fact that this behaviour is not the same when there are already 1t canisters present in the hold is what makes me thing this is a bug.
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6681
Joined: Wed Feb 28, 2007 7:54 am

Re: Strange behaviour adjusting player manifest

Post by another_commander »

Guess what, this goes back all the way to at least 1.82. And here is an additional test.
- Start game, before launching award any amount (let's say 32 kg) of gold. Remember this amount.
- Now launch. Gold is reported as 32 kg x Gold.
- Award any additional amount of gold, say to get us to 48 kg. Cargo report says 48 kg x Gold (1TC).
- Now remove a small amount, so that you don't fall below the initial quantity of 32 kg. Example: PS.manifest["gold"] -= 4. Reported cargo: 44 kg x Gold (1TC)
- Now remove more gold so that you get to the initial quantity or less. Example: PS.manifest["gold"] -= 13 to get to 31 kg. Cargo report: 31 kg x Gold (without the TC part).
- At this point, you cannot remove any more gold.
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4830
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: Strange behaviour adjusting player manifest

Post by phkb »

Well, I’m glad to know it wasn’t just me! Phew! Kept adjusting my code thinking the problem must be there somewhere and kept hitting the same issue... ah the joys of programming!
Post Reply