Join us at the Oolite Anniversary Party -- London, 7th July 2024, 1pm
More details in this thread.

Save Any Where OXP Version 3.2 [RELEASE]

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

Moderators: another_commander, winston

User avatar
lave
Deadly
Deadly
Posts: 141
Joined: Thu Sep 09, 2010 12:21 am
Location: Deep in Leesti space mining asteroids for a living.
Contact:

Re: Save Any Where OXP Version 3.1 [RELEASE]

Post by lave »

I for one am looking forward to a release.
Thanks.
Switeck
---- E L I T E ----
---- E L I T E ----
Posts: 2412
Joined: Mon May 31, 2010 11:11 pm

Re: Save Any Where OXP Version 3.1 [RELEASE]

Post by Switeck »

CommonSenseOTB wrote:
line 884 if(guiScreen !== "GUI_SCREEN_STATUS")//CommonSenseOTB bug found deprecated !=
Just for the sake of writing OXPs, I don't fully understand the difference between != and !== or even == and === in an if statement. :(
You have a good link to explain what makes them tick?
Dragonfire
---- E L I T E ----
---- E L I T E ----
Posts: 503
Joined: Sat Jun 11, 2011 7:46 pm

Re: Save Any Where OXP Version 3.1 [RELEASE]

Post by Dragonfire »

No link, but I know that for Python (so, similar syntax, I assume), "=" sets a variable, while "==" compares a variable. "!=" means "does not equal".

But, it could be different for openstep, so don't quote me.
User avatar
Lone_Wolf
---- E L I T E ----
---- E L I T E ----
Posts: 546
Joined: Wed Aug 08, 2007 10:59 pm
Location: Netherlands

Re: Save Any Where OXP Version 3.1 [RELEASE]

Post by Lone_Wolf »

Switeck wrote:
CommonSenseOTB wrote:
line 884 if(guiScreen !== "GUI_SCREEN_STATUS")//CommonSenseOTB bug found deprecated !=
Just for the sake of writing OXPs, I don't fully understand the difference between != and !== or even == and === in an if statement. :(
You have a good link to explain what makes them tick?
try this one :
JavaScript Comparison and Logical Operators
OS : Arch Linux 64-bit - rolling release

OXPs : My user page

Retired, reachable at [email protected]
User avatar
CommonSenseOTB
---- E L I T E ----
---- E L I T E ----
Posts: 1397
Joined: Wed May 04, 2011 10:42 am
Location: Saskatchewan, Canada

Re: Save Any Where OXP Version 3.1 [RELEASE]

Post by CommonSenseOTB »

Switeck wrote:
CommonSenseOTB wrote:
line 884 if(guiScreen !== "GUI_SCREEN_STATUS")//CommonSenseOTB bug found deprecated !=
Just for the sake of writing OXPs, I don't fully understand the difference between != and !== or even == and === in an if statement. :(
You have a good link to explain what makes them tick?
Hi Switek.

To find the bugs I needed to see what the changes were from 1.74.2 to 1.75.

I looked in the Changelog that comes with oolite and found under 1.75 under javascript changes the following:

Vector3D and Quaternion objects can no longer be compared using == and !=,
because the wart in the JavaScript engine we were previously exploiting no
longer exists. See https://bb.oolite.space/viewtopic.php?f=4&t=8847 for
more information.

In that post there is a link to this website that explains it.

http://www.webreference.com/js/tips/991205.html

Sometimes it is not required to understand the changes, but simply to know what they are and apply them. Basically we were using sloppy programming and that will no longer work as of 1.75. Best to use !==(not exactly equal) and ===(exactly equal) as "3" == 3 is true but "3" === 3 is false. See the difference? For a lot of comparisons == works just fine but for how long? and != can give the wrong answer so shouldn't be used and the "wart" that allowed us to be sloppy is no longer there so you might not get the same answer from the same equation as of 1.75.

I hope that helps Switek. It helped me understand what to look for in an oxp that became broken as of 1.75. :)
Take an idea from one person and twist or modify it in a different way as a return suggestion so another person can see a part of it that can apply to the oxp they are working on.


CommonSense 'Outside-the-Box' Design Studios Ltd.
WIKI+OXPs
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Re: Save Any Where OXP Version 3.1 [RELEASE]

Post by JensAyton »

Erm, that link very explicitly applies only to Quaternion and Vector3D objects. == and != are not deprecated for strings, and === and !== are no use for Quaternions and Vector3Ds either.
CommonSenseOTB wrote:
For a lot of comparisons == works just fine but for how long?
Forever. The problem was highly specific.
Switeck
---- E L I T E ----
---- E L I T E ----
Posts: 2412
Joined: Mon May 31, 2010 11:11 pm

Re: Save Any Where OXP Version 3.1 [RELEASE]

Post by Switeck »

This did get me looking at my old OXP code again. In Misjump Inducer OXP, I could've accidentally done this:

Code: Select all

		if(player.ship.scriptedMisjump === "TRUE") {
			player.ship.scriptedMisjump = false;
			player.commsMessage("Misjumping Disabled.",6);
		} else {
			player.ship.scriptedMisjump = true;
Does true with no quotes exactly equal (both value and type) "TRUE" as a string? I'm not convinced it is...or should be. Fortunately, that's not what I used.

I also work with a lot of math in some of my unreleased OXPs...related to this:
https://bb.oolite.space/viewtopic.php?f=2&t=9729
(It's too complex and crash-happy to release ANY of it, not to mention it's currently only a hack-job cheat I use for testing. That it also mostly duplicates parts of Okti's LongRangeScanner OXP gives me even less incentive to release it.)
But in it, I alternate from dealing with probable integers to definite floating point numbers. It would be a pain if an integer 4 isn't exactly equal to a floating point 4.0000 and that's a minefield I was sure to run into had you not helped me out some here.
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Re: Save Any Where OXP Version 3.1 [RELEASE]

Post by JensAyton »

Switeck wrote:
Does true with no quotes exactly equal (both value and type) "TRUE" as a string?
No. The boolean values, true and false, are distinct values of a particular type, boolean.

In any case, the proper test here is if (player.ship.scriptedMisjump). Comparing against either boolean value, but especially true, is almost never the right thing. It makes your code noisier and more fragile.
Switeck
---- E L I T E ----
---- E L I T E ----
Posts: 2412
Joined: Mon May 31, 2010 11:11 pm

Re: Save Any Where OXP Version 3.1 [RELEASE]

Post by Switeck »

Looks like both my Auto ECM OXP and Misjump Inducer OXP are in need of updates to make them less fragile then. :lol:
I'd previously mistaken a statement like this:
if (player.ship.scriptedMisjump)
to ONLY mean "if this exists" (is not null). Ah well, live and learn.
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Re: Save Any Where OXP Version 3.1 [RELEASE]

Post by JensAyton »

The actual rule is that the following values are treated as false:
  • false
  • 0
  • -0
  • NaN (“not a number”, a numerical value for certain invalid operations like Math.asin(2))
  • The empty string
  • null
  • undefined
User avatar
CommonSenseOTB
---- E L I T E ----
---- E L I T E ----
Posts: 1397
Joined: Wed May 04, 2011 10:42 am
Location: Saskatchewan, Canada

Re: Save Any Where OXP Version 3.1 [RELEASE]

Post by CommonSenseOTB »

Edited: Irrelevant post as math discusion has ceased.


I'm glad I could help you Switek.

A little heads up to Save Anywhere users who used my bugfix to upgrade their copy. I found a very isolated behaviour in custom views when loading a saveanywhere savegame. This is specific to a method I'm using to keep huds synchronized with the correct zoom views in my Sniper Camera System.oxp and as no other oxp uses this method you need not worry about it and I have a workaround for it anyway.

Be on the lookout for any other strange behaviour as everything released in the last 6 months hasn't had to pass testing with this oxp installed. I don't anticipate any real problems but developers should test their stuff that it is ok after reloading a save anywhere saved game and anyone who finds some kind of weird behaviour after reloading a saved saveanywhere game should report it here.

We're six months behind so this is to be expected.
Take an idea from one person and twist or modify it in a different way as a return suggestion so another person can see a part of it that can apply to the oxp they are working on.


CommonSense 'Outside-the-Box' Design Studios Ltd.
WIKI+OXPs
Dragonfire
---- E L I T E ----
---- E L I T E ----
Posts: 503
Joined: Sat Jun 11, 2011 7:46 pm

Re: Save Any Where OXP Version 3.1 [RELEASE]

Post by Dragonfire »

Somehow not able to figure out...has this been released yet in the fixed version? The wiki still lists it as broken.
User avatar
maik
Wiki Wizard
Wiki Wizard
Posts: 2020
Joined: Wed Mar 10, 2010 12:30 pm
Location: Ljubljana, Slovenia (mainly industrial, feudal, TL12)

Re: Save Any Where OXP Version 3.1 [RELEASE]

Post by maik »

Dragonfire wrote:
Somehow not able to figure out...has this been released yet in the fixed version? The wiki still lists it as broken.
The fix hasn't been included in the released version. However, I added a link to this discussion to its wiki page and moved its entry from the broken to the normal section of the [wiki]OXP List[/wiki], marking it as N* (broken but fix exists). Does this make sense?
User avatar
DaddyHoggy
Intergalactic Spam Assassin
Intergalactic Spam Assassin
Posts: 8501
Joined: Tue Dec 05, 2006 9:43 pm
Location: Newbury, UK
Contact:

Re: Save Any Where OXP Version 3.1 [RELEASE]

Post by DaddyHoggy »

Makes sense to me - and the link to the fix is good - because I lost it!
Selezen wrote:
Apparently I was having a DaddyHoggy moment.
Oolite Life is now revealed here
User avatar
maik
Wiki Wizard
Wiki Wizard
Posts: 2020
Joined: Wed Mar 10, 2010 12:30 pm
Location: Ljubljana, Slovenia (mainly industrial, feudal, TL12)

Re: Save Any Where OXP Version 3.1 [RELEASE]

Post by maik »

Found it in CommonSenseOTB's User page on the wiki, escaped my attention before...
Post Reply