Page 1 of 1

Javascript Exceptions after Blowup

Posted: Sat Jul 27, 2024 4:43 pm
by hiran
I just died in my ship. Looks like I was rammed again by a Thargoid missile. To verify I opened the log and found lots of JavaScript errors. Here's an excerpt...

Code: Select all

18:34:27.804 [script.javaScript.exception.notDefined]: ***** JavaScript exception (oolite-starter-oxp 0.1): ReferenceError: sender is not defined
18:34:27.804 [script.javaScript.exception.notDefined]:       AddOns/org.oolite.hiran.OoliteStarter.oxp/Config/script.js, line 395.
18:34:27.939 [script.javaScript.exception.notDefined]: ***** JavaScript exception (oolite-starter-oxp 0.1): ReferenceError: sender is not defined
18:34:27.939 [script.javaScript.exception.notDefined]:       AddOns/org.oolite.hiran.OoliteStarter.oxp/Config/script.js, line 661.
18:34:27.939 [script.javaScript.stackTrace]:  0 (/home/hiran/GNUstep/Library/ApplicationSupport/Oolite/ManagedAddOns/oolite.oxp.Commander_McLane.Auto_Eject.oxz/Config/script.js:58) <anonymous function>
18:34:29.955 [script.javaScript.exception.unexpectedType]: ***** JavaScript exception (safetycatch 1.3): TypeError: m is undefined
18:34:29.955 [script.javaScript.exception.unexpectedType]:       /home/hiran/GNUstep/Library/ApplicationSupport/Oolite/ManagedAddOns/oolite.oxp.Norby.SafetyCatch.oxz/Scripts/safetycatch.js, line 94.
18:35:06.154 [script.javaScript.exception.unexpectedType]: ***** JavaScript exception (<unidentified script>): TypeError: p.velocity is undefined
18:35:06.154 [script.javaScript.exception.unexpectedType]:       /home/hiran/GNUstep/Library/ApplicationSupport/Oolite/ManagedAddOns/oolite.oxp.Gnievmir.VimanaHUD.oxz/Scripts/VimanaHUD.js, line 1009.
18:35:06.167 [script.javaScript.exception.unexpectedType]: ***** JavaScript exception (<unidentified script>): TypeError: p.velocity is undefined
18:35:06.168 [script.javaScript.exception.unexpectedType]:       /home/hiran/GNUstep/Library/ApplicationSupport/Oolite/ManagedAddOns/oolite.oxp.Gnievmir.VimanaHUD.oxz/Scripts/VimanaHUD.js, line 1009.
18:35:06.181 [script.javaScript.exception.unexpectedType]: ***** JavaScript exception (<unidentified script>): TypeError: p.velocity is undefined
18:35:06.181 [script.javaScript.exception.unexpectedType]:       /home/hiran/GNUstep/Library/ApplicationSupport/Oolite/ManagedAddOns/oolite.oxp.Gnievmir.VimanaHUD.oxz/Scripts/VimanaHUD.js, line 1009.
18:35:06.194 [script.javaScript.exception.unexpectedType]: ***** JavaScript exception (VimanaHUD 2.07): TypeError: p.fuel is undefined
18:35:06.194 [script.javaScript.exception.unexpectedType]:       /home/hiran/GNUstep/Library/ApplicationSupport/Oolite/ManagedAddOns/oolite.oxp.Gnievmir.VimanaHUD.oxz/Scripts/VimanaHUD.js, line 473.
18:35:06.195 [script.javaScript.exception.unexpectedType]: ***** JavaScript exception (<unidentified script>): TypeError: p.velocity is undefined
18:35:06.195 [script.javaScript.exception.unexpectedType]:       /home/hiran/GNUstep/Library/ApplicationSupport/Oolite/ManagedAddOns/oolite.oxp.Gnievmir.VimanaHUD.oxz/Scripts/VimanaHUD.js, line 1009.
18:35:06.207 [script.javaScript.exception.unexpectedType]: ***** JavaScript exception (useful_MFDs 0.6): TypeError: ship.fuel is undefined
18:35:06.207 [script.javaScript.exception.unexpectedType]:       /home/hiran/GNUstep/Library/ApplicationSupport/Oolite/ManagedAddOns/oolite.oxp.zirael.UsefulMFDs.oxz/Config/script.js, line 93.
18:35:06.208 [script.javaScript.exception.unexpectedType]: ***** JavaScript exception (<unidentified script>): TypeError: p.velocity is undefined

Re: Javascript Exceptions after Blowup

Posted: Sat Jul 27, 2024 7:11 pm
by Wildeblood
It's a frame callback not ending on ship.died(), I will bet one dollar.

Re: Javascript Exceptions after Blowup

Posted: Sun Jul 28, 2024 6:40 am
by phkb
I regularly have to test crashing my ship, to make sure I've included the right tests in the right spots, to prevent these sorts of errors.

Basically, any reference to "player.ship" (or any of its properties) will fail if the player dies.

Re: Javascript Exceptions after Blowup

Posted: Sun Jul 28, 2024 7:22 am
by Cholmondely
Wildeblood wrote: Sat Jul 27, 2024 7:11 pm
It's a frame callback not ending on ship.died(),
Thy eminence,

when I google "frame callback" I find nothing that seems to explain what it is.


Any chance of explaining to this dumb pilot... and also why it is important?

Re: Javascript Exceptions after Blowup

Posted: Sun Jul 28, 2024 7:37 am
by hiran
Cholmondely wrote: Sun Jul 28, 2024 7:22 am
Wildeblood wrote: Sat Jul 27, 2024 7:11 pm
It's a frame callback not ending on ship.died(),
Thy eminence,

when I google "frame callback" I find nothing that seems to explain what it is.


Any chance of explaining to this dumb pilot... and also why it is important?
Seems the big almighty Google is not all-knowing:
https://wiki.alioth.net/index.php?title ... back&go=Go
search.php?keywords=frame+callback

Re: Javascript Exceptions after Blowup

Posted: Sun Jul 28, 2024 7:50 am
by another_commander
Jens explaining frame callbacks:
viewtopic.php?t=8941

Re: Javascript Exceptions after Blowup

Posted: Sun Jul 28, 2024 8:01 am
by another_commander
And, because reading Jens' tech stuff sometimes feels like high level post-PhD physics, here is the one- sentence summary:
Frame callbacks are user-defined JavaScript functions that run on every single game frame update.

Re: Javascript Exceptions after Blowup

Posted: Sun Jul 28, 2024 8:05 am
by Cholmondely
another_commander wrote: Sun Jul 28, 2024 7:50 am
Jens explaining frame callbacks:
viewtopic.php?t=8941
Thanks for this!

So there are only the two types of "animation" in Oolite then? Or have newer ones been added?

I'll have to have a look at Thargoid's Frame Callback: Animation Demo - when I added it to the wiki I had no idea what it was about.

Re: Javascript Exceptions after Blowup

Posted: Sun Jul 28, 2024 9:29 am
by Wildeblood
Cholmondely wrote: Sun Jul 28, 2024 8:05 am
So there are only the two types of "animation" in Oolite then? Or have newer ones been added?
If you're alluding to timers and frame callbacks, then yes, two.

Re: Javascript Exceptions after Blowup

Posted: Sun Jul 28, 2024 9:50 am
by hiran
Wildeblood wrote: Sun Jul 28, 2024 9:29 am
Cholmondely wrote: Sun Jul 28, 2024 8:05 am
So there are only the two types of "animation" in Oolite then? Or have newer ones been added?
If you're alluding to timers and frame callbacks, then yes, two.
I'd think of them rather as triggers than animations.

So on specific events (e.g. change in alert status), or when a frame is about to be rendered an OXP-defined function can be called.
Similarly a timer would call a user-defined function just because time has progressed.

The OXP defines the function but it is Oolite to call them when the specific event happens. That's why it is called 'callback' or 'event handler'.

Re: Javascript Exceptions after Blowup

Posted: Sun Jul 28, 2024 9:57 am
by another_commander
Yeah, animations are just one application of timers and/or frame callbacks.

Anything that requires accurately timed updates (or per-frame updates in the case of frame callbacks) can make use of them.