[RELEASE] ShipVersion OXP v1.23

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: winston, another_commander

cag
Deadly
Deadly
Posts: 202
Joined: Fri Mar 17, 2017 1:49 am

Re: [RELEASE] ShipVersion OXP v1.23

Post by cag »

with ShipVersion installed but not HardShips: when docked, hit F3, F3, Enter

Code: Select all

Warning: mission.runScreen(): texture "start_choices_bg.png" could not be found.
    Active script: shipversion 1.24
    shipversion.js, line 290:
            function (choice) {
The reference is here:

Code: Select all

"D:\Oolite.org-oxzs\ShipVersion_1.24.oxz"
    in file: "Scripts/shipversion.js"
     288:              background: "start_choices_bg.png"
The missing file:

Code: Select all

"\Oolite.org-oxzs\HardShips_0.89.oxz"
    found in: "Images"
In ShipVersion, creating an Images folder and adding start_choices_bg.png from HardShips fixes the problem.
"Better to be thought a fool, boy, than to open your trap and remove all doubt." - Grandma [over time, just "Shut your trap... fool"]
"The only stupid questions are the ones you fail to ask." - Dad
How do I...? Nevermind.
Krager
Competent
Competent
Posts: 53
Joined: Wed Dec 11, 2024 9:44 pm
Location: Russian

Re: [RELEASE] ShipVersion OXP v1.23

Post by Krager »

Доброго времени суток! У меня вопрос по ShipVersion 1.24. Дополнение выводит информацию при покупке корабля на странице F3-F3. С троке где должна выводится информация об отсутствии лазера, выводится информация об его продаже. "Remove Laser". Можете поправить что было лазер отсутствует или просто слово НЕТ?
333.jpg
Ещё бы убрать вывод категорий из дополнения LoadoutByCategory. Но это наверно вопрос к автору этого дополнения.
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 5121
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: [RELEASE] ShipVersion OXP v1.23

Post by phkb »

Krager wrote: Sat May 31, 2025 11:16 am
Доброго времени суток! У меня вопрос по ShipVersion 1.24. Дополнение выводит информацию при покупке корабля на странице F3-F3. С троке где должна выводится информация об отсутствии лазера, выводится информация об его продаже. "Remove Laser". Можете поправить что было лазер отсутствует или просто слово НЕТ?
The "Remove Laser" is because the equipment item in an empty weapon position is "EQ_WEAPON_NONE", which in the equipment.plist file, has a description of "Remove Laser"

Code: Select all

	(
		3, 0, "Remove Laser",
		"EQ_WEAPON_NONE",
		"Remove laser weapon from selected mounting.",
		{
Basically, the original author of this mod (Norby) didn't do any additional translation to look for "EQ_WEAPON_NONE" and change the description shown on the screen to something more helpful than "Remove Laser".
Krager wrote: Sat May 31, 2025 11:16 am
Ещё бы убрать вывод категорий из дополнения LoadoutByCategory. Но это наверно вопрос к автору этого дополнения.
Yeah, I'm not sure how this would work with Loadout by Category. I don't normally use ShipVersion, so I'd have to pull it apart to see what's inside.
Krager
Competent
Competent
Posts: 53
Joined: Wed Dec 11, 2024 9:44 pm
Location: Russian

Re: [RELEASE] ShipVersion OXP v1.23

Post by Krager »

phkb wrote: Sat May 31, 2025 12:04 pm

Code: Select all

	(
		3, 0, "Remove Laser",
		"EQ_WEAPON_NONE",
		"Remove laser weapon from selected mounting.",
		{
Basically, the original author of this mod (Norby) didn't do any additional translation to look for "EQ_WEAPON_NONE" and change the description shown on the screen to something more helpful than "Remove Laser".
Искал где в коде находиться "EQ_WEAPON_NONE" и не нашёл. Нет его. В файле shipversion.js в строке 614 находиться текст, который должен выводиться на экран при отсутствии лазера. Однако почему то не выводиться...

И ещё один косяк в этом дополнении есть. На эакране F3-F3 при покупки корабля, если нажать нет, отказаться от покупки. Возвращаешься на экран списка кораблей для покупки. Однако сам просмотренный корабль исчезает. И фон этого экрана тоже исчезает...
1.jpg
2.jpg
3.jpg
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 5121
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: [RELEASE] ShipVersion OXP v1.23

Post by phkb »

Krager wrote: Tue Jun 03, 2025 11:44 pm
Искал где в коде находиться "EQ_WEAPON_NONE" и не нашёл. Нет его. В файле shipversion.js в строке 614 находиться текст, который должен выводиться на экран при отсутствии лазера. Однако почему то не выводиться...
There is a bug in the code. On lines 605-614 a text string is being built up with descriptions of the lasers installed on the new ship. However, it is doing a null check against each of the laser positions, which will likely never be true, because even on a ship with no laser mounts the positions have "EQ_WEAPON_NONE" installed there.

So, this is the code in question:

Code: Select all

    s=player.ship.forwardWeapon;
    if(s!=null) equip+="Forward "+s.name;
    s=player.ship.aftWeapon;
    if(s!=null) equip+=", Aft "+s.name;
    s=player.ship.portWeapon;
    if(s!=null) equip+="\nPort "+s.name;
    s=player.ship.starboardWeapon;
    if(s!=null) equip+=", Starboard "+s.name;
    if(equip.length > 0) equip+="\n";
    else equip+="No Laser\n";
To get this to work how I imagine it's supposed to work, you would need to change it to this:

Code: Select all

    s=player.ship.forwardWeapon;
    if(s.equipmentKey!="EQ_WEAPON_NONE") equip+="Forward "+s.name;
    s=player.ship.aftWeapon;
    if(s.equipmentKey!="EQ_WEAPON_NONE") equip+=", Aft "+s.name;
    s=player.ship.portWeapon;
    if(s.equipmentKey!="EQ_WEAPON_NONE") equip+="\nPort "+s.name;
    s=player.ship.starboardWeapon;
    if(s.equipmentKey!="EQ_WEAPON_NONE") equip+=", Starboard "+s.name;
    if(equip.length > 0) equip+="\n";
    else equip+="No Laser\n";
Krager wrote: Tue Jun 03, 2025 11:44 pm
И ещё один косяк в этом дополнении есть. На эакране F3-F3 при покупки корабля, если нажать нет, отказаться от покупки. Возвращаешься на экран списка кораблей для покупки. Однако сам просмотренный корабль исчезает. И фон этого экрана тоже исчезает...
I believe this was always a limitation with the OXP - I think I remember Norby mentioning this issue. The issue can be worked around now, as we have programmatic access to the stations shipyard and could theoretically add the ship back into the list, so from a technical perspective it can be solved. But Norby hasn't been around to update this OXP to utilise the newer methods.

As for the issue with the backgrounds changing, I believe that's is basically down to lots of OXP's in play (Library GUI, XenonUI, whatever HUD you have, ShipVersion and potentially Hyperspace Hangar) and insufficient testing. The are a few scenarios that haven't been fully catered for in the code. I notice the same thing when I'm testing ShipVersion. It gives me my old ship back if I say no, but messes up my HUD and backgrounds. Annoying, somewhat immersion breaking, but only a cosmetic bug, I'd say.
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2737
Joined: Sat Jun 11, 2011 6:07 am
Location: Nova Hollandia
Contact:

Re: [RELEASE] ShipVersion OXP v1.23

Post by Wildeblood »

phkb wrote: Wed Jun 04, 2025 6:26 am
On lines 605-614 a text string is being built up with descriptions of the lasers installed on the new ship. However, it is doing a null check against each of the laser positions, which will likely never be true, because even on a ship with no laser mounts the positions have "EQ_WEAPON_NONE" installed there.

So, this is the code in question:

Code: Select all

    s=player.ship.forwardWeapon;
    if(s!=null) equip+="Forward "+s.name;
    s=player.ship.aftWeapon;
    if(s!=null) equip+=", Aft "+s.name;
    s=player.ship.portWeapon;
    if(s!=null) equip+="\nPort "+s.name;
    s=player.ship.starboardWeapon;
    if(s!=null) equip+=", Starboard "+s.name;
    if(equip.length > 0) equip+="\n";
    else equip+="No Laser\n";
To get this to work how I imagine it's supposed to work, you would need to change it to this:

Code: Select all

    s=player.ship.forwardWeapon;
    if(s.equipmentKey!="EQ_WEAPON_NONE") equip+="Forward "+s.name;
    s=player.ship.aftWeapon;
    if(s.equipmentKey!="EQ_WEAPON_NONE") equip+=", Aft "+s.name;
    s=player.ship.portWeapon;
    if(s.equipmentKey!="EQ_WEAPON_NONE") equip+="\nPort "+s.name;
    s=player.ship.starboardWeapon;
    if(s.equipmentKey!="EQ_WEAPON_NONE") equip+=", Starboard "+s.name;
    if(equip.length > 0) equip+="\n";
    else equip+="No Laser\n";
Are you sure?

When I first revealed to the comoonity that it was possible to remove lasers, I warned not to try it on a mount that had never had a laser installed, because, "Whackiness will ensue." (i.e. the null would cause an exception as an unrecognized equipmentKey.)
Back then, a new Jameson file came with a pulse laser and three nulls, and Norby probably made this error by examining a Jameson file and assuming empty mounts were always null.

My question is, is it now the case that new Jameson files have "EQ_WEAPON_NONE" on empty mounts? Or, should the test be:

if (s.equipmentKey !== "EQ_WEAPON_NONE" && s.equipmentKey !== null)
Make pteridomania great again!
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 5121
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: [RELEASE] ShipVersion OXP v1.23

Post by phkb »

Wildeblood wrote: Wed Jun 04, 2025 7:29 am
Are you sure?
I just tried this:
Image
As soon as I applied a null value, it went back to EQ_WEAPON_NONE.

And I should add, that was using an Orbital Shuttle, which theoretically has no gun mounts anyway.
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2737
Joined: Sat Jun 11, 2011 6:07 am
Location: Nova Hollandia
Contact:

Re: [RELEASE] ShipVersion OXP v1.23

Post by Wildeblood »

phkb wrote: Wed Jun 04, 2025 7:35 am
As soon as I applied a null value, it went back to EQ_WEAPON_NONE.
Operative word boldfaced. Did you confirm the value before throwing the null at it and causing the error-handling to change null to "EQ_WEAPON_NONE"?

Addendum: I'm off on one of my nostalgia trips now, trying to remember what the situation was exactly. I remember discovering EQ_WEAPON_NONE in the source code, not in a Jameson save-file. It was something to do with the mount-weapon page, where you decide which mount a newly-purchased laser is going to, IIRC ( :lol: ). And... yeah, that's all I remember.
When I first revealed to the comoonity that it was possible to remove lasers, I warned not to try it on a mount that had never had a laser installed, because, "Whackiness will ensue." (i.e. the null would cause an exception as an unrecognized equipmentKey.)
I need to clarify my own remark now: trying to remove the existing null caused the error, not trying to write a null (which would have been silly).

I remember now: it's the refund-o-matic code that caused the problem, when Oolite attempted to extract the price of a null from its non-existent equipmentInfo. You could replace EQ_WEAPON_MINING_LASER with EQ_WEAPON_NONE, but you could not replace null with EQ_WEAPON_NONE, because it couldn't calculate the refund.

There were two possible ways to fix it: the obvious, to replace null with EQ_WEAPON_NONE in Jameson files, or to add extra lines of error-catching code to the Oolite source.
Last edited by Wildeblood on Wed Jun 04, 2025 8:14 am, edited 1 time in total.
Make pteridomania great again!
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 5121
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: [RELEASE] ShipVersion OXP v1.23

Post by phkb »

Wildeblood wrote: Wed Jun 04, 2025 7:47 am
Operative word boldfaced. Did you confirm the value before throwing the null at it and causing the error-handling to change null to "EQ_WEAPON_NONE"?
OK,
Image
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2737
Joined: Sat Jun 11, 2011 6:07 am
Location: Nova Hollandia
Contact:

Re: [RELEASE] ShipVersion OXP v1.23

Post by Wildeblood »

phkb wrote: Wed Jun 04, 2025 8:13 am
OK,
You don't need to post screen-captures. You could just write, "Yeah." I'd take you at your word. Anyway, thank you for this trip down memory lane.
Make pteridomania great again!
Post Reply