Javascript Exceptions after Blowup

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

Moderators: winston, another_commander

Post Reply
User avatar
hiran
Theorethicist
Posts: 2403
Joined: Fri Mar 26, 2021 1:39 pm
Location: a parallel world I created for myself. Some call it a singularity...

Javascript Exceptions after Blowup

Post 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
Sunshine - Moonlight - Good Times - Oolite
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2453
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia
Contact:

Re: Javascript Exceptions after Blowup

Post by Wildeblood »

It's a frame callback not ending on ship.died(), I will bet one dollar.
In your heart, you know it's flat.
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: Javascript Exceptions after Blowup

Post 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.
User avatar
Cholmondely
Archivist
Archivist
Posts: 5365
Joined: Tue Jul 07, 2020 11:00 am
Location: The Delightful Domains of His Most Britannic Majesty (industrial? agricultural? mainly anything?)
Contact:

Re: Javascript Exceptions after Blowup

Post 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?
Comments wanted:
Missing OXPs? What do you think is missing?
Lore: The economics of ship building How many built for Aronar?
Lore: The Space Traders Flight Training Manual: Cowell & MgRath Do you agree with Redspear?
User avatar
hiran
Theorethicist
Posts: 2403
Joined: Fri Mar 26, 2021 1:39 pm
Location: a parallel world I created for myself. Some call it a singularity...

Re: Javascript Exceptions after Blowup

Post 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
Sunshine - Moonlight - Good Times - Oolite
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6683
Joined: Wed Feb 28, 2007 7:54 am

Re: Javascript Exceptions after Blowup

Post by another_commander »

Jens explaining frame callbacks:
viewtopic.php?t=8941
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6683
Joined: Wed Feb 28, 2007 7:54 am

Re: Javascript Exceptions after Blowup

Post 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.
User avatar
Cholmondely
Archivist
Archivist
Posts: 5365
Joined: Tue Jul 07, 2020 11:00 am
Location: The Delightful Domains of His Most Britannic Majesty (industrial? agricultural? mainly anything?)
Contact:

Re: Javascript Exceptions after Blowup

Post 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.
Comments wanted:
Missing OXPs? What do you think is missing?
Lore: The economics of ship building How many built for Aronar?
Lore: The Space Traders Flight Training Manual: Cowell & MgRath Do you agree with Redspear?
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2453
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia
Contact:

Re: Javascript Exceptions after Blowup

Post 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.
In your heart, you know it's flat.
User avatar
hiran
Theorethicist
Posts: 2403
Joined: Fri Mar 26, 2021 1:39 pm
Location: a parallel world I created for myself. Some call it a singularity...

Re: Javascript Exceptions after Blowup

Post 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'.
Sunshine - Moonlight - Good Times - Oolite
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6683
Joined: Wed Feb 28, 2007 7:54 am

Re: Javascript Exceptions after Blowup

Post 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.
Post Reply